2025年9月5日小于 1 分钟
from fastapi import FastAPI
from fastapi_mcp import FastApiMCP
app = FastAPI()
mcp = FastApiMCP(app)
mcp.mount()
@app.get("/hello")
async def hello():
return {"message": "Hello World"}
# Mount the MCP server directly to your FastAPI app
mcp.setup_server()
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)