{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-resume-an-mcp-streamable-session-against-the-wrong-tenant-after-a-gateway-reroute",
  "title": "Why does an instance resume an MCP streamable session against the wrong tenant after a gateway reroute?",
  "date_of_record": "2026 November 25",
  "scope": "Applies to MCP servers exposed over HTTP-native transport (Streamable HTTP with `Mcp-Session-Id` and resumable SSE via `Last-Event-ID`) sitting behind a multi-tenant routing gateway that terminates connections and re-dispatches them. Does not apply to stdio transport, nor to single-tenant deployments where the session ID namespace is globally unique and the gateway is a transparent L4 proxy.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-resume-an-mcp-streamable-session-against-the-wrong-tenant-after-a-gateway-reroute.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-resume-an-mcp-streamable-session-against-the-wrong-tenant-after-a-gateway-reroute.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-resume-an-mcp-streamable-session-against-the-wrong-tenant-after-a-gateway-reroute.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1746,
    "python_slice_tokens": 326,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"session lost\" and not \"auth rejected.\" It is **session identity collision across tenants caused by event-ID reuse under gateway-level reconnection**. In Streamable HTTP, resumption is keyed on two independent identifiers: the session handle (`Mcp-Session-Id`, an opaque token minted at `initialize`) and the resumability cursor (`Last-Event...",
    "what_was_observed": "A tenant gateway multiplexes N tenants onto a pool of MCP server instances. Sessions are minted with IDs of the form `<tenant-slug>-<uuidv4>`. The gateway, to keep origin servers tenant-agnostic, **rewrites** the inbound `Mcp-Session-Id` by stripping the tenant slug before forwarding, and re-attaches the slug on the response path. Origin servers therefore see only `<uuidv4>` and maintain a flat session registry. Trig...",
    "condition_of_validity": "This failure requires **all** of the following to co-occur: - The gateway performs **session-ID rewriting** (strip/re-attach of tenant-scoped components) such that the origin server cannot reconstruct the tenant binding from the session handle alone. - The gateway's **affinity table has a TTL or eviction policy** shorter than the client's reconnect window (c...",
    "decision_boundary": "The architectural line is: **who owns the session→tenant binding at resumption time?** - **Gateway-owned binding** (route on session ID, trust the origin to be tenant-blind): fails here. The gateway's affinity state is a cache, and caches evict. - **Origin-owned binding** (origin re-verifies session→tenant against a warrant that survives gateway rewriting): ...",
    "operational_effect": "- **Silent cross-tenant disclosure** of tool results, resource reads, and outbound prompts — with no error surfaced to either tenant. This is worse than a hard failure because neither client nor server observability sees a fault; only a later audit of event-ID provenance detects it. - **Replay of a peer's `sampling/createMessage`** can cause the recovering c..."
  },
  "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": "abef4331c741ced81d42cbe391211646a01e051b085eba07b49ee2a755932656",
    "verified_classes": [
      "CrossTenantResumptionError",
      "SessionRecord",
      "ResumptionGuard"
    ],
    "verified_functions": [
      "handle_resumption",
      "__init__",
      "register",
      "resume"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "CrossTenantResumptionError"
    ],
    "sample_fail_closed_invariants": [
      "empty tenant warrant; cannot authorize resumption"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
