Fix "Missing session ID" by making the MCP transport stateless - #161
Merged
Conversation
Cloud Run logs (after the 421 fix deployed) showed several container instances each starting their own independent StreamableHTTP session manager -- confirms the default session manager's in-memory, per-instance session tracking doesn't survive a follow-up request landing on a different instance than the one that created the session (maxScale=15, no session affinity configured). Both tools (get_day, search_saints) are stateless reads with no need for server-side session state in the first place, so stateless_http=True is the correct fix rather than trying to force session affinity: it makes every request self-contained instead. Verified locally: a tools/call with no prior initialize on the connection and no session ID at all now succeeds. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hf6j2xXQXywHVh3HAVRxB3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/mcpstarted returning "Bad Request: Missing session ID."StreamableHTTP session managerin short succession -- confirms the SDK's default session manager tracks each session's transport in that process's own memory, but this service scales to multiple instances (maxScale=15, no session affinity configured), with no guarantee a session's follow-up request lands back on the instance that created it.get_day,search_saints) are stateless reads with no need for server-side session state in the first place, sostateless_http=Trueis the correct fix rather than trying to force session affinity: it makes every request self-contained instead.Test plan
docker compose run --rm tests— 135/135 passingtools/callwith no priorinitializeon the connection and no session ID at all now succeeds (200 OK, correct data) -- confirms statelessness, not just that the old flow still happens to work🤖 Generated with Claude Code
https://claude.ai/code/session_01Hf6j2xXQXywHVh3HAVRxB3