Integrate FastMCP servers into ASGI applications
New in version:Β 2.3.1
FastMCP servers can be integrated into existing ASGI applications, allowing you to add MCP functionality to your web applications. This is useful for:
http_app()
method to obtain a Starlette application instance:
http_app()
method is new in FastMCP 2.3.2. In older versions, use sse_app()
for SSE transport or streamable_http_app()
for Streamable HTTP transport./mcp/
for Streamable HTTP transport and /sse/
for SSE transport.
@custom_route
decorator:
/health
alongside your MCP endpoint at /mcp/
.
/mcp-server/mcp/
of the resulting Starlette app.
/outer/inner/mcp/
path.
New in version:Β 2.3.2
Add custom Starlette middleware to your FastMCP ASGI apps by passing a list of middleware instances:
uvicorn
: