From 7d504fca10204e5f719583f75821ed16847b2ce9 Mon Sep 17 00:00:00 2001 From: Nora Xiao Date: Fri, 29 May 2026 17:22:20 +0000 Subject: [PATCH] Fix: run mcp-server-hello-world in stateless HTTP mode The FastMCP app was created with the default stateful HTTP transport, which requires clients to carry an mcp-session-id across requests. Clients that don't (e.g. the Databricks Assistant) get a fresh session on every POST and the server rejects follow-ups with HTTP 400. Pass stateless_http=True so each request is self-contained; this also avoids session-affinity problems on horizontally scaled Databricks Apps. Fixes #141 Co-authored-by: Isaac --- mcp-server-hello-world/server/app.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mcp-server-hello-world/server/app.py b/mcp-server-hello-world/server/app.py index f1ed172e..3b32b0fc 100644 --- a/mcp-server-hello-world/server/app.py +++ b/mcp-server-hello-world/server/app.py @@ -32,8 +32,15 @@ load_tools(mcp_server) # Convert the MCP server to a streamable HTTP application -# This creates a FastAPI app that implements the MCP protocol over HTTP -mcp_app = mcp_server.http_app() +# This creates a FastAPI app that implements the MCP protocol over HTTP. +# +# stateless_http=True makes each request self-contained instead of requiring a +# prior session-initialization handshake. Some MCP clients (e.g. the Databricks +# Assistant) do not send the `mcp-session-id` header, which causes stateful +# servers to reject follow-up requests with HTTP 400. Stateless mode also plays +# nicely with horizontally scaled Databricks Apps where requests may land on +# different replicas. +mcp_app = mcp_server.http_app(stateless_http=True) # ============================================================================ # FastAPI Application Setup