Fix: wire WORKSPACE_MCP_STATELESS_MODE to FastMCP's stateless_http parameter

WORKSPACE_MCP_STATELESS_MODE=true was already read, validated, and used to
configure the OAuth layer — but was never passed to server.run(). FastMCP
therefore always ran in stateful mode, keeping session state in memory.

On pod/process restart all in-memory sessions are lost, causing clients to
receive {"code":-32600,"message":"Session not found"} on their next request.

Passes stateless_http=is_stateless_mode() to server.run() so FastMCP drops
session tracking when stateless mode is configured, matching what the env var
already advertises.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vincent Demay
2026-03-16 12:47:51 +01:00
parent 7fe01c1b86
commit f163ffbd30

View File

@@ -517,7 +517,12 @@ def main():
)
sys.exit(1)
server.run(transport="streamable-http", host=host, port=port)
server.run(
transport="streamable-http",
host=host,
port=port,
stateless_http=is_stateless_mode(),
)
else:
server.run()
except KeyboardInterrupt: