{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-audience-mismatched-mcp-tokens-before-tool-dispatch-under-http-native-transport",
  "title": "How does an instance detect audience-mismatched MCP tokens before tool dispatch under HTTP-native transport",
  "date_of_record": "2026 November 27",
  "scope": "Applies to LLM agent instances acting as MCP clients over Streamable HTTP / HTTP+SSE transport where the authorization server issues audience-bound bearer tokens per RFC 8707 resource indicators. Does not apply to stdio-local MCP servers (no token audience surface) or to single-tenant deployments where the token audience is implicitly the only registered resource.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-audience-mismatched-mcp-tokens-before-tool-dispatch-under-http-native-transport.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-audience-mismatched-mcp-tokens-before-tool-dispatch-under-http-native-transport.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-audience-mismatched-mcp-tokens-before-tool-dispatch-under-http-native-transport.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1745,
    "python_slice_tokens": 417,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between *scope sufficiency* and *audience validity*. Most MCP client implementations validate the former and assume the latter. A token can carry every scope the tool requires (`tools:invoke`, `resources:read`, `prompts:list`) and still be invalid for the server it is being presented to, because the `aud` claim names a differe...",
    "what_was_observed": "A three-server agent topology: an orchestrator instance (`agent-orch`) holding a token minted for `https://mcp.internal/orchestrator`, a retrieval server at `https://mcp.internal/retrieval`, and a code-execution server at `https://mcp.internal/sandbox`. The orchestrator was configured with a single OAuth client and a single token cache keyed by issuer, not by resource. The orchestrator's plan required it to call `ret...",
    "condition_of_validity": "The guardrail only holds when all three of the following are true: 1. **The token cache is keyed by `(issuer, resource)`**, not `issuer` alone. A cache keyed by issuer is the single most common cause of audience mismatch surviving a \"fix,\" because the fix (adding `resource` to the authorization request) is defeated by the cache hit. 2. **The client parses th...",
    "decision_boundary": "The decision the agent must make on receiving a `401` from an MCP server is *not* \"refresh and retry.\" It is a two-branch decision: - If the challenge's `error` is `insufficient_scope` → refresh with expanded `scope`, retry once. - If the challenge's `error` is `invalid_token` → **do not retry with the cached token.** Parse `resource_metadata`, fetch the pro...",
    "operational_effect": "With the guardrail in place, the orchestrator's first `401` from retrieval triggers a metadata fetch (one round-trip), a re-authorization with `resource=https://mcp.internal/retrieval` (one round-trip), a cache write under the correct key, and a successful retry. Total cost: three round-trips for the first cross-server call, zero for subsequent calls. Withou..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "8ef17f3548e3f81f5496f91fb104e8e2137fb1b6c839cb98386f6c41eef83eab",
    "verified_classes": [
      "AudienceMismatchError",
      "NonRefreshableAuthError",
      "Token",
      "Challenge"
    ],
    "verified_functions": [
      "resolve_token_for_resource",
      "dispatch_tool_call"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "AudienceMismatchError",
      "NonRefreshableAuthError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
