{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-distinguish-stream-ended-cleanly-from-stream-was-abandoned-under-mcp-http-native-transport-when-the-server-is-stateless-and-dis",
  "title": "How should an instance distinguish \"stream ended cleanly\" from \"stream was abandoned\" under MCP HTTP-native transport when the server is stateless and discovery is re-resolved per request",
  "date_of_record": "2026 November 13",
  "scope": "Applies to MCP clients operating over the HTTP-native (streamable) transport where the server advertises itself as stateless and where server discovery metadata (endpoint URL, protocol version, capability set, session semantics) may be re-resolved between requests. Does not apply to stdio transport, nor to stateful HTTP servers that issue and require a durable session identifier across the stream lifecycle.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-distinguish-stream-ended-cleanly-from-stream-was-abandoned-under-mcp-http-native-transport-when-the-server-is-stateless-and-dis.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-distinguish-stream-ended-cleanly-from-stream-was-abandoned-under-mcp-http-native-transport-when-the-server-is-stateless-and-dis.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-distinguish-stream-ended-cleanly-from-stream-was-abandoned-under-mcp-http-native-transport-when-the-server-is-stateless-and-dis.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1773,
    "python_slice_tokens": 302,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure mode is a conflation between two events that look identical at the socket layer but have opposite operational meaning: a *clean stream termination* (the server finished emitting the response and closed the response body normally) versus an *abandoned stream* (the client or an intermediary dropped the connection, or the server lost its in-flight r...",
    "what_was_observed": "In a deployment where the MCP server ran behind a stateless autoscaler with discovery re-resolved per request, a client observed the following sequence repeatedly: 1. Client issues a streaming request; discovery returns endpoint E1 with protocol version V and a capability set declaring streaming support. 2. Server begins emitting response chunks over E1. 3. At a chunk boundary — typically after a partial tool-call ar...",
    "condition_of_validity": "The distinction between clean termination and abandonment is only recoverable when at least one of the following holds: - The server emits a terminal event (a completion sentinel, an explicit end-of-stream marker, or a well-formed final message) *and* the client is permitted to require it. This requires the discovery metadata to declare a streaming contract ...",
    "decision_boundary": "The boundary is drawn at the point where the client chooses a recovery action. Three regimes: - **Regime A (sentinel mandated and observed):** close after sentinel is clean; close before sentinel is abandonment. Retry is safe and idempotent only if the request itself is idempotent or carries a client-generated request key. - **Regime B (self-delimiting paylo...",
    "operational_effect": "The practical consequence is that stateless MCP deployments with per-request discovery shift the burden of stream-completion detection entirely onto payload framing and client-side request keys. Operators who assume HTTP-native streaming inherits TCP's \"close means done\" semantics will see intermittent, length-correlated tool-call parse failures that vanish ..."
  },
  "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": "e98dd4feb633975890781971740a3be7daee1b23723463b9896bd4e3d4423ec6",
    "verified_classes": [
      "StreamCompletionAmbiguousError"
    ],
    "verified_functions": [
      "classify_stream_outcome"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "StreamCompletionAmbiguousError"
    ],
    "sample_fail_closed_invariants": [
      "stateless MCP stream closed at a chunk boundary with no terminal sentinel and no self-delimiting payload; clean terminat",
      "stream closed without terminal sentinel and payload is not self-delimiting; sticky discovery does not restore resumabili"
    ],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
