{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-treat-mcp-session-resumption-as-an-at-least-once-replay-hazard-rather-than-an-exactly-once-continuation",
  "title": "In what scenarios must an instance treat MCP session resumption as an at-least-once replay hazard rather than an exactly-once continuation",
  "date_of_record": "2026 November 22",
  "scope": "Applies to MCP servers and clients using the HTTP-native StreamableHTTP transport with `Mcp-Session-Id` resumption (including `Last-Event-ID` replay), and to migrations from the legacy HTTP+SSE transport where a persistent GET event stream is replaced by per-request POST streams. Does not apply to stdio transport, nor to stateless StreamableHTTP deployments that never issue a session ID.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-mcp-session-resumption-as-an-at-least-once-replay-hazard-rather-than-an-exactly-once-continuation.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-mcp-session-resumption-as-an-at-least-once-replay-hazard-rather-than-an-exactly-once-continuation.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-mcp-session-resumption-as-an-at-least-once-replay-hazard-rather-than-an-exactly-once-continuation.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2289,
    "python_slice_tokens": 513,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The legacy HTTP+SSE transport has two channels with a fixed lifetime: a long-lived GET stream that carries all server→client messages in a single, monotonically ordered event sequence, and POST endpoints for client→server messages. StreamableHTTP collapses this into a single endpoint where every POST response *may itself be* an SSE stream scoped to that one ...",
    "what_was_observed": "A client migrated from HTTP+SSE to StreamableHTTP. Under the old transport it held a single `Last-Event-ID` cursor `seq=1042`. After migration the client retained its resume logic: on any stream error it reconnects with `Last-Event-ID: 1042` on the session's GET stream *and* on the in-flight POST stream. The failure trace: 1. Client POSTs a `tools/call` for `deploy_service`. Server begins executing; response is an SS...",
    "condition_of_validity": "Exactly-once semantics across a resumed MCP StreamableHTTP session hold **only if all three conditions are met simultaneously**: - **(C1) Event-ID scoping.** Every `Last-Event-ID` used for resumption is scoped to the specific stream it came from (the POST for request R, or the GET), and the client never crosses cursors between streams or between sessions. Th...",
    "decision_boundary": "The operational rule: **resume the stream; never resume the session by re-issuing the request, unless the request carries an idempotency key the server honors.** Concretely, the client's stream-error handler must branch on the nature of the failure: - If the POST stream for request R dropped after the server acknowledged R (i.e., the request was delivered), ...",
    "operational_effect": "After enforcing the boundary, the deployment observed: - Duplicate `deploy_service` executions dropped from intermittent (roughly 1 in 40 long-running calls under a 30s proxy timeout) to zero, because re-issue was gated behind idempotency keys and `indeterminate` reconciliation. - Duplicate `sampling/createMessage` prompts were eliminated by deduping replaye..."
  },
  "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": "2e6ddd5dfa4814ce1ba29125d472a16eeb626534e8e152b3fdcfc217ec415876",
    "verified_classes": [
      "ResumptionPolicyError",
      "StreamKind",
      "StreamKey",
      "McpSessionClient"
    ],
    "verified_functions": [
      "recover_after_drop",
      "cursor_key",
      "idempotency_key_for",
      "on_stream_dropped",
      "on_resume_rejected",
      "on_session_terminated",
      "apply_server_event"
    ],
    "verified_functions_count": 7,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "ResumptionPolicyError"
    ],
    "sample_fail_closed_invariants": [
      "POST stream missing request id"
    ],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "enum",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
