MCP x-mcp-header Validation Prevents Bad Tool Schemas from Reaching tools/list
The MCP x-mcp-header annotation, introduced with the 2026-07-28 Streamable HTTP transport, acts as a wire contract that mirrors selected tool arguments into HTTP headers so gateways and load balancers can act on them without parsing JSON-RPC. Invalid annotations — such as unsupported types, bad header-name suffixes, or unreachable nested properties — render an entire tool definition invalid and must be caught before the tool appears in tools/list. The official C# SDK v2 supports automatic schema generation and header projection via the McpHeader attribute on a stable release, requiring no preview pins. Strict rules govern what can be mirrored: only string, integer, and boolean properties qualify, header names must be unique case-insensitively, and annotated properties must be reachable through a direct properties path with no composition keywords in between. A sample dependency-free .NET 10 validator demonstrates pre-flight schema checking across twelve test cases, including encoding edge cases and null-argument handling.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in