Skip to content

Commit 40529cf

Browse files
fix: use environment variable for FastMCP stateless_http mode
Use FASTMCP_STATELESS_HTTP env var instead of constructor parameter to avoid deprecation warning in FastMCP >= 2.x. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3b6e97b commit 40529cf

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

api/mcp/server.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ async def get_mcp_db_session() -> AsyncSession:
6464
return _mcp_session_factory()
6565

6666

67+
# Enable stateless HTTP mode via environment variable (recommended approach)
68+
# This allows horizontal scaling without session affinity
69+
os.environ.setdefault("FASTMCP_STATELESS_HTTP", "true")
70+
6771
# Initialize FastMCP server
68-
# stateless_http=True allows horizontal scaling without session affinity
69-
mcp_server = FastMCP("pyplots", stateless_http=True)
72+
mcp_server = FastMCP("pyplots")
7073

7174

7275
@mcp_server.tool()

0 commit comments

Comments
 (0)