You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-2Lines changed: 26 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,6 +65,28 @@ That's it! Your auto-generated MCP server is now available at `https://app.base.
65
65
66
66
> **Note on `base_url`**: While `base_url` is optional, it is highly recommended to provide it explicitly. The `base_url` tells the MCP server where to send API requests when tools are called. Without it, the library will attempt to determine the URL automatically, which may not work correctly in deployed environments where the internal and external URLs differ.
67
67
68
+
## Tool Naming
69
+
70
+
FastAPI-MCP uses the `operation_id` from your FastAPI routes as the MCP tool names. When you don't specify an `operation_id`, FastAPI auto-generates one, but these can be cryptic.
71
+
72
+
Compare these two endpoint definitions:
73
+
74
+
```python
75
+
# Auto-generated operation_id (something like "read_user_users__user_id__get")
76
+
@app.get("/users/{user_id}")
77
+
asyncdefread_user(user_id: int):
78
+
return {"user_id": user_id}
79
+
80
+
# Explicit operation_id (tool will be named "get_user_info")
For clearer, more intuitive tool names, we recommend adding explicit `operation_id` parameters to your FastAPI route definitions.
87
+
88
+
To find out more, read FastAPI's official docs about [advanced config of path operations.](https://fastapi.tiangolo.com/advanced/path-operation-advanced-configuration/)
89
+
68
90
## Advanced Usage
69
91
70
92
FastAPI-MCP provides several ways to customize and control how your MCP server is created and configured. Here are some advanced usage patterns:
@@ -88,9 +110,11 @@ mcp = FastApiMCP(
88
110
mcp.mount()
89
111
```
90
112
91
-
### Mounting to a Separate FastAPI App
113
+
### Deploying Separately from Original FastAPI App
114
+
115
+
You are not limited to serving the MCP on the same FastAPI app from which it was created.
92
116
93
-
You can create an MCP server from one FastAPI app and mount it to a different app:
117
+
You can create an MCP server from one FastAPI app, and mount it to a different app:
0 commit comments