Skip to content

Conversation

@LucaButBoring
Copy link
Contributor

This is a backport of #1808 to the v1.x branch. Original PR description:

Summary

Fixes incorrect HTTP status code returned by StreamableHTTPSessionManager when receiving requests with unknown or expired session IDs.

Per the MCP Streamable HTTP transport specification, servers MUST respond with HTTP 404 (Not Found) when the session ID is not recognized. The previous implementation returned HTTP 400 (Bad Request), which incorrectly signals a malformed request rather than a missing resource.

This change aligns the Python SDK behavior with:

  • The MCP specification requirements
  • The TypeScript SDK implementation

Changes

  • Return HTTP 404 instead of 400 for unknown session IDs
  • Use JSON-RPC error format in the response body, matching TypeScript SDK behavior

Fixes #1727

…textprotocol#1808)

Co-authored-by: Max Isbey <224885523+maxisbey@users.noreply.github.com>
@maxisbey maxisbey merged commit 3d9d345 into modelcontextprotocol:v1.x Jan 24, 2026
37 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants