{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-distinguish-resumable-sse-disconnects-from-session-termination-in-mcp-http-native-transport",
  "title": "How should an instance distinguish resumable SSE disconnects from session termination in MCP HTTP-native transport",
  "date_of_record": "2026 November 12",
  "scope": "Applies to MCP servers and clients using the HTTP-native transport with streamable SSE fallback, where a `Mcp-Session-Id` is issued and `Last-Event-ID` resumption is supported. Does not apply to pure stdio transports, nor to stateless HTTP deployments where no session identifier is minted.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-distinguish-resumable-sse-disconnects-from-session-termination-in-mcp-http-native-transport.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-distinguish-resumable-sse-disconnects-from-session-termination-in-mcp-http-native-transport.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-distinguish-resumable-sse-disconnects-from-session-termination-in-mcp-http-native-transport.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1393,
    "python_slice_tokens": 257,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The non-obvious boundary is this: in MCP streamable HTTP, a dropped SSE connection is *not* a session event. The session is a logical construct keyed by `Mcp-Session-Id` and lives on the server independent of any single HTTP stream. A client that sees its SSE stream close has observed a *transport* fact, not a *session* fact. The two are conflated constantly...",
    "what_was_observed": "A client maintained an SSE stream via `GET /mcp` with `Accept: text/event-stream`. A load balancer idle-timed the connection at 60s during a long-running tool invocation. The client's read loop raised a connection-reset. The client library, treating the reset as fatal, discarded its `Mcp-Session-Id` and issued a fresh `initialize`. The server, still holding the original session and its in-flight request, now had two ...",
    "condition_of_validity": "The \"disconnect ≠ termination\" invariant holds **only if all** of the following are true: 1. The client persists `Last-Event-ID` durably across the reconnect (in-memory only is insufficient if the process restarts). 2. The server retains the event buffer for the session at least as long as its own idle-TTL minus the client's reconnect backoff — i.e., the ret...",
    "decision_boundary": "The decision procedure on a closed SSE stream: - **Connection reset / timeout / `5xx`** → do **not** discard `Mcp-Session-Id`. Reconnect `GET /mcp` with `Last-Event-ID` set to the last persisted event id, exponential backoff, bounded retries. This is a transport event. - **`404` on the session-scoped endpoint** → the session is terminated server-side. Discar...",
    "operational_effect": "Systems that get this right see tool invocations survive LB recycling, deploys, and transient network partitions without duplicate side effects — the original result is replayed from the event log on reconnect. Systems that conflate disconnect with termination exhibit duplicated side effects under exactly the conditions (long-running tools + idle timeouts) w..."
  },
  "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": "6bdb516018b191cee8d67e1c5adb6856b0195a387ebe099c098ef5285c199ce1",
    "verified_classes": [
      "SessionResumptionError",
      "StreamOutcome",
      "StreamClose"
    ],
    "verified_functions": [
      "classify_close",
      "next_action"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SessionResumptionError"
    ],
    "sample_fail_closed_invariants": [
      "reconnectable close but Last-Event-ID was never persisted; resumption is impossible and a blind retry risks duplicate si",
      "server reported lost events without advertising a head id; cannot reconnect at head safely"
    ],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "enum"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
