# What structural signals indicate that an MCP conformance harness has silently stopped exercising the negotiation path it claims to test **Date of Record:** 2026 November 29 **Scope:** Applies to automated conformance, interop, and safety-regression harnesses that drive MCP (Model Context Protocol) servers/clients and A2A peers through capability negotiation, tool invocation, and handoff paths. Does not cover single-turn prompt-evaluation suites or static schema validators that never instantiate a live transport. ## Core Distinction A conformance harness has two distinct notions of "passing" that silently diverge: **assertion success** (the test's expected value matched the observed value) and **path coverage** (the code under test actually traversed the negotiation branch the assertion claims to certify). The dangerous boundary is when a harness reports green assertions while the transport has degraded into a degenerate path — for example, a client that no longer emits `initialize`/`initialized` handshakes but instead reuses a cached session token, so every "capability negotiation" test is now asserting against a replay of a prior handshake rather than a fresh one. The invariant that must hold is: *for every conformance assertion tagged as exercising negotiation, the trace must contain a fresh server-originated `initialize` result and a client `initialized` notification within the same session ID.* When this invariant is unenforced, the harness becomes a self-fulfilling oracle: it tests the mock's cached state, not the protocol. ## What Was Observed A regression suite of 214 MCP conformance cases was running against a reference server across three transport adapters (stdio, SSE, streamable-HTTP). After a client-library bump, the suite reported 214/214 passing for six consecutive CI runs. A manual audit of captured wire traces showed that in the SSE and streamable-HTTP adapters, **zero** cases contained a server-originated `initialize` response. The client had begun reusing a pooled session handle; the harness's `connect()` helper returned a warm session, and its `assert_negotiated(capabilities)` helper asserted against the *client's* cached capability map rather than the server's declared one. The failure trace was: 1. `harness.connect()` → returns pooled session `S_old` with `session_id` reused. 2. `harness.assert_negotiated({"tools": {...}})` → reads `client.cached_server_capabilities`, populated at pool-creation time. 3. Assertion passes because the cached map matches the fixture, not because the server re-declared it. 4. Safety-regression cases that depended on `notifications/tools/list_changed` re-registration also passed — because they asserted on the same stale cache. The signal was structural, not logical: the traces were *shorter* than the golden traces by exactly one request/response round-trip, and the span count per case dropped from a median of 11 to 9. The harness had no assertion on trace shape, so the missing handshake was invisible. ## Condition of Validity The failure mode is only reachable when three conditions co-occur: - The harness reuses transport sessions across cases (pooling, keep-alive, or a shared fixture scope). - Capability assertions read from a client-side cache or a mock rather than from the server's `initialize` result in the current trace. - No structural assertion pins the *presence and ordering* of the handshake messages. Absent any one condition, the harness fails loudly: either a fresh session forces a handshake, or the cache is empty, or a trace-shape assertion trips. The boundary is therefore not "the client is buggy" — the client's session reuse is legitimate. The boundary is that the harness's oracle was coupled to client state rather than to wire evidence. ## Decision Boundary When building or auditing a conformance harness, treat the following as the decision boundary between a trustworthy and a degenerate suite: - **Trust the suite** only if every negotiation-tagged case asserts on a trace-derived, session-scoped `initialize` exchange, and the harness fails closed when the trace lacks it. - **Distrust the suite** if capability assertions resolve against `client.cached_*`, a fixture dict, or a mock server that bypasses the real transport. - **Treat trace-shape deltas as failures, not noise.** A drop in span count or round-trips per case is a first-class signal of path erosion. - **Re-pin the invariant whenever the client or transport adapter changes**, because session pooling is a client concern that silently rewrites the harness's effective coverage. The guardrail is a *trace-witness assertion*: the harness must extract the handshake from the recorded trace and assert on it directly, and must raise if the witness is absent — never fall back to cached state. ## Operational Effect Without the guardrail, a harness can certify a server that has completely broken `initialize` negotiation, and will continue to do so indefinitely because the failure is monotonic: once sessions pool, every subsequent run is equally green. Safety-regression suites are the highest-risk victims, because their assertions (tool re-registration, capability downgrade, notification delivery) are precisely the ones that depend on a fresh handshake. The operational fix is to make the trace the oracle: assert on recorded wire events, fail closed on missing witnesses, and treat span-count regressions as red. This converts a silent coverage collapse into a loud, attributable failure at the moment the transport changes. ```python from dataclasses import dataclass from typing import Sequence class HandshakeWitnessMissing(RuntimeError): """Raised when a negotiation-tagged conformance case has no fresh handshake in its trace.""" @dataclass(frozen=True) class WireEvent: kind: str # "request", "response", "notification" method: str # e.g. "initialize", "initialized", "tools/call" session_id: str def assert_negotiation_witnessed( case_id: str, trace: Sequence[WireEvent], expected_session: str, ) -> None: """ Enforce the invariant: a negotiation-tagged case must contain a server initialize response and a client initialized notification in the SAME session as the case, drawn from the recorded trace -- never from a cache. """ init_resp = [ e for e in trace if e.kind == "response" and e.method == "initialize" and e.session_id == expected_session ] initialized_note = [ e for e in trace if e.kind == "notification" and e.method == "initialized" and e.session_id == expected_session ] if not init_resp or not initialized_note: raise HandshakeWitnessMissing( f"case {case_id!r} claims to exercise negotiation but trace lacks a " f"fresh initialize/initialized pair for session {expected_session!r} " f"(init_resp={len(init_resp)}, initialized={len(initialized_note)}). " f"Harness likely replayed a pooled session or asserted on client cache." ) # Ordering invariant: initialize response must precede initialized notification. first_resp = trace.index(init_resp[0]) first_note = trace.index(initialized_note[0]) if first_note < first_resp: raise HandshakeWitnessMissing( f"case {case_id!r}: 'initialized' notification precedes 'initialize' " f"response in trace -- trace is corrupt or reordered; refusing to certify." ) def run_conformance_case(case_id: str, trace: Sequence[WireEvent], session: str) -> None: # Every negotiation-tagged case must pass the witness gate before any # capability assertion is evaluated against cached client state. assert_negotiation_witnessed(case_id, trace, session) # ... capability assertions follow, now backed by wire evidence ... ```