FastMCP stateless mode

16-12-2025

https://gofastmcp.com/deployment/http#horizontal-scaling

from fastmcp import FastMCP
 
mcp = FastMCP("My Server", stateless_http=True)
 
@mcp.tool
def process(data: str) -> str:
    return f"Processed: {data}"
 
app = mcp.http_app()

https://github.com/jlowin/fastmcp/issues/678

By default, FastMCP’s Streamable HTTP transport maintains server-side sessions. Sessions enable stateful MCP features like elicitation and sampling, where the server needs to maintain context across multiple requests from the same client.

This works perfectly for single-instance deployments. However, sessions are stored in memory on each server instance, which creates challenges when scaling horizontally.

For horizontally scaled deployments, enable stateless HTTP mode. In stateless mode, each request creates a fresh transport context, eliminating the need for session affinity entirely.