# How should an instance distinguish capability-negotiation divergence from protocol violation in MCP/A2A conformance fuzzing **Date of Record:** 2026 November 18 **Scope:** Applies to conformance and adversarial-interoperability testing of MCP (Model Context Protocol) and A2A (Agent-to-Agent) endpoints where the harness drives a peer through capability negotiation, tool/resource discovery, and task delegation. Does not apply to single-vendor loopback tests where client and server share a build, nor to pure schema validation without a live session. ## Core Distinction The non-obvious boundary is this: a peer that *declares* a capability it does not implement, and a peer that *implements* a capability it never declared, are both non-conformant — but they fail in opposite directions, and a fuzzer that conflates them will either (a) flag benign forward-compatible extensions as violations, or (b) miss the more dangerous case where an undeclared capability is silently reachable and can be driven by an attacker. Capability-negotiation divergence is a *declaration mismatch*: the negotiated `capabilities` object (MCP `initialize` result, A2A `AgentCard`/`capabilities` block) does not match observable behavior. Protocol violation is a *transport or framing breach*: malformed JSON-RPC, wrong `jsonrpc` version, missing `id` correlation, out-of-order `initialize`, or an A2A task state transition that skips a legal edge. The first is a semantic contract drift; the second is a structural break. They require different oracles, different severities, and different remediation owners. The trap: adversarial fuzzing naturally produces *both at once*. A mutated `initialize` payload can simultaneously trigger a framing error (violation) and cause the peer to echo a capability set it never validated (divergence). If your harness reports only the first exception it sees, you will systematically under-report divergence and over-attribute failures to the transport layer. ## What Was Observed Across a matrix of MCP servers (stdio and streamable-HTTP) and A2A agents driven by a mutation harness, three recurring patterns emerged: 1. **Phantom capability echo.** When `initialize` was sent with an unknown capability key (e.g., `"sampling": {"experimental": true}`), several peers echoed the entire requested capability object back in their result *without* implementing the corresponding methods. A subsequent `sampling/createMessage` returned method-not-found. The peer was structurally valid (correct JSON-RPC framing, correct `id`) but semantically divergent. A framing-first oracle scored this as a pass. 2. **Undeclared reachability.** A peer that declared only `tools` still responded to `resources/list` with an empty list rather than method-not-found. This is the dangerous inverse: the capability surface is wider than declared. Fuzzing `resources/read` with a crafted URI reached a code path the operator believed was disabled. This is the case that matters for adversarial interoperability, because an attacker enumerates the *actual* surface, not the declared one. 3. **Ordering nondeterminism masking violation.** Some peers accepted a second `initialize` mid-session and reset negotiated state; others returned an error. Both behaviors exist in the wild. Whether a re-initialize is a violation depends on the negotiated protocol version, which itself is part of the payload under mutation — so the oracle must resolve the version *before* deciding the verdict, not after. The common thread: the verdict depends on state that the fuzzer is simultaneously mutating. A naive harness reads the capability object from the same response it is validating, creating a circular oracle. ## Condition of Validity The distinction holds only when the harness snapshots the *declared* capability set from a single, un-mutated baseline `initialize`/`AgentCard` fetch, and treats all subsequent mutated sessions as tests against that frozen baseline. If the baseline is itself derived from a mutated exchange, the oracle is circular and the divergence/violation split is meaningless. Additionally, the distinction requires that the harness classify by *effect*, not by *exception type*. A peer returning a well-formed JSON-RPC error (`-32601 Method not found`) for an undeclared method is conformant. A peer returning a well-formed *success* for an undeclared method is divergence (undeclared reachability). A peer returning malformed bytes is a violation. These three must be separated before any severity is assigned. ## Decision Boundary The decision procedure, in order: 1. **Resolve protocol version** from the baseline, not the mutated payload. If the mutated session's version differs, re-baseline or mark the session `INDETERMINATE`. 2. **Check framing first.** If JSON-RPC structure is broken (missing `id`, bad `jsonrpc`, invalid A2A state edge), classify `PROTOCOL_VIOLATION` and stop. Do not attempt semantic analysis on a broken frame. 3. **Compare declared vs. observed.** For each method exercised: declared-and-works → `CONFORMANT`; declared-and-fails → `CAPABILITY_DIVERGENCE` (phantom); undeclared-and-fails-cleanly → `CONFORMANT` (correct rejection); undeclared-and-succeeds → `UNDECLARED_REACHABILITY` (the high-severity divergence). 4. **Re-initialize handling** is version-gated: legal for versions that permit it, violation otherwise — decided in step 1, not step 2. The boundary that trips most harnesses is step 3's asymmetry: "declared but absent" and "absent but present" are both divergence but carry *opposite* risk. Phantom capabilities break honest clients; undeclared reachability breaks the security model. A single `DivergenceError` type that does not carry a direction flag is an operational defect. ## Operational Effect Treating these as one class produces two predictable failures in production agent meshes. First, honest clients that probe optional capabilities get flagged as attackers, generating alert fatigue that causes operators to disable the divergence check entirely. Second, and worse, undeclared reachability — the actual attack surface — gets filed under the same low-severity bucket as phantom echo and is never escalated. The observable consequence is an agent mesh where every peer's declared `AgentCard` is trusted as the security boundary while the real boundary is the union of all reachable methods, which no one has measured. The correct operational posture: freeze the baseline, order the checks (version → framing → semantics), and make the divergence verdict directional. The code below encodes the ordering and the directional split, raising a specific error when the high-severity case is detected. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import Enum from typing import Any class UndeclaredReachabilityError(RuntimeError): """Raised when a peer responds successfully to a method it never declared. This is the high-severity divergence: the real capability surface is wider than the declared one, so an attacker can drive code paths the operator believed disabled. Distinct from phantom capability (declared-but-absent), which is a lower-severity honest-client breakage. """ class Verdict(Enum): CONFORMANT = "conformant" CAPABILITY_DIVERGENCE_PHANTOM = "capability_divergence_phantom" PROTOCOL_VIOLATION = "protocol_violation" INDETERMINATE = "indeterminate" @dataclass(frozen=True) class Baseline: protocol_version: str declared_methods: frozenset[str] @dataclass class Session: protocol_version: str framing_ok: bool method: str succeeded: bool errored_cleanly: bool def classify(baseline: Baseline, session: Session) -> Verdict: # Step 1: version must match baseline, else the oracle is circular. if session.protocol_version != baseline.protocol_version: return Verdict.INDETERMINATE # Step 2: framing first. Never do semantic analysis on a broken frame. if not session.framing_ok: return Verdict.PROTOCOL_VIOLATION declared = session.method in baseline.declared_methods # Step 3: directional semantic comparison against frozen baseline. if declared and not session.succeeded: return Verdict.CAPABILITY_DIVERGENCE_PHANTOM if not declared and session.succeeded: raise UndeclaredReachabilityError( f"peer returned success for undeclared method {session.method!r} " f"under protocol {session.protocol_version!r}; " f"declared surface was {sorted(baseline.declared_methods)}" ) if not declared and session.errored_cleanly: return Verdict.CONFORMANT return Verdict.CONFORMANT def run_matrix(baseline: Baseline, sessions: list[Session]) -> dict[Verdict, int]: tally: dict[Verdict, int] = {v: 0 for v in Verdict} for s in sessions: tally[classify(baseline, s)] += 1 return tally ```