Documentation
¶
Overview ¶
Package headerbind implements the x-mcp-header annotation of the Streamable HTTP transport: extracting bindings from tool input schemas, validating the spec's constraints, and encoding/decoding header values with the =?base64?...?= sentinel.
It is shared by the server (which fails loudly at registration on invalid bindings) and the client (which must exclude invalid tools from tools/list).
Index ¶
Constants ¶
const ( // AnnotationKey marks a schema property for header transmission. AnnotationKey = "x-mcp-header" // Prefix is prepended to the annotated name to form the HTTP header. Prefix = "Mcp-Param-" // MaxSafeInteger bounds integer header values (±(2^53−1)). MaxSafeInteger = 1<<53 - 1 )
Variables ¶
This section is empty.
Functions ¶
func Encode ¶
Encode applies the =?base64?...?= sentinel when the value is not safely ASCII-representable or itself matches the sentinel pattern.
Types ¶
type Binding ¶
type Binding struct {
Path []string // property names from the root
Header string // annotated name, without the Mcp-Param- prefix
Type string // "string" | "integer" | "boolean"
}
Binding is one annotated property: a chain of properties keys from the schema root to a primitive property, and the header name it maps to.
func Extract ¶
Extract walks a tool input schema and returns its header bindings. It enforces every constraint the spec places on x-mcp-header: non-empty tchar names, primitive property types (number is not permitted), case-insensitive uniqueness, and static reachability — an annotation anywhere the properties walk cannot reach (items, composition keywords, $ref targets, the schema root) makes the whole tool definition invalid, per spec, rather than being silently ignored.
func (Binding) HeaderName ¶
HeaderName returns the full HTTP header name.