Skip to content

fix: validate MCP-Protocol-Version header in servlet transports - #1092

Open
ez-lbz wants to merge 1 commit into
modelcontextprotocol:mainfrom
ez-lbz:validate-protocol-version-header
Open

fix: validate MCP-Protocol-Version header in servlet transports#1092
ez-lbz wants to merge 1 commit into
modelcontextprotocol:mainfrom
ez-lbz:validate-protocol-version-header

Conversation

@ez-lbz

@ez-lbz ez-lbz commented Aug 16, 2026

Copy link
Copy Markdown

The streamable HTTP spec requires the server to answer with 400 Bad Request when the client sends an unsupported MCP-Protocol-Version header, and to accept the request when the header is missing (falling back to the negotiated version). The Servlet-based providers never read this header.

This change validates the MCP-Protocol-Version header in doGet, doPost, and doDelete of HttpServletStreamableServerTransportProvider and in doPost of HttpServletStatelessServerTransport, rejecting unsupported versions with a 400 JSON error response consistent with the existing error style.

Tests cover the version-header matrix (supported version accepted, unsupported version rejected, missing header accepted) across both providers.

@ez-lbz
ez-lbz force-pushed the validate-protocol-version-header branch from 6cd91c1 to 0e467ac Compare August 16, 2026 15:08
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.

1 participant