{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-of-a-streamable-http-mcp-server-silently-corrupt-per-session-tool-state-when-a-single-sse-stream-applies-backpressure",
  "title": "Why does an instance of a Streamable HTTP MCP server silently corrupt per-session tool state when a single SSE stream applies backpressure?",
  "date_of_record": "2026 November 25",
  "scope": "Applies to MCP servers implementing the Streamable HTTP transport (single `/mcp` endpoint, `Mcp-Session-Id` header, GET for server→client SSE stream, POST for client→server messages) that multiplex multiple concurrent sessions over one process and share any mutable tool-execution state (connection pools, cwd, env vars, scratch files, cached tool registry). Does not apply to stdio transports, to stateless servers with no shared tool state, or to servers where each session is pinned to a dedicated process.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-of-a-streamable-http-mcp-server-silently-corrupt-per-session-tool-state-when-a-single-sse-stream-applies-backpressure.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-of-a-streamable-http-mcp-server-silently-corrupt-per-session-tool-state-when-a-single-sse-stream-applies-backpressure.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-of-a-streamable-http-mcp-server-silently-corrupt-per-session-tool-state-when-a-single-sse-stream-applies-backpressure.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2092,
    "python_slice_tokens": 338,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the server drops messages under load\" — that is a visible, recoverable backpressure symptom. The failure is that **backpressure on one session's SSE stream stalls the writer that is also responsible for draining the shared tool-execution queue, and the tool-state isolation boundary is enforced only at *dispatch* time, not at *completion* ...",
    "what_was_observed": "A reproduction with three concurrent sessions against one server process, each with its own `Mcp-Session-Id`, each issuing a `tools/call` for a tool that writes to a per-session scratch directory (`scratch/<session_id>/`): 1. Session A opens its GET SSE stream and then stops reading (client-side `recv` buffer fills after ~64 KiB of server-sent progress notifications). The server's `StreamWriter.write()` for A returns...",
    "condition_of_validity": "The corruption requires the conjunction of: - **Shared writer.** One task/thread owns the SSE write path for all sessions (the common shape when a server exposes a single `GET /mcp` handler that fans out via a broadcast queue). Per-session dedicated writers eliminate the stall-propagation but not the binding bug if routing is still temporal. - **Temporal ses...",
    "decision_boundary": "The correct design choice is **structural addressing over ambient addressing**, and it is not optional once the writer is shared. Concretely: - The `tools/call` handler must capture `session_id` from the request's `Mcp-Session-Id` header at admission and pass it as an explicit, immutable argument through the entire dispatch → execute → route chain. The resul...",
    "operational_effect": "In production this manifests as intermittent, load-correlated data corruption that is misattributed to the tool implementation or to the client. Symptoms observed in the field: a coding agent's `write_file` tool writing into another agent's workspace, a database tool executing a query against the wrong tenant's connection pool, a browser tool navigating a pa..."
  },
  "matched_failure_symptoms": [
    "HTTP_429_BURST_STARVATION"
  ],
  "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": "3d064605be199294dc6bd578db28c6ab09166d3c2fabc11e2d439e9722a4ac5c",
    "verified_classes": [
      "SessionStateCorruption",
      "ToolCall"
    ],
    "verified_functions": [
      "dispatch_and_route",
      "run_under_stalled_consumer",
      "execute",
      "route"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "SessionStateCorruption"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "asyncio",
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
