Skip to content

Duplicated standard MCP headers: only the first value is checked #1321

Closed

Description

@Kehrlann

HttpServletMcpTransport.validateHeaders reads Mcp-Method, Mcp-Name and MCP-Protocol-Version with HttpServletRequest#getHeader, which returns only the first value. Any further values of the same header are ignored.

Impact

SEP-2243 headers exist so intermediaries (gateways, load balancers, WAFs) can route and apply policy without parsing the body. Intermediaries disagree on which copy of a duplicated header counts: some take the first, some the last, some join them with , . A request such as:

Mcp-Method: tools/list
Mcp-Method: tools/call

with a tools/call body can be routed or authorized by a last-value proxy as tools/list, then accepted by the server, which only looks at the first value. The same applies to Mcp-Name (e.g. a policy of the form "allow tool X").

Expected behaviour

A standard header with more than one value is malformed. The server should reject the request with -32020 (HeaderMismatch) and HTTP 400. This applies to repeated header lines and to a single comma-joined value alike.

  • RFC 9110 §5.3: repeated header lines are equivalent to one comma-joined value. These headers hold a single value, not a list, so a joined value is invalid.
  • The spec lists "a header value contains invalid characters" as a validation failure.
  • This is already how Mcp-Param-{Name} headers are handled (McpHeaderDecoder.paramHeaders).

Proposed fix

Read the headers with getHeaders(name) and require exactly one value for Mcp-Method, Mcp-Name and MCP-Protocol-Version. Add tests for duplicated values of each.

Activity

  1. added this to the 2.2.0-M3 milestone on Nov 9, 2026
  2. self-assigned this
    on Nov 9, 2026
  3. added theissue type on Nov 9, 2026
  4. added
    bugSomething isn't working
    P2Moderate issues affecting some users, edge cases, potentially valuable feature
    on Nov 9, 2026
  5. added a commit that references this issue on Nov 9, 2026
    352ccf8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Moderate issues affecting some users, edge cases, potentially valuable featurearea/serverbugSomething isn't working

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions