Skip to content

[Server] Stop bundling queued notifications into the JSON answer of a request - #602

Merged
chr-hertel merged 1 commit into
modelcontextprotocol:mainfrom
chr-hertel:fix-json-answer-bundles-queue
Oct 15, 2026
Merged

chr-hertel merged 1 commit into
modelcontextprotocol:mainfrom
chr-hertel:fix-json-answer-bundles-queue

Conversation

@chr-hertel

Copy link
Copy Markdown
Member

Follow-up to #597: a plain request on a session with queued messages (e.g. resources/updated) was still answered with a JSON array of those messages and its response. The spec wants one JSON object there, and since 2025-06-18 there is no batching at all - Python mcp 2.x rejects it with -32700.

  • Queued messages turn the answer into SSE, carrying them ahead of the response(s), like an SSE answer of a suspended call already does
  • A JSON answer holds the response alone, or the array of responses for a batch

A standalone GET stream would be the more natural home for these messages, but the transport has none yet - so the SSE answer keeps them flowing until then.

Fixes chr-hertel#73

🤖 Generated with Claude Code

A JSON answer bundled the session's queued messages with the request's
response into one array, which clients on 2025-06-18 and later reject.
The queued messages now go out on an SSE answer ahead of the responses,
and a JSON answer holds the response alone.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@chr-hertel chr-hertel added this to the 0.9.0 milestone Oct 14, 2026
@chr-hertel chr-hertel added bug Something isn't working Server Issues & PRs related to the Server component improves spec compliance Improves consistency with other SDKs such as TyepScript labels Oct 14, 2026
@chr-hertel
chr-hertel requested a balanced review from Copilot October 14, 2026 23:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused change matches the intended behavior and includes regression coverage, with no blocking issues identified; tests were not executed.

0 open findings

What changed in this PR

Fixes queued notification delivery in StreamableHttpTransport without bundling notifications into JSON responses.

Changes:

  • Uses SSE when queued messages exist, sending them before request responses.
  • Adds regression coverage for single requests, batches, and JSON-only responses.
  • Documents the compatibility fix.
File Description
tests/​Unit/​Server/​Transport/​StreamableHttpTransportTest.php Tests queued-message SSE delivery and response-only JSON.
src/​Server/​Transport/​StreamableHttpTransport.php Selects SSE for queued messages; otherwise returns JSON responses alone.
CHANGELOG.md Documents the corrected response format.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@chr-hertel
chr-hertel merged commit 82e19d1 into modelcontextprotocol:main Oct 15, 2026
28 checks passed
@chr-hertel
chr-hertel deleted the fix-json-answer-bundles-queue branch October 15, 2026 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working improves spec compliance Improves consistency with other SDKs such as TyepScript Server Issues & PRs related to the Server component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Server] Any POST drains the session's outgoing queue into its JSON answer

2 participants