Skip to content

fix: reject unsupported MCP protocol version headers#958

Open
zxyasfas wants to merge 1 commit into
modelcontextprotocol:mainfrom
zxyasfas:fix/streamable-http-version-header
Open

fix: reject unsupported MCP protocol version headers#958
zxyasfas wants to merge 1 commit into
modelcontextprotocol:mainfrom
zxyasfas:fix/streamable-http-version-header

Conversation

@zxyasfas
Copy link
Copy Markdown

@zxyasfas zxyasfas commented May 14, 2026

Fixes #957.

This keeps initialize on the existing negotiation path. At that point the client can still be advertising its newest supported protocol version, so rejecting the header before negotiation would break the current fallback behavior.

For later Streamable HTTP requests, the servlet now rejects a non-empty MCP-Protocol-Version value unless it is one of the server supported versions. That covers POST requests on an established session as well as GET and DELETE session operations.

I added an integration test that initializes a session, sends notifications/initialized, then verifies that tools/list returns 400 for both an unsupported version and a malformed version.

Tested with:
./mvnw.cmd -pl mcp-test -am -Dtest=HttpClientStreamableHttpVersionNegotiationIntegrationTests -Dsurefire.failIfNoSpecifiedTests=false test

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 accepts unsupported or malformed MCP-Protocol-Version headers

1 participant