Build an MCP Server with FastAPI Infrastructure
You do not need to replace an existing FastAPI backend. The MCP Python SDK can expose a Streamable HTTP ASGI app that can be deployed alongside normal web routes.
Share service-layer code, not route handlers
Keep business logic in reusable services. Your FastAPI REST endpoints and MCP tools should both call the same service layer rather than calling each other over HTTP inside the same process.
ASGI integration
The current SDK exposes streamable_http_app(), which returns a Starlette-compatible application. This makes it possible to mount or compose MCP with existing ASGI infrastructure.
Lifespan matters
Initialize connection pools, HTTP clients, and other expensive dependencies once through application lifespan rather than creating them inside every tool call.
Authentication
Do not assume your existing browser-session authentication automatically protects MCP. Define the authorization model for remote MCP explicitly and validate tokens at the MCP boundary.