{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-resumes-an-mcp-sse-stream-across-a-mid-flight-transport-upgrade-to-websocket",
  "title": "What happens when an instance resumes an MCP SSE stream across a mid-flight transport upgrade to WebSocket",
  "date_of_record": "2026 December 1",
  "scope": "Applies to MCP clients and servers that negotiate an HTTP-native transport (SSE for server→client, POST for client→server) and support resumption via `Last-Event-ID`, where the server may independently advertise a WebSocket upgrade mid-stream. Does not apply to pure stdio transports, nor to deployments where the upgrade is negotiated only at connection establishment (pre-stream).",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-resumes-an-mcp-sse-stream-across-a-mid-flight-transport-upgrade-to-websocket.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-resumes-an-mcp-sse-stream-across-a-mid-flight-transport-upgrade-to-websocket.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-resumes-an-mcp-sse-stream-across-a-mid-flight-transport-upgrade-to-websocket.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1966,
    "python_slice_tokens": 446,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The MCP spec's resumability model assumes a *single logical event log* per stream, keyed by monotonically increasing event IDs, replayable from any `Last-Event-ID`. The SSE-to-WebSocket upgrade breaks this assumption in a way that is easy to miss: **the two transports do not share an event namespace unless the server explicitly bridges them.** SSE event IDs ...",
    "what_was_observed": "A client holds an SSE stream from an MCP server, last received `id: 4417`. The connection drops (proxy idle timeout, 30s). The client reconnects per spec: `GET /mcp/stream` with `Last-Event-ID: 4417`. The server's upgrade logic has, in the intervening window, transitioned the session to WebSocket-backed delivery and now responds with `101 Switching Protocols` after the initial HTTP handshake, then emits frames. Three...",
    "condition_of_validity": "Resumption across an SSE→WebSocket upgrade is only valid when the server satisfies all of: - A **single logical event log** with monotonic IDs is the source of truth, independent of transport. SSE writers and WebSocket emitters both draw from it and both stamp the ID (WebSocket frames carry an `id` field in the envelope, not just payload). - The upgrade is *...",
    "decision_boundary": "The client cannot distinguish \"resumed correctly\" from \"silently lossy\" by inspecting frames. It must make a policy decision at the upgrade boundary: - **If the server advertises upgrade capability and the client's last cursor is `C`:** the client MUST verify, on the first WebSocket frame, that the frame's ID is `C+1` (or that the server has sent an explicit...",
    "operational_effect": "The practical consequence is that **MCP resumption must be modeled as a cursor-continuity protocol, not a reconnect protocol.** Agents that treat `Last-Event-ID` as \"where to resume reading\" and the upgrade as \"same stream, faster pipe\" will silently lose events at every upgrade boundary and will exhibit exactly the symptoms that look like model hallucinatio..."
  },
  "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": "361b9c4bbc1a91dd55a820878704c3306c2f66469d4b0bdb142113bbcb727513",
    "verified_classes": [
      "StreamContinuityError",
      "Frame"
    ],
    "verified_functions": [
      "verify_upgrade_continuity",
      "resume_stream"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 6,
    "raised_exceptions": [
      "StreamContinuityError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
