Skip to content

fix(server): check a GET's Accept and protocol version before the SSE upgrade - #1210

Open
yadava5 wants to merge 1 commit into
modelcontextprotocol:mainfrom
yadava5:fix-get-validation-before-sse
Open

yadava5 wants to merge 1 commit into
modelcontextprotocol:mainfrom
yadava5:fix-get-validation-before-sse

Conversation

@yadava5

@yadava5 yadava5 commented Nov 20, 2026 •

Copy link
Copy Markdown

GET goes through sse {}, which sends 200 before its handler runs, so the Accept (406) and MCP-Protocol-Version (400) checks came too late. The GET guard from #1032 now runs both before the upgrade, reusing the transport's checks. With #1032 this covers all four cases in the issue.

closes #1036

How Has This Been Tested?

Two new StreamableHttpResponseDeliveryTest cases fail on main with 200 and pass with the fix. Server jvmTest, ktlint, detekt and checkKotlinAbi pass, and so do Build and Conformance on my fork.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

I used Claude Code to write and test this.

… upgrade

mcpStreamableHttp serves GET through Ktor's sse {}, which sends 200 and
the event-stream headers before its handler runs. The Accept and
MCP-Protocol-Version checks in StreamableHttpServerTransport's GET
handling ran inside that handler, so a GET without text/event-stream in
Accept, or with an unsupported protocol version, got 200 and an empty
stream instead of 406 or 400.

The route's GET guard, which already rejects a missing or unknown
session before sse {}, now runs both checks too, in the transport's
order: Accept, then session, then protocol version. It reuses the
transport's own checks rather than copying them; the transport keeps
them for callers that route GETs to handleRequest themselves.

Verified with two new StreamableHttpResponseDeliveryTest cases that fail
on main with 200 and pass with the fix, and fail again when the guard
change alone is reverted. kotlin-sdk-server jvmTest (202 tests),
ktlintCheck, detekt and checkKotlinAbi pass.

With modelcontextprotocol#1032 covering the missing and unknown session rows, this handles
all four cases in the issue.

Closes modelcontextprotocol#1036
Copilot AI balanced review requested due to automatic review settings November 20, 2026 00:51

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
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.

Streamable HTTP: rejected GET requests get 200 OK

2 participants