Skip to content

mcp: ignore the session ID on server/discover responses - #1523

Closed
simon0191 wants to merge 1 commit into
modelcontextprotocol:mainfrom
simon0191:discover-session-id
Closed

simon0191 wants to merge 1 commit into
modelcontextprotocol:mainfrom
simon0191:discover-session-id

Conversation

@simon0191

Copy link
Copy Markdown

A legacy server may reject server/discover with HTTP 200 and a JSON-RPC error while setting Mcp-Session-Id. The streamable client stored that ID and sent it on the fallback initialize, so a server that assigned a new session ID made Connect fail with mismatching session IDs.

server/discover is sessionless in 2026-07-28, and under 2025-11-25 the session ID belongs to the response carrying the InitializeResult, so the client no longer records a session ID from a server/discover response.

The new table test covers the HTTP 200 / -32601 case and four HTTP 400 rejection shapes seen from real legacy servers (plain text, -32600 with an unmatched id, -32600 with legacy-only data.supported), each with a session ID on the discover response.

Fixes #1522

AI disclosure: written with Claude Code; I reviewed the change and can explain it.

A legacy server may reject server/discover with HTTP 200 and a JSON-RPC
error while setting Mcp-Session-Id. The streamable client stored that ID
and sent it on the fallback initialize, so a server that assigned a new
session ID made Connect fail with "mismatching session IDs".

server/discover is sessionless in 2026-07-28, and under 2025-11-25 the
session ID belongs to the response carrying the InitializeResult, so the
client no longer records a session ID from a server/discover response.

Fixes modelcontextprotocol#1522

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and you aren't currently assigned to #1522.

You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned. There's no need to open a new PR either way.

Maintainers: reopen, remove missing-issue-link, or add bypass-issue-check to override.

@github-actions github-actions Bot closed this Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcp: streamable client keeps the session ID from a rejected server/discover, so the fallback initialize fails

1 participant