fix(http-custom-headers): use spec-permitted x-mcp-header types

Merged
KL
5mo ago
+30-13

Summary

The http-custom-headers client scenario annotates three number-typed properties with x-mcp-header (priority and float_val, in both test_custom_headers and test_custom_headers_null). SEP-2243 forbids this:

MUST only be applied to parameters with primitive types (integer, string, boolean). Parameters with type number are not permitted.

The same spec says a conformant client MUST reject (exclude from tools/list) any tool whose x-mcp-header annotations violate the constraints:

Clients MUST reject tool definitions where any x-mcp-header value violates these constraints. Rejection means the client MUST exclude the invalid tool from the result of tools/list.

So a strict, spec-conformant client drops both test_custom_headers and test_custom_headers_null and never calls them - failing ClientSupportsCustomHeaders (and ClientCustomHeaderOmitNull) through no fault of its own. The fixture is internally inconsistent: it requires the client both to reject the tool (per the type constraint) and to call it and mirror its params.

This surfaced while implementing SEP-2243 client emission in the Python SDK (modelcontextprotocol/python-sdk#2990): the SDK rejects number per the spec text, so the scenario is unpassable as written. The TypeScript SDK works around it by deliberately allow-listing number against the spec (note in mcpParamHeaders.ts). Fixing the fixture lets both SDKs follow the spec text.

Changes

  • priority: number -> integer (both tools). Its value (42 / 1) and the resulting Mcp-Param-Priority header are unchanged.
  • float_val: drop the x-mcp-header annotation. A floating-point header parameter is exactly what the spec prohibits and has no valid replacement; the property stays in the body and is now asserted not to be mirrored, mirroring the existing negative check on the unannotated query parameter.
  • Treat 'integer' like 'number' in validateEncodedHeader and the check-id classification, so Priority keeps its cross-SDK numeric tolerance (42 vs 42.0) and lands under sep-2243-client-encode-values.

Verification

npm run typecheck
npm run lint
npm run build
npx vitest run src/scenarios/client/http-custom-headers.test.ts   # 5 passed
npm test                                                          # 315 passed

All pass.