Why mcp-asgi-http exists
The official MCP Python SDK and FastMCP can expose Streamable HTTP. Tutorials show app.mount("/mcp", ...). That is enough for local demos.
Problems show up when you put the same pattern on Mangum with lifespan="off", share auth with a REST API, or hit Function URL slash redirects. This package is the small set of helpers we kept rewriting for that case:
- Stateless Streamable HTTP ASGI app (JSON responses, no session store)
- Path middleware instead of
Mountfor/mcp - Optional API key / JWT / dual auth, or
auth=Noneif the gateway already authenticated once_readyfor lazy init when lifespan never runs
It is not a tool framework. Register tools with the official SDK (or FastMCP). Use this to mount and protect /mcp next to your existing API.