Skip to content

Add documentation tools #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

shira-ayal
Copy link
Collaborator

Describe your changes

Add a function to automatically create fetch_documentation tool, helping AI agents work with the API more efficiently.

Screenshots of the feature / bugfix

image

Checklist before requesting a review

  • Added relevant tests
  • Run ruff & mypy
  • All tests pass

@shira-ayal shira-ayal requested a review from shahar4499 April 7, 2025 14:00
Copy link

codecov bot commented Apr 7, 2025

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

def to_dict(self) -> Dict[str, Any]:
return asdict(self)

def _get_file_priority(file):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shiraayal-tadata is file a Path? a str? missing typing.

Comment on lines +29 to +35
# Create documentation tools for the MCP server
# Based on a single file
create_documentation_tools(mcp_server, "README.md")
# Based on a list of files
# create_documentation_tools(mcp_server, ["README.md", "README2.md", "llms.txt"])
# Based on a directory
# create_documentation_tools(mcp_server, "docs")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shiraayal-tadata
First, make this section a bit clearer, it's too dense.

Second, all these options should be explained in the README too, not just here.
It's unclear what happens when I do README.md + README2.md + llms.txt. Will one take precedence? Will all their text just be concatenated? Need a clearer explanation / example

Comment on lines +93 to +96
app = FastAPI()
mcp_server = add_mcp_server(app)

create_documentation_tools(mcp_server, "README.md")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shiraayal-tadata I would expect documentation tools to be a parameter and not a separate function we need to call.

The add_mcp_server() function takes a FastAPI app and mutates it, and that makes sense because we are not in control of the FastAPI instance.
But we are in control of our own MCP server instance, so there's no need for another mutating function that takes a server instance. We can just add it as a feature to the existing add_mcp_server() function.

A clearer syntax might be something like this:

app = FastAPI()
add_mcp_server(
    app=app,
    documentation_tools=create_documentation_tools("README.md")
)

Here, "documentation_tools" is a parameter expecting a set of tools in some format, and "create_documentation_tools" is not mutating any fastMCP instance. It's just a helper function that returns tools.

@shira-ayal shira-ayal closed this Apr 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants