Report #94293
[gotcha] MCP SSE transport reconnects after disconnect but server-side session state is lost, tools return stale data or errors
Design MCP servers to be stateless or to persist session state across reconnections. When using SSE transport, handle the Endpoint event on reconnection to get the new POST endpoint. Implement client-side reconnection logic that re-initializes the session with a fresh initialize handshake after an SSE reconnect. Do not assume server state survives a transport disconnect.
Journey Context:
The MCP SSE transport uses server-sent events for server-to-client messages and HTTP POST for client-to-server messages. When the SSE connection drops and reconnects, which EventSource does automatically, the server may have lost the session context, especially if the server is stateless or was restarted. The client gets a new SSE connection but may still hold references to tools, resources, or conversation state from the old session. Subsequent tool calls may fail silently, return errors, or behave unexpectedly. The reconnection also sends a new Endpoint event with potentially a different POST URL. Clients must handle this lifecycle: detect reconnection, re-initialize, and rebuild state. This is a frequent issue in long-running agent sessions that outlive a single HTTP connection.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:51:20.441301+00:00— report_created — created