Conformance burn-down: server-side InputRequiredResult, Mcp-Method/Name validation, x-mcp-header filter (14 scenarios → green)

Merged
MA
5mo ago
+1163-150

Bumps the conformance pin to 0.2.0-alpha.7 and clears 14 scenarios from the expected-failures baseline, leaving only the 4 that depend on unlanded design (client Mcp-Param-* emission, modern stateless SSE for progress, MCPServer prompt-pipeline InputRequiredResult, and the SEP-990 enterprise-auth waiver).

Motivation and Context

#2967 widened the lowlevel server return types for InputRequiredResult and #2968 gave Client.call_tool the allow_input_required / input_responses / request_state surface, but neither was reachable through the conformance harness: the everything-server had no MRTR fixture tools, the client driver had no SEP-2322 handler, and MCPServer's func_metadata.convert_result() still mangled an InputRequiredResult into TextContent. Separately, the SEP-2243 boundary checks (Mcp-Method/Mcp-Name cross-check, x-mcp-header validity) were unimplemented on both sides. This closes those gaps.

How Has This Been Tested?

All five conformance legs run green with --expected-failures at @modelcontextprotocol/conformance@0.2.0-alpha.7:

LegResult
server --suite active42 pass / 0 fail
server --suite draft69 pass / 1 expected fail
server --suite all --spec-version 2026-07-2897 pass / 2 expected fail
client --suite all402 pass / 7 expected fail (2 scenarios)
client --suite all --spec-version 2026-07-28352 pass / 5 expected fail (1 scenario)

./scripts/test: 2776 passed, 100% coverage, strict-no-cover clean. pyright: 0 errors.

Breaking Changes

None for v1-lineage callers. At 2026-07-28, ClientSession.list_tools() now drops tools whose x-mcp-header annotations are invalid (the spec MUST is on the client); handshake-era sessions are unaffected. The modern HTTP server entry now rejects requests where Mcp-Method/Mcp-Name headers contradict the body — handshake-era requests don't pass through that classifier rung.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

SDK changes

  • func_metadata.convert_result() passes InputRequiredResult through; MCPServer._handle_call_tool / call_tool return type widened to CallToolResult | InputRequiredResult. Context gains .input_responses / .request_state / .client_capabilities read-only props so a tool body can read what the client supplied.
  • shared/inbound.py: classify_inbound_request rung 2 cross-checks Mcp-Method == body.method and Mcp-Name == params.{name|uri} (new NAME_BEARING_METHODS map + decode_header_value). New find_invalid_x_mcp_header() validates the annotation per RFC 9110 token rules + uniqueness + primitive-type.
  • _streamable_http_modern.py filters tools/list results for invalid x-mcp-header at the modern HTTP boundary (so the version gate is structural, not a conditional in handler code).
  • ClientSession.list_tools applies the same filter when the negotiated version is modern. _make_modern_stamp now derives Mcp-Name from NAME_BEARING_METHODS (covers prompts/get and resources/read, not just tools/call); send_discover stamps Mcp-Method so the auto-mode probe doesn't fail the cross-check it just introduced.

Fixtures

  • everything-server: 8 test_input_required_result_* tools (elicitation/sampling/list_roots/request_state/multiple_inputs/multi_round/tampered_state/capabilities) + json_schema_2020_12_tool carrying the 2020-12 keywords the scenario checks. The tampered_state tool uses a fixture-local hmac to sign/verify requestState; an SDK-level helper is follow-up.
  • .github/actions/conformance/client.py: handlers for sep-2322-client-request-state (drives the four mock tools via allow_input_required=True) and http-invalid-tool-headers (lists then calls every surfaced tool).

Pin

CONFORMANCE_PKG moves from the pkg.pr.new@65fcd39 URL to the published @modelcontextprotocol/conformance@0.2.0-alpha.7; the URL fetch-and-verify steps are dropped now that npm's own integrity check applies. Baselined: alpha.7 introduces no new failures over the previous pin.

Stacked on #2968.

AI Disclaimer