Get an API key
MCP concepts

Transport headers

Some tools declare that an argument must travel as an HTTP header. The rules are narrow, and a definition that breaks them is invalid rather than merely awkward.

declared in the schemastatically reachable onlyASCII or encoded
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

What they are for

Intermediaries — gateways, routers — read headers without opening the body. A tool can therefore declare that one of its parameters belongs in a header, and the specification also requires a header naming the server on certain methods.

Only along a direct chain of properties

An annotation under a branching construct makes the definition invalid

If it sits under an array's items, or under a construct that could take one of several shapes, there is no single path to read in the arguments — so there is no way to know which value to put in the header. The specification calls such a tool invalid, and it is rejected with that reason rather than guessed at.

What a header value may contain

ValueSent as
Plain visible ASCII, no surrounding spacesitself
Anything else — accents, newlines, control charactersencoded behind the sentinel the specification defines
Plain ASCII that looks like the sentinelencoded too

The last row is the subtle one: a value that already resembles the encoding marker would be decoded by the server into something other than what the body carries — exactly the mismatch the protocol has an error code for.

A mismatch is reported precisely

A modern server answering that the header does not match the body is saying something specific. It is not a reason to retry with an older handshake, which would replace the real cause with a different one.

If you call the client yourself

Pass the tool's recorded schema to call(). Without it an annotated argument stays in the body and the server refuses. api.mcp.call() does this for you.