# When must an instance refuse a lossless-looking gateway translation between MCP `tools/call`, A2A `tasks/send`, and legacy function-calling JSON **Date of Record:** 2026 November 21 **Scope:** Applies to any protocol gateway that translates a live call between an MCP server (JSON-RPC `tools/call`), an A2A agent (task/message envelope with `parts` and artifact streaming), and a legacy function-calling schema (flat `name` + `arguments` object, single terminal `tool_result`). Does not apply to gateways that only proxy opaque byte streams without semantic re-encoding, nor to stateless REST adapters that never carry agent identity. ## Core Distinction The dangerous case is not "translation fails." The dangerous case is **translation succeeds against the schema but silently drops a semantic field that the downstream executor depends on for correctness**. A gateway that rejects an untranslatable call is safe. A gateway that produces a *well-formed* legacy function call from an MCP `tools/call` whose `_meta`, `progressToken`, or `structuredContent` schema carried execution-relevant constraints is a **lossy success** — the most expensive failure class in agent systems, because the caller receives a valid-looking result and the executor proceeds under a contract it never actually agreed to. Concretely: MCP `tools/call` permits `_meta.progressToken`, streaming `notifications/progress`, and a `structuredContent` field governed by an `outputSchema`. Legacy function-calling has none of these. A2A `tasks/send` permits multi-part messages (`TextPart`, `FilePart`, `DataPart`), asynchronous `TaskStatusUpdateEvent` streams, and a `contextId` that binds a task to a conversational memory scope. The legacy interface has one `arguments` blob and one terminal response. Three different *state-and-progress models* are being collapsed into one. The gateway must decide, per call, whether the collapse is *semantically admissible* — and the boundary where it is not is non-obvious. ## What Was Observed A gateway routing an MCP `tools/call` for a long-running tool (`deploy_service`, declared `outputSchema` with a required `rollback_token`, and the client supplying `_meta.progressToken: "p-4471"`) into a legacy function-calling executor. The translation layer: 1. Flattened `params.arguments` into the legacy `arguments` object. 2. **Dropped `_meta.progressToken`** because the legacy schema has no field for it — treated as "metadata, non-essential." 3. **Dropped the `outputSchema` requirement** because the legacy executor has no output-schema concept; the model-facing description was passed as a free-text `description` string. 4. Returned the legacy `tool_result` as an MCP `CallToolResult` with `content: [{type:"text", text: ...}]` and **no `structuredContent`**, because the legacy executor returned a string. The downstream agent then reasoned: "the tool returned text, no `rollback_token` present, so no rollback handle exists" and proceeded to issue a second `deploy_service` call to "retry" — because the first call's *progress notifications never arrived* (the token was dropped, so no `notifications/progress` could be emitted), and the agent's loop interpreted silence-plus-text-result as an ambiguous, possibly-failed call. The second deploy collided with the first. The rollback token existed in the legacy executor's raw output but was never surfaced as `structuredContent`, so the agent could not have recovered even if it had looked. The failure trace, in state terms: - **Pre-call invariant (held):** MCP client believes it has a progress channel and a structured output contract. - **Translation (violated):** Gateway discards `progressToken` and `outputSchema` because target schema lacks fields. No error raised; `CallToolResult` emitted. - **Post-call invariant (broken):** Client's progress-token state machine is now permanently waiting; `structuredContent` absent where `outputSchema` required it; agent's retry logic (keyed on "no progress + text-only result") fires a duplicate side-effecting call. - **Compounding:** The duplicate call is itself translated losslessly-looking, so the second failure is indistinguishable from the first at the gateway layer. The non-obvious part: **each individual translation step was locally correct.** Dropping an unknown field is standard schema-mapping hygiene. The bug is that `progressToken` and `outputSchema` are not "unknown fields" — they are *contract-bearing* fields whose absence changes the downstream agent's control flow. A gateway cannot know a field is contract-bearing from the schema alone; it must be told, or it must refuse. ## Condition of Validity A gateway may translate MCP `tools/call` → legacy function call **only if all three hold**: 1. The tool's declared `outputSchema`, if present, is *satisfiable* by a plain-text legacy result — i.e., the schema admits a `content`-only `CallToolResult` with no `structuredContent`. If the schema marks any property `required`, text-only is inadmissible and the gateway MUST refuse (or synthesize `structuredContent` by parsing, which is itself a new failure surface and must be declared). 2. The client supplied no `_meta.progressToken`, **or** the gateway has a registered progress-emulation path (e.g., periodic heartbeat `notifications/progress` synthesized from legacy polling). If neither, refusal. 3. The call is not `idempotency-sensitive`: legacy executors typically lack MCP's implicit at-most-once semantics under client retry. If the tool is declared side-effecting and the client has retry enabled, the gateway must inject a deduplication key into the legacy `arguments` (and reject on duplicate) rather than pass through. For A2A → legacy, add: a `tasks/send` whose message contains a `FilePart` or `DataPart` cannot be losslessly flattened to a single `arguments` string without an explicit encoding contract; flattening to JSON-string is admissible only if the legacy tool's schema declares a string-typed parameter that the gateway can bind by name. Otherwise refuse. The invariant the gateway must enforce: **no contract-bearing field may be dropped silently; every drop must either be proven inapplicable or converted into a typed refusal returned to the caller as an MCP error / A2A failed task, not a success.** ## Decision Boundary The boundary is *not* "schema mismatch → refuse." That is too coarse and would reject the majority of legitimate translations. The precise boundary is: - **Admissible collapse:** a field whose absence does not alter the caller's control flow — e.g., a `_meta` field used only for logging correlation, a `description` hint, a non-required `outputSchema` property that the legacy result can omit. - **Inadmissible collapse:** a field whose absence causes the caller to enter a different branch — `progressToken` (caller waits on a channel that will never fire), required `outputSchema` properties (caller's parser assumes presence), A2A `contextId` (caller's memory scope silently rebinds to a fresh context, causing episodic amnesia mid-task), A2A `TaskStatusUpdateEvent` stream (caller's async state machine never reaches terminal). - **Refusal-required zone:** inadmissible collapse where the gateway cannot synthesize a substitute. Must raise a typed gateway error enumerating the dropped contract fields, so the caller can decide to (a) re-issue without the field, (b) route to a native MCP path, or (c) abort. The gateway must therefore maintain a **per-tool contract manifest** mapping each MCP/A2A field to one of {pass-through, synthesize, refuse-if-present, drop-safe}. Absent a manifest entry, the default is `refuse-if-present` for any field not in the target schema — *not* drop-safe. This inverts the usual schema-mapping default and is the entire point. ## Operational Effect With the manifest and refusal default in place, the observed failure class disappears: the `deploy_service` call with `progressToken` and required `outputSchema` is refused at the gateway with `ContractLossError`, the agent receives a typed error naming `_meta.progressToken` and `outputSchema.required=[rollback_token]`, and its retry logic — keyed on *typed error*, not on silence — does not fire a duplicate side-effecting call. The cost is a higher refusal rate on the first deployment of any new tool through the gateway; the manifest entry is then authored once, reviewed, and the tool passes thereafter. The invariant that makes this safe: **the gateway's default disposition for unknown fields is refusal, and refusal is a first-class typed result, not an exception swallowed into a generic 500.** Any gateway that maps unknown fields to "drop" has re-introduced the lossy-success class and will produce duplicate side effects under exactly the conditions (long-running, side-effecting, structured-output tools) where duplicates are most expensive. ```python from dataclasses import dataclass, field from typing import Any, Literal Disposition = Literal["pass_through", "synthesize", "refuse_if_present", "drop_safe"] class ContractLossError(RuntimeError): """Raised when a gateway translation would silently drop a contract-bearing field.""" def __init__(self, tool: str, dropped: list[str], reason: str): self.tool = tool self.dropped = dropped self.reason = reason super().__init__( f"refusing lossy translation for tool={tool!r}: " f"contract-bearing fields {dropped} cannot be represented in target schema ({reason})" ) @dataclass class ToolContractManifest: # Per-field disposition; anything absent defaults to refuse_if_present. fields: dict[str, Disposition] = field(default_factory=dict) def disposition(self, name: str) -> Disposition: return self.fields.get(name, "refuse_if_present") def translate_mcp_call_to_legacy( tool: str, params: dict[str, Any], manifest: ToolContractManifest, target_schema_params: set[str], ) -> dict[str, Any]: """Translate an MCP tools/call params dict into a legacy function-call arguments dict. Enforces the invariant: no contract-bearing field is dropped silently. """ legacy_args: dict[str, Any] = {} dropped_contract: list[str] = [] # Contract-bearing top-level fields we know about. if "_meta" in params: meta = params["_meta"] or {} if "progressToken" in meta: disp = manifest.disposition("_meta.progressToken") if disp == "refuse_if_present": dropped_contract.append("_meta.progressToken") elif disp == "synthesize": # Gateway must have a heartbeat path; record intent, do not drop. legacy_args.setdefault("__progress_emulation__", meta["progressToken"]) # pass_through / drop_safe: no action needed for legacy target output_schema = params.get("outputSchema") if output_schema: required = output_schema.get("required", []) disp = manifest.disposition("outputSchema") if required and disp == "refuse_if_present": dropped_contract.append(f"outputSchema.required={required}") elif required and disp == "synthesize": # Caller must have a parser; without one this is still lossy. if not manifest.fields.get("__has_structured_parser__"): dropped_contract.append( f"outputSchema.required={required} (no structured parser registered)" ) for key, value in (params.get("arguments") or {}).items(): if key in target_schema_params: legacy_args[key] = value else: disp = manifest.disposition(key) if disp == "refuse_if_present": dropped_contract.append(f"arguments.{key}") elif disp == "drop_safe": continue elif disp == "synthesize": legacy_args[f"__passthrough__{key}"] = value if dropped_contract: raise ContractLossError( tool=tool, dropped=dropped_contract, reason="target schema lacks fields; default disposition is refuse_if_present", ) return {"name": tool, "arguments": legacy_args} ```