python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

2026 Streamable HTTP rejects whitespace-padded Mcp-Name values

Open DMomplaisir opened this issue 1 month ago • 3 comments

Description

The 2026 Streamable HTTP header validation rejects a valid Mcp-Name when its value has leading or trailing HTTP optional whitespace. Header field values are subject to HTTP whitespace normalization; a client or intermediary that sends Mcp-Name: tools/call is rejected with JSON-RPC error -32020, although the trimmed value names the registered method.

This also fails the official conformance case sep-2243 (header validation).

Reproduction

Send a valid 2026 request with:

  • MCP-Protocol-Version: 2026-07-28
  • Mcp-Method: tools/call
  • Mcp-Name: tools/call
  • a valid tools/call JSON-RPC body

On mcp 2.3.0, the SDK returns -32020 rather than accepting the header value after HTTP whitespace handling.

Expected

Normalize permitted surrounding HTTP whitespace before comparing the header value, while continuing to reject values that differ after normalization.

Environment

Python SDK 2.3.0; reproduced by the MCP conformance suite's sep-2243 header-validation case.

DMomplaisir avatar Oct 25 '26 22:10 DMomplaisir

Thanks for the focused reproduction. I’d normalize only permitted HTTP optional whitespace around Mcp-Name before comparing it with the registered method, then add regression coverage for leading and trailing whitespace while keeping mismatched values rejected. I used Codex to help review the issue and will review and own any change. Does that match the intended spec handling, and would it be okay for me to take this once assigned?

aritejhg avatar Oct 26 '26 01:10 aritejhg

Yep, that matches what I meant. I'd keep it to HTTP OWS (SP / HTAB) at the header boundary, then still reject anything that doesn't match after normalization.

@aritejhg thanks for taking a look, and @duongynhi000005-oss appreciate the repro + tests. The existing patch looks like the right direction, so no need for folks to duplicate the same fix. Happy to review or help verify sep-2243 once a maintainer picks an owner.

DMomplaisir avatar Oct 27 '26 06:10 DMomplaisir

Linking the existing implementation so it doesn’t get missed: #3764 already proposes trimming HTTP SP/HTAB before sentinel decoding and comparison. It was auto-closed by the assignment gate, not rejected on technical grounds. There is also the tested fork proposal linked above; I won’t create another implementation.

The behavior I want as the reporter is to remove surrounding wire-level OWS before decoding, while preserving whitespace inside a decoded Base64 value and continuing to reject actual header/body mismatches. That keeps a body name containing significant edge whitespace distinct from padding added around its encoded header.

AI disclosure: Codex reviewed the source and existing proposals and drafted this reply; I have not independently run either contributor’s tests.

DMomplaisir avatar Oct 27 '26 06:10 DMomplaisir