Skip to content

mcp: reject unsupported protocol versions with -32022 when stateless - #1547

Merged
guglielmo-san merged 2 commits into
mainfrom
serob/handle-stateless-usupported-protocol-version
Nov 26, 2026
Merged

guglielmo-san merged 2 commits into
mainfrom
serob/handle-stateless-usupported-protocol-version

Conversation

@nahapetyan-serob

Copy link
Copy Markdown
Contributor

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

Fixes #1542

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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 -32022 with supported and requested versions instead of a plain-text 400.
  • Add MCPGODEBUG=plaintextversionrejection=1 to 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

Comment thread mcp/streamable.go Resolved
Comment thread mcp/streamable.go Resolved
@guglielmo-san
guglielmo-san merged commit 4b1a524 into main Nov 26, 2026
10 checks passed
@guglielmo-san
guglielmo-san deleted the serob/handle-stateless-usupported-protocol-version branch November 26, 2026 12:48
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: unsupported protocol version below 2026-07-28 still gets a plain-text 400, not -32022 (#1173 still reproduces)

3 participants