From f163ffbd30ff8b130e6860b97d134a0bdcf27443 Mon Sep 17 00:00:00 2001 From: Vincent Demay Date: Mon, 16 Mar 2026 12:47:51 +0100 Subject: [PATCH] Fix: wire WORKSPACE_MCP_STATELESS_MODE to FastMCP's stateless_http parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 8fb97c5..b11ef6a 100644 --- a/main.py +++ b/main.py @@ -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: