-
Notifications
You must be signed in to change notification settings - Fork 72
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
Utilize tag on fastAPI paths to only create tools when opted-in #5
base: main
Are you sure you want to change the base?
Changes from all commits
41102e6
149d81b
7383c45
f6316f0
121f823
c9d500f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,39 @@ add_mcp_server( | |
|
||
That's it! Your auto-generated MCP server is now available at `https://app.base.url/mcp`. | ||
|
||
By default, all registered FastAPI paths will have MCP tools created for them | ||
|
||
If you wish to turn on the ability to not have tools created by default, pass | ||
the `create_tools_by_default = false` flag into your `add_mcp_server` call. | ||
|
||
Ex ) | ||
|
||
``` | ||
add_mcp_server( | ||
app, | ||
mount_path="/mcp", | ||
name="My API MCP", | ||
create_tools_by_default = false | ||
) | ||
``` | ||
|
||
Then, for each path you wish to create a tool for, include the following in the path's tags: `include_in_mcp` | ||
|
||
Ex) | ||
|
||
``` | ||
@app.post("/items/", response_model=Item, tags=["items", "include_in_mcp"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am interested in using tags to classify resource types for mcp. I was thinking about using something like How would you feel about changing the keyword tag to I'm not an owner/official maintainer of this repository, just voicing my thoughts. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's actually funny you suggest- I'm not an owner or maintainer either, but felt like this was needed so we could use the library. Someone at my company actually suggested we have a list of tags that we utilize instead for defining mcp tools. the idea is that folks could reuse the tags they already have, or add new ones, to indicate what should have tools built upon them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, 100% agreed. Also, I only included half a thought in my review. What I meant to say is that I just started working on a piece of code to expose endpoints as specific MCP types. I was thinking about using tags to indicate how each endpoint should be classified. I'm wondering if maybe that might be the solution. In the code I'm working on, maybe you add tags to endpoints if you want to classify the endpoint as a different MCP type (defaults to tool as normal). Then you could have an option to |
||
async def create_item(item: Item): | ||
""" | ||
Create a new item. | ||
|
||
Returns the created item. | ||
""" | ||
return item | ||
``` | ||
|
||
If `create_tools_by_default` is set to 'false', any paths _without_ the `include_in_mcp` tag will not have a corresponding MCP tool created. | ||
|
||
## Advanced Usage | ||
|
||
FastAPI-MCP provides several ways to customize and control how your MCP server is created and configured. Here are some advanced usage patterns: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
|
||
setup( | ||
name="fastapi-mcp", | ||
version="0.1.4", | ||
version="0.1.5", | ||
description="Automatic MCP server generator for FastAPI applications - converts FastAPI endpoints to MCP tools for LLM integration", | ||
author="Tadata Inc.", | ||
author_email="[email protected]", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
False
should be capitalized.