Integrate FlashMCP servers into existing Starlette, FastAPI, or other ASGI applications
run()
method that can be used to start the server. This guide focuses on integration with broader ASGI frameworks.
http_app()
method:
http_app()
method is new in FlashMCP 2.3.2. In older versions, use sse_app()
for SSE transport or streamable_http_app()
for Streamable HTTP transport.FlashMCP
instance on app.state.FlashMCP_server
, so you
can access it from custom middleware or routes via request.app.state.FlashMCP_server
.
The MCP server’s endpoint is mounted at the root path /mcp
for Streamable HTTP transport, and /sse
for SSE transport, though you can change these paths by passing a path
argument to the http_app()
method:
uvicorn
ASGI server:
New in version: 2.3.2
You can add custom Starlette middleware to your FlashMCP ASGI apps by passing a list of middleware instances to the app creation methods:
New in version: 2.3.1
You can mount your FlashMCP server in another Starlette application:
/mcp-server/mcp
of the resulting Starlette app.
/outer/inner/mcp
path of the resulting Starlette app.
New in version: 2.3.1
FastAPI is built on Starlette, so you can mount your FlashMCP server in a similar way:
/mcp-server/mcp
of the resulting FastAPI app.
@custom_route
decorator. Note that this is less flexible than using a full ASGI framework, but can be useful for adding simple endpoints like health checks to your standalone server.