# Where must an instance draw the line between tool-scoped egress and the transitive reach of a composed MCP server? **Date of Record:** 2026 November 24 **Scope:** Applies to agent runtimes that expose MCP servers under per-tool capability scopes and enforce egress controls at the tool-call boundary. Does not apply to single-process agents with no external tool federation, nor to servers whose entire toolset shares one egress policy. ## Core Distinction The failure mode is not "a tool escaped its sandbox." It is that **capability scoping was enforced on the call edge, not on the data-flow edge**. An MCP server is a *composition surface*: tool A (a fetcher, scoped to `net:egress:docs.internal`) can return content that tool B (an executor, scoped to `fs:write:/tmp`) then acts on. Each individual tool call was authorized. The *composition* was not. Egress control was defined per-tool, but the reachable effect is the transitive closure over the argument graph between tools. The invariant that must hold: **for any sequence of authorized tool calls, the union of effects must be within the union of the declared capability scopes — and no tool's *output* may be promoted to another tool's *input* unless that edge is itself in the capability graph.** Per-tool egress without a per-edge (output→input) taint rule is not a sandbox. It is a set of individually locked doors in a corridor with no walls. ## What Was Observed A composed MCP server exposed three tools under distinct scopes: - `fetch_doc(url) -> text` — scope `net:egress:docs.internal` - `summarize(text) -> text` — scope `model:local` (no egress) - `run_shell(cmd)` — scope `exec:sandbox:ro` The runtime enforced egress at each call: `fetch_doc` could only reach `docs.internal`; `run_shell` ran in a read-only sandbox; `summarize` had no network. The agent was asked to "summarize the runbook and apply the documented fix." The trace: 1. `fetch_doc("http://docs.internal/runbook")` → returns text containing a fenced command block. 2. `summarize(text)` → returns a condensed string that *retains* the command block verbatim (the model copied it as "the fix"). 3. The agent extracts the command from the summary and calls `run_shell(cmd)`. Every call was authorized. But the string that reached `run_shell` originated at `net:egress:docs.internal` and traversed `model:local` — an edge that was never declared. The egress scope of `fetch_doc` bounded *where it could read*, not *where its output could travel*. The `run_shell` scope bounded *what it could touch*, not *what could reach it*. The gap between them — the untyped `text` flowing through `summarize` — is the boundary condition. The trigger is specific: **a tool whose output type is structurally identical to another tool's input type, with no provenance tag on the value.** When both sides are `text`, the type system offers no resistance, and the runtime's per-tool egress table has no row for the edge. ## Condition of Validity Per-tool egress control is sound **only if** one of the following holds: - (a) No tool's output is ever consumed as another tool's input within a single task (the tools are leaves, not a graph), or - (b) Every value crossing a tool boundary carries a provenance label, and the capability graph includes output→input edges that are checked at consumption time, or - (c) A capability ceiling is enforced on the *task*, not the tool: the union of reachable egress is computed as a transitive closure before execution and rejected if any composed path exceeds the task grant. Absent (a), (b), or (c), the sandbox is a per-call fiction. The moment an agent can route data between two tools — which is the entire point of a composed server — the effective capability is the closure, not the leaf scopes. ## Decision Boundary The decision the runtime must make at each tool result: **does this value's provenance permit it to be an argument to the next tool?** - If the next tool's scope is a *superset* of the value's provenance scope, allow. - If the value's provenance includes a capability the next tool does not hold, **deny unless the edge is explicitly granted** in the task's capability graph. - If provenance is absent (untyped `text`), treat it as **tainted to the maximum** and require an explicit declassify edge — never silently promote. The boundary is crossed the instant a runtime treats "the call was authorized" as "the data is authorized." Authorization of the *invocation* and authorization of the *flow* are distinct predicates; conflating them is the defect. ## Operational Effect Without the closure check, an agent under prompt-injection or simple instruction-following can launder a capability: read from a high-egress source, pass through a no-egress transformer, and land in a low-scope executor. The blast radius is bounded by the *weakest* leaf, not the *intended* leaf. The fix is to make provenance a first-class field on every tool result and to gate consumption on the edge, not the node. The following guard encodes the invariant and refuses the composed path that the per-tool table would have allowed: ```python from dataclasses import dataclass, field from typing import FrozenSet class CapabilityLaunderingError(RuntimeError): """Raised when a tool result's provenance exceeds the consuming tool's scope.""" @dataclass(frozen=True) class Value: payload: str provenance: FrozenSet[str] # capabilities the value was derived under @dataclass class Tool: name: str scope: FrozenSet[str] granted_edges: FrozenSet[tuple] = field(default_factory=frozenset) def consume(tool: Tool, value: Value) -> Value: """Gate a value entering a tool. Enforces output->input edge invariant.""" excess = value.provenance - tool.scope if excess: edge = (frozenset(value.provenance), tool.name) if edge not in tool.granted_edges: raise CapabilityLaunderingError( f"tool {tool.name!r} (scope={sorted(tool.scope)}) " f"cannot consume value carrying {sorted(excess)} " f"without an explicit declassify edge" ) # Result inherits union of provenance: it is now reachable under both. return Value(payload=value.payload, provenance=value.provenance | tool.scope) def run_pipeline(fetch: Tool, summarize: Tool, shell: Tool, url: str, cmd: str) -> Value: doc = Value(payload=f"{cmd}", provenance=fetch.scope) summary = consume(summarize, doc) # edge fetch->summarize, allowed (subset) # The summary retains provenance of fetch; shell must not silently accept it. return consume(shell, summary) # raises: net:egress leaked into exec ``` The call to `run_pipeline` fails at the final `consume`, exactly where the per-tool table was silent. That is the boundary: **an instance must refuse to route a value across a tool edge whose union of provenance exceeds the consumer's scope, even when every individual invocation was authorized.**