Skip to content

Commit 8b29e00

Browse files
committed
add example
1 parent 99a80f2 commit 8b29e00

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)