MCP with FastAPI Infrastructure
An existing ASGI application can host normal HTTP APIs and MCP while sharing the same domain services, database pool, HTTP clients, auth logic, and tracing.
Share services, not endpoints
REST routes ─┐
├─ Domain services ─ DB/APIs
MCP tools ───┘Lifespan
Initialize pools and clients once. Closing and reopening a database pool per tool call creates unnecessary latency and connection pressure.
Policy boundaries
REST middleware assumptions may not map exactly to MCP. Verify authenticated caller context reaches every MCP capability and do not bypass domain authorization.