Repository navigation
mcp: reject unsupported protocol versions with -32022 when stateless - #1547
Merged
guglielmo-san merged 2 commits intoNov 26, 2026
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Ignoring the body read error in mcp/streamable.go causes oversized requests to receive 400/-32022 instead of the documented 413 response when the configured size limit is reached.
1 open issue
What changed in this PR
This PR addresses #1542 by making stateless Streamable HTTP servers that support modern protocols return structured version-rejection errors for unsupported legacy versions.
Changes:
- Return JSON-RPC
-32022with supported and requested versions instead of a plain-text 400. - Add
MCPGODEBUG=plaintextversionrejection=1to restore the previous behavior. - Add regression tests and document the compatibility option.
| File | Description |
|---|---|
mcp/streamable.go |
Implements structured version rejection and the compatibility option. |
mcp/streamable_test.go |
Tests version rejection, supported requests, and compatibility behavior. |
internal/docs/mcpgodebug.src.md |
Documents the option and its planned removal. |
docs/mcpgodebug.md |
Updates the generated compatibility-option documentation. |
Review effort: Balanced
guglielmo-san
approved these changes
Nov 26, 2026
guglielmo-san
deleted the
serob/handle-stateless-usupported-protocol-version
branch
November 26, 2026 12:48
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.

When the server supports 2026-07-28 or later, that check now answers with a
JSON-RPC
-32022error with the supported versions andthe requested one, for modern and legacy requests alike.
MCPGODEBUG=plaintextversionrejection=1restores the previous behavior.Fixes #1542