Module: Ask::MCP::XMcpHeader
- Defined in:
- lib/ask/mcp/x_mcp_header.rb
Overview
Validation of x-mcp-header annotations in tool inputSchemas
(2026-07-28, SEP-2243).
Servers MAY designate tool parameters to be mirrored into HTTP headers
via an x-mcp-header extension property. Clients using the Streamable
HTTP transport MUST reject a tool definition whose annotations violate
the constraints below (rejection = exclude the tool from tools/list);
clients on other transports (stdio, SSE) MAY ignore the annotations.
Constant Summary collapse
- TOKEN_RE =
RFC 9110 field-name token characters (1*tchar).
/\A[!#$%&'*+\-.^_`|~0-9A-Za-z]+\z/- PRIMITIVE_TYPES =
Primitive types that may carry an x-mcp-header annotation.
%w[string integer boolean].freeze
- JS_SAFE_MIN =
JavaScript safe integer range.
-(2**53) + 1
- JS_SAFE_MAX =
2**53 - 1
Class Method Summary collapse
-
.invalid_reason(schema) ⇒ Object
Returns the reason the tool definition's x-mcp-header annotations are invalid, or nil if the definition is valid (or has no annotations).
-
.safe_integer?(value) ⇒ Boolean
Whether an integer value is representable as a safe header value.
Class Method Details
.invalid_reason(schema) ⇒ Object
Returns the reason the tool definition's x-mcp-header annotations are invalid, or nil if the definition is valid (or has no annotations).
26 27 28 29 |
# File 'lib/ask/mcp/x_mcp_header.rb', line 26 def invalid_reason(schema) seen = {} find_invalid(schema, seen, tainted: false) end |
.safe_integer?(value) ⇒ Boolean
Whether an integer value is representable as a safe header value.
32 33 34 |
# File 'lib/ask/mcp/x_mcp_header.rb', line 32 def safe_integer?(value) value.is_a?(Integer) && value.between?(JS_SAFE_MIN, JS_SAFE_MAX) end |