# How does an instance detect authorization envelope bleed when an HTTP-native MCP server multiplexes concurrent tool calls under per-tool rate limits? **Date of Record:** 2026 November 20 **Scope:** Applies to HTTP-native Model Context Protocol servers that multiplex multiple in-flight `tools/call` requests over a shared connection pool while enforcing per-tool authorization scopes and per-tool rate-limit envelopes. Does not apply to stdio-transport MCP servers, single-tool servers, or stateless request/response gateways that serialize calls per client. ## Core Distinction The failure is not "rate limit exceeded" and it is not "authorization denied." It is the *cross-contamination of envelope state between concurrent tool invocations that share a transport but must not share a policy context*. In an HTTP-native MCP server, the transport layer (connection, HTTP/2 stream, session cookie, bearer token) is a single identity, but the *authorization envelope* and the *rate-limit bucket* are per-tool resources. When the multiplexer reuses a connection or a session-scoped middleware object, per-tool state leaks: a call to tool B can consume tool A's rate budget, inherit tool A's narrowed scope, or observe tool A's cached capability negotiation result. The distinction that matters operationally: a **transport identity** is not an **authorization envelope**. HTTP gives you one; MCP semantics require many. Any multiplexing layer that treats the bearer token as the envelope key is structurally broken for multi-tool servers, and the breakage is silent—every individual request returns 200 with a well-formed JSON-RPC result. There is no error to catch unless the server explicitly tags envelope identity into the response and the client verifies it. ## What Was Observed A server exposing three tools—`read_file` (rate limit 60/min, scope `fs:read`), `write_file` (rate limit 10/min, scope `fs:write`), and `query_index` (rate limit 30/min, scope `index:read`)—fronted by an HTTP/2 multiplexer that pooled connections per bearer token. An agent dispatched a fan-out of 12 parallel `query_index` calls plus 8 `read_file` calls over the same token. Observed trace: 1. All 20 requests entered the multiplexer within a 40ms window and were assigned to 4 pooled HTTP/2 streams. 2. The rate-limit middleware keyed its token bucket on `(bearer_token, tool_name)`, but the *bucket lookup* occurred after stream assignment and read a `tool_name` field from a shared `RequestContext` object that was mutated per-request on the pool worker. 3. Under concurrency, two `query_index` requests and one `read_file` request were assigned to the same worker; the `RequestContext.tool_name` was observed as `read_file` for one `query_index` request (last-writer-wins on the shared context). 4. Result: that `query_index` call was charged against the `read_file` bucket (60/min) instead of its own (30/min), and its scope check evaluated `fs:read` instead of `index:read`. 5. The call *succeeded*—the token had both scopes, so authorization passed—but the rate budget was wrong, and a subsequent legitimate `read_file` burst hit a `429` that should have been attributed to `query_index`. 6. No client-side error. The agent's retry logic interpreted the `429` on `read_file` as backpressure on filesystem reads and backed off the wrong tool, starving the actual `read_file` work. The failure only manifested when the token held *multiple* scopes. With a single-scope token, the scope-check contamination would have produced a `403`—a loud, catchable failure. Multi-scope tokens convert an authorization bug into a silent rate-limit misattribution. ## Condition of Validity The invariant that must hold: **for every `tools/call`, the authorization envelope and the rate-limit bucket are resolved from the request's own immutable payload, not from any object shared across the transport.** This is valid only if: - The envelope key is `(token_id, tool_name, request_id)` and is computed before stream assignment, carried as an immutable value through the handler chain, and never read from a mutable per-worker context. - The rate-limit middleware keys on the same tuple and performs an atomic increment-and-check (compare-and-swap or a single Lua script on the backing store) so that concurrent calls to the same tool cannot both pass a `59→60` boundary. - The capability negotiation result (the `tools/list` schema, including which tool names are authorized for this token) is cached per `(token_id, schema_version)`, not per connection, and is invalidated on any `notifications/tools/list_changed`. The condition fails—and the invariant is violated—whenever the server uses a request-scoped mutable context object on a pooled worker, or keys any per-tool state on the connection rather than the request. HTTP/2 stream multiplexing makes this failure *more* likely than HTTP/1.1 keep-alive, because many logical requests share one worker thread and one context object within a single event-loop tick. ## Decision Boundary An instance should treat a multiplexed MCP server as **envelope-safe** only if it can observe one of the following, and should otherwise assume bleed: - The server returns a per-response header or JSON-RPC result field echoing the resolved `tool_name` and `envelope_id` it charged, and that value matches the request. - The server exposes a `tools/list` result whose `rateLimit` and `scopes` fields are per-tool and the client can independently verify a `429`'s `Retry-After` and `X-RateLimit-Tool` header against the tool it actually called. - Under a controlled fan-out probe (N parallel calls to tool A, M to tool B, token holding both scopes), the observed `429` distribution matches the per-tool budgets. If none of these hold, the boundary decision is: **serialize per-tool calls or partition by connection**, accepting the latency cost, because the alternative is unbounded silent misattribution. The decision flips to "safe to multiplex" only when the server demonstrates per-request envelope resolution under a concurrency probe—not when it merely documents per-tool limits. ## Operational Effect The downstream effect is *budget inversion*: the agent's backpressure model learns the wrong mapping between tool and capacity. An agent that fans out across tools and adapts its concurrency from `429` feedback will progressively throttle the wrong tool, because the `429`s are attributed to whichever tool won the shared-context race. Over a long session this produces a stable but incorrect throughput profile—`query_index` appears cheap (it is borrowing `read_file`'s budget) while `read_file` appears saturated. The agent's planner then routes work toward the "cheap" tool and away from the "expensive" one, which is exactly inverted from the server's intent. Recovery requires the agent to reset its per-tool concurrency model, not just retry, because the learned state is corrupted rather than merely stale. The guardrail is a **per-call envelope assertion**: the client must verify, on every response, that the server-charged tool identity matches the requested tool identity, and must raise on mismatch rather than retry, because a mismatch indicates the server's multiplexer is envelope-unsafe and retries will reproduce the corruption. ```python import hashlib from dataclasses import dataclass class EnvelopeBleedError(RuntimeError): """Raised when a multiplexed MCP response reports a tool/envelope identity that does not match the request that produced it. This indicates the server resolved authorization or rate-limit state from a shared transport context rather than the request payload; retrying will reproduce the corruption.""" @dataclass(frozen=True) class CallEnvelope: request_id: str tool_name: str token_id: str def envelope_id(self) -> str: raw = f"{self.token_id}:{self.tool_name}:{self.request_id}".encode() return hashlib.sha256(raw).hexdigest()[:16] def verify_response_envelope( request: CallEnvelope, response_tool_name: str, response_envelope_id: str, response_status: int, ) -> None: # The server must echo the tool it actually charged. If it echoes a # different tool, the multiplexer leaked a shared RequestContext value. if response_tool_name != request.tool_name: raise EnvelopeBleedError( f"envelope bleed: request for tool={request.tool_name!r} " f"(req={request.request_id}) was charged to tool=" f"{response_tool_name!r}; server resolved envelope from shared " f"transport context, not request payload" ) if response_envelope_id != request.envelope_id(): raise EnvelopeBleedError( f"envelope id mismatch: expected {request.envelope_id()!r} " f"for {request.tool_name!r}, got {response_envelope_id!r}; " f"per-tool rate bucket may be keyed on connection, not request" ) # A 429 is only trustworthy if it is attributed to the tool we called. if response_status == 429 and response_tool_name != request.tool_name: raise EnvelopeBleedError( f"429 misattribution for {request.tool_name!r}: backpressure " f"signal belongs to {response_tool_name!r}; do not adapt " f"concurrency model from this response" ) ```