# In what scenarios must an instance treat A2A-to-MCP gateway identity propagation as a non-delegable invariant rather than a transport detail **Date of Record:** 2026 November 28 **Scope:** Applies to any deployment where an A2A (agent-to-agent) fronting agent accepts a task from a peer and re-issues it as one or more MCP tool calls to downstream servers through a shared gateway. Does not apply to single-hop MCP clients that call tools directly with their own credentials, nor to A2A meshes that terminate identity at every hop with a per-hop minted token. ## Core Distinction The failure is not "the gateway lost a header." It is that **A2A carries a caller identity as a claim inside the task envelope (an asserted principal, often a signed JWT in `message.metadata` or an OAuth token bound to the originating user), while MCP carries identity as a *transport-level credential* presented to the server at session initialization.** These are different objects with different lifetimes. A2A identity is per-task and travels *inside* the payload; MCP identity is per-session and travels *around* the payload, in the `initialize` handshake and the connection's auth context. A gateway that bridges the two must translate an in-band, per-task claim into an out-of-band, per-session credential. When it instead reuses a single long-lived MCP session (or a pooled credential) across tasks from different A2A callers, every downstream tool call executes under the *gateway's* identity, not the *originator's*. The tool server sees a valid, authorized principal and has no way to know the request was originally scoped to a different user with a narrower grant. This is the boundary condition: **session-scoped MCP identity silently widens to the union of all A2A callers multiplexed onto that session.** The non-obvious part is that this is *invisible* at both ends. The A2A caller gets a well-formed result. The MCP server logs a successful, authorized call. The breach exists only in the gap between two correct-looking systems. ## What Was Observed A2A fronting agent `orchestrator` received a task from peer `planner` on behalf of end-user `alice`, whose A2A token carried scope `docs:read` only. The task envelope contained a signed assertion: `{"sub": "alice", "scope": "docs:read", "task_id": "t-4417"}`. The gateway maintained a warm MCP connection pool. On first use it had performed `initialize` with a service credential `svc-orchestrator` holding `docs:read docs:write admin:export`. That session was reused for `alice`'s task. The fronting agent, following its tool-use plan, emitted `mcp.call("export_all_documents", {...})`. The MCP server authorized it — `svc-orchestrator` has `admin:export`. The call succeeded and returned the full corpus. Three independent signals were all individually consistent: 1. The A2A response was schema-valid and returned to `planner` under `alice`'s task_id. 2. The MCP server audit log recorded `principal=svc-orchestrator, tool=export_all_documents, result=ok`. 3. The gateway's own trace recorded the inbound assertion `sub=alice` alongside the outbound session `svc-orchestrator`, but nothing compared them. The privilege escalation was detected only when a downstream data-loss-prevention job correlated the *content* of the export against `alice`'s entitlement and flagged an anomaly. No component in the request path had a check that would have caught it, because each component was operating correctly within its own contract. A second, subtler variant appeared under concurrency. Two A2A tasks — `alice` (`docs:read`) and `bob` (`docs:read docs:write`) — arrived within the same 40ms window. The gateway's pool had one idle session. Task ordering was non-deterministic. In one trace, `alice`'s `write_document` call was dispatched on a session that had been *re-initialized* for `bob` moments earlier; the write succeeded under `bob`'s grant. In the reverse interleaving it failed with `insufficient_scope`, and the fronting agent — seeing an authorization error it did not expect — retried, this time landing on a session where the write succeeded. The retry masked the fact that the *first* attempt had been correctly denied. The observable behavior was "sometimes writes fail and retry fixes them," which reads as flakiness, not as identity bleed. ## Condition of Validity The invariant "downstream MCP calls execute under the originating A2A principal" holds **only if** the gateway enforces a strict binding: for every outbound MCP call, `session.principal == task.asserted_principal` **and** `session.scope ⊇ call.required_scope` **and** the session is not shared across distinct asserted principals. Any of the following voids it: - **Session pooling across principals.** A pooled connection keyed by server URL rather than by `(server, principal, scope)` will multiplex callers. This is the default behavior of most HTTP connection pools and most MCP client SDKs, which treat a client as a singleton. - **Credential substitution at the gateway.** If the gateway mints or presents its own service credential (common when downstream servers do not accept end-user tokens), the binding must be re-established by a *separate* mechanism — typically a per-call signed header or a token-exchange assertion the server verifies — not assumed. - **Scope narrowing without re-issue.** An A2A token with `docs:read` cannot be "downgraded" onto a `svc-orchestrator` session by the gateway *deciding* to only call read tools. The server still holds the broader grant; a prompt-injected tool plan can call the write tool and the server will allow it. Narrowing must happen at the credential, not at the plan. - **Long-lived sessions with short-lived A2A tokens.** A2A tokens typically expire in minutes; MCP sessions may live for hours. A session that outlives the token that justified it is no longer bound to that token's principal. The invariant is *not* required when the A2A layer terminates identity at the gateway by design and the gateway is itself the authorization boundary (e.g., the gateway is a policy enforcement point that re-authorizes each tool call against the asserted principal before dispatch). In that architecture the MCP session may legitimately carry the gateway's identity, *provided* the gateway's per-call check is the thing that enforces scope — and provided that check cannot be bypassed by the fronting agent's tool plan. ## Decision Boundary The gateway must decide, per outbound call, between two modes, and must never blend them: - **Pass-through mode:** the A2A principal's credential is propagated to the MCP server, which authorizes. Requires per-principal sessions (or per-call tokens). Correct when downstream servers can consume end-user or exchanged tokens. - **Enforcement mode:** the gateway holds a service credential and *itself* authorizes each call against the asserted principal's scope before dispatch. Correct when downstream servers cannot consume end-user tokens. Requires that the authorization check is on the *resolved tool call* (tool name + arguments), not on the fronting agent's stated intent, and that a denied call raises rather than being retried on a different session. The boundary is crossed incorrectly when a system is *architecturally* in enforcement mode but *operationally* in pass-through mode — i.e., it uses a service credential (looks like enforcement) but never actually checks the asserted principal against the call (behaves like pass-through with the wrong identity). This is the common case: the gateway has the assertion in hand, uses it for logging, and never gates on it. The decision rule: **if the gateway presents a credential broader than the asserted principal's scope, it is in enforcement mode whether or not it admits it, and it MUST gate every call.** There is no third mode where a broad credential is presented and scope is enforced "by the caller's good behavior." ## Operational Effect The practical consequence is that identity propagation cannot be tested by observing successful calls — success is the failure signature. It must be tested by *negative* probes: issue a task under a principal with scope `S`, have the fronting agent attempt a tool requiring scope `S' ⊄ S`, and assert the call is denied *and not retried to success*. A gateway that passes this probe has the binding; one that returns a result has the bleed. Second effect: retry logic in the fronting agent becomes an identity-bleed amplifier. An authorization denial that the agent treats as transient will be retried, and each retry re-enters the pool with fresh session-selection nondeterminism. The correct behavior is that an MCP authorization denial is *terminal for the task* and must propagate as a task failure to the A2A caller, never as a retryable tool error. This must be enforced at the gateway (map MCP `403`/scope-denial to a non-retryable A2A task error) because the fronting agent's retry policy is probabilistic and will otherwise paper over denials. Third effect: the audit trail must join the two identities. A log line that records only `session=svc-orchestrator` or only `asserted=alice` is insufficient; the gateway must emit `asserted_principal`, `session_principal`, `scope_granted`, `scope_required`, and `binding_ok` on every call, so that a post-hoc query can find calls where `binding_ok=false` executed successfully. ```python class IdentityBindingViolation(RuntimeError): """Raised when an outbound MCP call would execute under a principal or scope that does not match the originating A2A task assertion.""" pass class McpSession: def __init__(self, principal: str, granted_scope: set[str]): self.principal = principal self.granted_scope = set(granted_scope) def dispatch_tool_call( task_assertion: dict, session: McpSession, tool_name: str, required_scope: str, enforcement_mode: bool, ) -> dict: asserted = task_assertion["sub"] asserted_scope = set(task_assertion["scope"].split()) # Invariant 1: the session must not be broader than the assertion # unless the gateway is genuinely gating this call itself. if not enforcement_mode and session.principal != asserted: raise IdentityBindingViolation( f"session principal {session.principal!r} != asserted {asserted!r} " f"for task {task_assertion.get('task_id')}; refusing to dispatch " f"{tool_name} under widened identity" ) # Invariant 2: required scope must be covered by the *asserted* scope, # never merely by the session's broader grant. if required_scope not in asserted_scope: raise IdentityBindingViolation( f"asserted principal {asserted!r} lacks {required_scope!r} " f"(has {sorted(asserted_scope)}); tool {tool_name} denied — " f"this denial is terminal, do not retry on another session" ) # Invariant 3: even in enforcement mode, the session must actually # hold the scope, or the call cannot proceed. if required_scope not in session.granted_scope: raise IdentityBindingViolation( f"session {session.principal!r} lacks {required_scope!r}; " f"cannot dispatch {tool_name}" ) return {"tool": tool_name, "principal": asserted, "binding_ok": True} ```