Skip to content

feat(client): validate safe integer range for x-mcp-header parameters (#445) - #499

Open
Yudis-bit wants to merge 1 commit into
modelcontextprotocol:mainfrom
Yudis-bit:feat/sep-2243-safe-integer-range
Open

feat(client): validate safe integer range for x-mcp-header parameters (#445)#499
Yudis-bit wants to merge 1 commit into
modelcontextprotocol:mainfrom
Yudis-bit:feat/sep-2243-safe-integer-range

Conversation

@Yudis-bit

Copy link
Copy Markdown

Closes #445.

What

Per the Streamable HTTP specification (SEP-2243) and server/tools.mdx:

Constraints on x-mcp-header values:
Integer values MUST be within the safe range for integers represented using IEEE754 double-precision floating point numbers (−2^53+1 to 2^53−1).

Previously, this requirement was completely uncovered in the conformance test harness:

  • No check definition in src/seps/sep-2243.yaml (the list stopped at primitive-only).
  • No check ID emitted in src/scenarios/client/http-custom-headers.ts.
  • No scenario asked the client under test to call an annotated integer tool with an out-of-range integer value (e.g. 2**53 = 9007199254740992).
  • An SDK that mirrored out-of-range integers into Mcp-Param-* headers passed the conformance suite with zero indication.

Changes

  1. src/seps/sep-2243.yaml:
    • Added normative check requirement:
      - check: sep-2243-x-mcp-header-integer-safe-range
        text: 'Integer values MUST be within the safe range for integers represented using IEEE754 double-precision floating point numbers (−2^53+1 to 2^53−1).'
        url: https://modelcontextprotocol.io/specification/draft/server/tools#custom-headers
  2. src/scenarios/client/http-custom-headers.ts:
    • Added 'sep-2243-x-mcp-header-integer-safe-range' to CUSTOM_HEADERS_DECLARED_CHECK_IDS.
    • Added an annotated integer property unsafe_integer_val with x-mcp-header: 'UnsafeInteger' to the test_custom_headers tool definition.
    • Supplied unsafe_integer_val: 9007199254740992 (2**53) in urls.context.toolCalls[0].arguments.
    • In handleToolsCall, verified that the client does not mirror out-of-range integer arguments into Mcp-Param-UnsafeInteger, emitting SUCCESS when omitted and FAILURE when mirrored.
  3. src/scenarios/client/http-custom-headers.test.ts:
    • Added unit test verifying FAILs safe-integer-range when a client mirrors an out-of-range integer header.
    • Added unit test verifying PASSes safe-integer-range when a client omits the out-of-range integer header.
    • Updated existing tool-call assertions to supply unsafe_integer_val and verify that all declared requirement IDs in CUSTOM_HEADERS_DECLARED_CHECK_IDS pass on conforming tool calls.
  4. src/seps/traceability.json:
    • Updated SEP-2243 traceability entries and summary (tested: 19).

Validation

  • npm run check: typecheck (tsgo --noEmit) and lint (eslint & prettier) pass cleanly with 0 errors, 0 warnings.
  • npm run build: builds dist/index.js cleanly with 0 errors.
  • npm test: all 45 test files, 589 tests pass across the suite.
  • Pre-push hooks: formatting, linting, and full test suite pass cleanly on push.

AI assistance disclosure: Generated with Antigravity agent in pair-programming session following maintainer instructions on issue #445 with minimal reproducible test coverage.

…modelcontextprotocol#445)

Per the Streamable HTTP specification (SEP-2243) and server/tools.mdx:
'Integer values MUST be within the safe range for integers represented
using IEEE754 double-precision floating point numbers (−2^53+1 to 2^53−1)'

Previously, the conformance harness had no requirement row in sep-2243.yaml,
no emitted check ID, and no verification that clients refrain from mirroring
out-of-range integer values into Mcp-Param headers.

1. Add sep-2243-x-mcp-header-integer-safe-range to src/seps/sep-2243.yaml
   and CUSTOM_HEADERS_DECLARED_CHECK_IDS in http-custom-headers.ts.
2. Add an annotated integer parameter unsafe_integer_val to test_custom_headers
   with context argument 9007199254740992 (2^53).
3. In HttpCustomHeadersScenario.handleToolsCall, verify that the client does
   not mirror unsafe integer arguments into Mcp-Param-UnsafeInteger.
4. Add positive and negative unit test assertions in http-custom-headers.test.ts.
5. Update traceability.json for SEP-2243.

Closes modelcontextprotocol#445
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SEP-2243: safe-integer-range MUST is untested, and SDKs disagree on what it requires

1 participant