Skip to main content

Module param_headers

Module param_headers 

Source
Expand description

Mcp-Param-{Name}: tool arguments a client mirrors into HTTP headers.

2026-07-28 (SEP-2243). A tool’s inputSchema may mark a property with x-mcp-header: "Region", and a client calling that tool over Streamable HTTP must then send the argument’s value as Mcp-Param-Region. A server that reads the body must check the two agree — an intermediary may have routed on the header while this server is about to act on the body — and refuse a disagreement with 400 and -32020 HeaderMismatch.

The rules here are the transport specification’s, quoted where they decide something: https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http#custom-headers-from-tool-parameters

  • Only properties statically reachable through properties keys count; an annotation under items, a composition keyword, a conditional or a $ref makes the annotation invalid, and an invalid one is not enforced.
  • Only string, integer and boolean parameters may be annotated.
  • “Parameter value is null” and “parameter not in arguments”: the server “MUST NOT expect the header”. “Client omits header but value is in body”: the server “MUST reject the request”.
  • A value wrapped as =?base64?…?= is decoded before comparison, and one whose payload is not valid Base64 is refused; a value without the exact wrapper is literal.
  • Integers compare numerically, so 42.0 and 42 agree.

Functions§

check
Checks every annotated argument against the Mcp-Param-* headers.
decode
Decodes a header value per the sentinel rule, or None if it is invalid.
encode
Encodes a value for a header that admits the Base64 sentinel.
has_invalid_annotation
Whether schema carries any x-mcp-header annotation the transport specification forbids.
headers_for
The Mcp-Param-* headers a client must send for arguments.