Skip to content

Streamable HTTP: a Base64-encoded Mcp-Name is rejected as a header mismatch instead of decoded #1234

Closed

Description

@romanidis

Describe the bug

validateMcpHeaders compares Mcp-Name with the body value as the raw header string. The 2026-07-28 spec lets a client Base64-wrap a name or resource URI that is not header-safe, and requires the server to decode it before comparing; the SDK decodes Mcp-Param-* that way but not Mcp-Name, so an encoded name is refused as a header mismatch.

mcp/streamable_headers.go (main): line 377 reads nameInHeader := header.Get(nameHeader) and compares it directly; decodeHeaderValue at line 496 exists and is applied only to Mcp-Param-* values at line 431.

Transport page, "Value encoding":

Servers and intermediaries that need to inspect these values MUST decode them accordingly. In particular, servers MUST decode an encoded Mcp-Name or Mcp-Param-{Name} value before comparing it to the corresponding request body value during Server Validation.

Tool names are usually header-safe, so this mostly bites resources/read: a resource template with a path argument that contains non-ASCII, which the spec allows, forces a conformant client to encode the URI, and every such read is then rejected.

To Reproduce

Register a tool named fast, then:

curl -s -X POST http://127.0.0.1:8080/mcp \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -H 'Mcp-Protocol-Version: 2026-07-28' \
  -H 'Mcp-Method: tools/call' \
  -H 'Mcp-Name: =?base64?ZmFzdA==?=' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"fast","arguments":{},"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientInfo":{"name":"probe","version":"1"},"io.modelcontextprotocol/clientCapabilities":{}}}}'

Observed: 400 with {"code":-32020,"message":"header mismatch: Mcp-Name header value '=?base64?ZmFzdA==?=' does not match body value 'fast'"}.

Expected behavior

The header decodes to fast, matches the body, and the call runs. The same decodeHeaderValue already used for Mcp-Param-* would do it.

Additional context

go-sdk v1.7.0; unchanged on main. Working around it with a handler in front of the SDK's that decodes the header before delegating.

Activity

  1. added
    P1
    on Sep 4, 2026
  2. added a commit that references this issue on Sep 6, 2026
    a5026ea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions