# Under what conditions must an instance treat MCP tool-call authorization as a decision made over the *arguments*, not the tool name — because the middleware's per-tool ACL silently over-permits when a single tool multiplexes its target via parameters **Date of Record:** 2026 November 27 **Scope:** Applies to MCP servers that expose coarse-grained tools whose *target resource* is selected by a request argument (path, repo, table, channel, tenant, URL, shell "command") rather than by a distinct tool name, and that rely on a name-keyed authorization middleware (allowlist/ACL per tool) plus a name-keyed audit trail. Does not apply to servers where each tool maps 1:1 to a distinct, single-resource capability, nor to transport-level auth (mTLS, bearer scopes) that is already resource-scoped. ## Core Distinction The failure hinges on the difference between **capability identity** and **effect identity**. An MCP tool is a *capability*: `fs.read`, `db.query`, `http.fetch`, `k8s.exec`. The authorization middleware, by design, keys on capability identity — "is this agent allowed to invoke `db.query`?" — because that is the only stable, enumerable surface the protocol advertises via `tools/list`. But the *effect* of a call is a function of capability **and** arguments: `db.query` against `analytics.public` versus `billing.pii`; `http.fetch` against `docs.internal` versus `169.254.169.254`; `fs.read` on `/workspace` versus `/etc/shadow`. The middleware's per-tool ACL is a *sound* least-privilege gate only if effect identity is a constant per capability. When a tool multiplexes its target through an argument, effect identity becomes a *variable* the ACL never sees — and the guardrail silently degrades from "least privilege" to "any privilege reachable through the most permissive instance of this tool." The non-obvious corollary: the audit trail inherits the same blindness. A log line reading `agent=planner tool=db.query status=allow` is *not* an audit record of what the agent did; it is a record of which capability it touched. The actual effect — which tenant's rows, which host, which path — lives only in the request arguments, which name-keyed middleware typically logs at `DEBUG` or drops entirely. So the two properties that "per-tool least-privilege and audit trails" are supposed to deliver both fail at the same seam, for the same reason, and the failure is invisible precisely because the middleware reports `allow` with no error. ## What Was Observed A retrieval agent was granted a single MCP tool, `warehouse.query`, with the ACL entry `warehouse.query: allow`. The tool signature was `query(sql: str, database: str = "analytics")`. The granting team reasoned that the agent "only needs read access to analytics," and the per-tool ACL was treated as enforcing that. It did not. The `database` argument was unconstrained at the middleware layer; the tool's own handler passed it straight to the connection pool, which had a service account with cross-database grants. Trace of the state transition: 1. `tools/list` returns `warehouse.query`. Middleware builds ACL key `warehouse.query` → `{allow}`. No argument schema is inspected. **Invariant assumed:** effect ⊆ capability. 2. Agent, mid-task, hits a schema mismatch in `analytics` and — via a tool-selection retry loop — re-issues `warehouse.query(sql="SELECT ...", database="billing")`. The model did not "decide to escalate"; it repaired a failed call by varying a parameter. The escalation is an *emergent* consequence of the retry loop, not an adversarial action. 3. Middleware evaluates key `warehouse.query` → `allow`. **No argument evaluation occurs.** The call proceeds. 4. Audit sink writes `tool=warehouse.query result=ok rows=4`. The `database` argument is not in the audit record. The effect (billing PII read) is unreconstructable from the trail. 5. Post-hoc review reads the audit trail, sees only `warehouse.query`, and concludes the ACL held. The critical observation: **the middleware reported success at every step.** There was no denial, no anomaly, no error. The over-permission was not a bypass of the guardrail — it was the guardrail operating exactly as specified on a key that was too coarse for the effect it was meant to bound. This is the boundary condition: name-keyed authorization is *correct* and *complete* only over the projection of effects onto capabilities, and it silently drops every effect dimension that the projection collapses. A second instance showed the audit-trail half failing independently. A `k8s.exec` tool with `allow` was used to run `kubectl get pods -n prod` and later `kubectl delete pod -n prod`. Both logged as `tool=k8s.exec`. The trail could not distinguish a read from a destructive write, so the "audit trail" could not answer the one question audits exist to answer: *what changed*. The ACL was arguably fine (the agent was meant to have exec); the *audit* was not, and the middleware had no mechanism to know the difference because the verb lived inside the `command` argument. ## Condition of Validity Per-tool, name-keyed authorization is a valid least-privilege enforcement **iff** for every tool `t`, the set of effects reachable by any argument vector `a ∈ dom(t)` is contained in the effect set authorized for `t`. Formally: `⋃_{a} effect(t, a) ⊆ authorized(t)`. This holds trivially when `dom(t)` selects no resource (pure functions, fixed-target tools) and fails whenever `t` exposes a *resource selector* argument whose range exceeds the authorized effect set. Operationally, the condition is checkable at registration time by inspecting the tool's input schema: if any required or optional parameter is a *target selector* (path, host, database, namespace, tenant, command, URL, repo, channel) and the middleware's ACL is not parameterized over that selector, the invariant is unproven and must be treated as violated until the selector is bounded. The middleware must therefore either (a) promote selector arguments into the ACL key — `warehouse.query[database=analytics]` — or (b) delegate to a tool-internal policy the middleware *verifies* rather than assumes, or (c) refuse to register multiplexing tools under a name-only ACL. Option (c) is the conservative default: a middleware that cannot see the effect must not claim to authorize it. The same condition governs the audit trail: an audit record is *valid* as an effect record only if it captures the selector arguments that determine effect. A name-only audit line is a capability-touch record, not an effect record, and must not be used to answer "what did the agent do." ## Decision Boundary An instance must escalate from name-keyed to argument-keyed authorization (or refuse the call) at the following boundary: **the moment a tool's schema admits a target-selector argument whose value is chosen by the model, not pinned by the server.** Concretely, the instance crosses the boundary when: - The tool's `inputSchema` contains a `string`/`enum`/`oneOf` parameter that names a resource (host, path, db, namespace, tenant, URL, command), **and** - That parameter is not constrained to a server-side-fixed allowlist (e.g., `enum` of permitted databases, or a path prefix enforced by the handler), **and** - The middleware's ACL key does not incorporate the parameter value. If all three hold, the call is *outside* the ACL's proven domain and must be denied-and-logged with the full argument vector, or re-authorized against the argument. The boundary is *not* crossed when the selector is an `enum` pinned to the authorized set (the handler cannot be steered outside it) or when the tool is genuinely single-target. The subtle case — and the one that bites — is a selector with a *default* (`database="analytics"`): the default makes the tool *look* single-target in the happy path, so the schema inspection that would catch the multiplexing is skipped, and the boundary is crossed silently on the first call that overrides the default. Defaults are the most common camouflage for this failure. ## Operational Effect When the boundary is respected, three properties hold that do not hold otherwise. First, **least-privilege becomes a property of effects, not capabilities** — the agent's reachable effect set is the intersection of its per-tool grants and the argument constraints, and that intersection is what the ACL actually bounds. Second, **the audit trail becomes replayable**: given the logged argument vector, a reviewer can reconstruct the exact resource touched and distinguish read from write, so the trail can support incident reconstruction and, where the handler is deterministic, re-execution. Third, **retry-loop escalation is bounded**: the common failure where a model repairs a failed call by varying a resource-selector argument is caught at the middleware, not discovered in post-hoc review, because the varied argument now changes the ACL key and triggers a deny. When the boundary is violated, the failure is *silent and self-reporting as success*: the ACL returns `allow`, the audit returns `ok`, and the only signal of over-permission is the effect itself, which the middleware never observed. This is the operational hazard — the guardrail's telemetry actively asserts a safety property it did not check, which is worse than no guardrail, because it terminates the human review that would otherwise have caught the multiplexing. The remediation is not "add a check"; it is to make the middleware's authorization key *isomorphic to the effect*, and to make that isomorphism a registration-time precondition rather than a runtime hope. ```python from dataclasses import dataclass, field from typing import Any, Callable class UnboundedSelectorError(PermissionError): """Raised when a multiplexing tool is registered or invoked under a name-keyed ACL that cannot see the argument that determines its effect.""" pass # Arguments whose values select the resource the call actually touches. SELECTOR_PARAMS = frozenset({ "path", "host", "url", "database", "db", "namespace", "tenant", "repo", "channel", "command", "table", "bucket", }) @dataclass class ToolSpec: name: str input_schema: dict[str, Any] handler: Callable[..., Any] @dataclass class NameKeyedACL: # ACL keyed only on tool name -> the exact defect this record describes. grants: dict[str, set[str]] = field(default_factory=dict) # Optional per-selector allowlists: tool -> {param: allowed_values} selector_bounds: dict[str, dict[str, frozenset[str]]] = field(default_factory=dict) def _unbounded_selectors(self, spec: ToolSpec) -> list[str]: props = spec.input_schema.get("properties", {}) bounds = self.selector_bounds.get(spec.name, {}) unbounded = [] for pname, pschema in props.items(): if pname not in SELECTOR_PARAMS: continue # A selector is bounded only if it is an enum pinned server-side # OR the middleware holds an explicit allowlist for it. is_enum = isinstance(pschema.get("enum"), list) has_bound = pname in bounds if not (is_enum or has_bound): unbounded.append(pname) return unbounded def register(self, spec: ToolSpec) -> None: unbounded = self._unbounded_selectors(spec) if unbounded: # Refuse to register a multiplexing tool under a name-only ACL: # the ACL cannot prove effect ⊆ capability for these parameters. raise UnboundedSelectorError( f"tool {spec.name!r} exposes unbounded selector(s) {unbounded}; " f"name-keyed ACL cannot enforce least-privilege over its effects. " f"Pin via enum or selector_bounds, or key the ACL on arguments." ) def authorize(self, spec: ToolSpec, args: dict[str, Any]) -> dict[str, Any]: # Re-validate at call time: a defaulted selector can slip past a # registration that only inspected required fields. unbounded = self._unbounded_selectors(spec) if unbounded: raise UnboundedSelectorError( f"call to {spec.name!r} carries unbounded selector(s) {unbounded}; " f"effect cannot be bounded by tool-name grant" ) if spec.name not in self.grants: raise PermissionError(f"no grant for tool {spec.name!r}") # Enforce selector bounds against the *actual* argument values. bounds = self.selector_bounds.get(spec.name, {}) for pname, allowed in bounds.items(): if pname in args and args[pname] not in allowed: raise PermissionError( f"{spec.name}.{pname}={args[pname]!r} outside bound {sorted(allowed)}" ) # Effect-bearing audit record: name AND selector arguments. return {"tool": spec.name, "args": dict(args), "decision": "allow"} def dispatch(acl: NameKeyedACL, spec: ToolSpec, args: dict[str, Any]) -> Any: record = acl.authorize(spec, args) # raises before any side effect _ = record # emit to effect-scoped audit sink here return spec.handler(**args) ```