We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 99a80f2 commit 8b29e00Copy full SHA for 8b29e00
examples/mount_specific_router_example.py
@@ -0,0 +1,28 @@
1
+from examples.shared.apps import items
2
+from examples.shared.setup import setup_logging
3
+
4
+from fastapi import APIRouter
5
+from fastapi_mcp import FastApiMCP
6
7
+setup_logging()
8
9
10
+router = APIRouter(prefix="/other/route")
11
+items.app.include_router(router)
12
13
+mcp = FastApiMCP(
14
+ items.app,
15
+ name="Item API MCP",
16
+ description="MCP server for the Item API",
17
+ base_url="http://localhost:8000",
18
+)
19
20
+# Mount the MCP server to a specific router.
21
+# It will now only be available at `/other/route/mcp`
22
+mcp.mount(router)
23
24
25
+if __name__ == "__main__":
26
+ import uvicorn
27
28
+ uvicorn.run(items.app, host="0.0.0.0", port=8000)
0 commit comments