Expand description
Decoding the Mcp-Name header value.
Mcp-Name mirrors params.name (a tool or prompt name) or params.uri (a
resource URI). Tool names are only SHOULD-constrained to header-safe
characters and URIs are not constrained at all, so the spec defines a sentinel
escape: a value that cannot ride in an ASCII header field arrives as
Mcp-Name: =?base64?{Base64EncodedValue}?=The markers are lowercase and case-sensitive, and the payload is Base64 over
the UTF-8 bytes using the standard alphabet (the spec’s own example
=?base64?PT9iYXNlNjQ/bGl0ZXJhbD89?= contains /, so it is not URL-safe
Base64).
This matters to a meter for one blunt reason: the price book is keyed on tool
name. Matching =?base64?...?= against it does not merely fail to find the
tool, it silently prices every non-ASCII-named tool at the default rate. The
spec requires servers and intermediaries that inspect these values to “decode
them accordingly” before comparing.
Clients MUST also encode any plain-ASCII value that happens to look like the sentinel, so decoding is unambiguous: anything wearing the markers is encoded.
Enums§
- Name
Error - Why a
Mcp-Namevalue could not be decoded.
Constants§
- SENTINEL_
PREFIX - Opening marker of the Base64 sentinel form.
- SENTINEL_
SUFFIX - Closing marker of the Base64 sentinel form.
Functions§
- decode
- Decode a raw
Mcp-Nameheader value to the name the body actually carries. - encode
- Encode a value into the sentinel form. Test and client-side helper.
- is_
sentinel - Whether a raw header value is wearing the complete Base64 sentinel.