{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-an-mcp-streamable-batch-upgrade-mid-tool-call-the-sse-to-stream-promotion-race-and-its-per-tool-capability-invariant",
  "title": "When must an instance refuse an MCP streamable-batch upgrade mid-tool-call: the SSE-to-stream promotion race and its per-tool capability invariant",
  "date_of_record": "2026 December 1",
  "scope": "Applies to MCP clients and servers negotiating the HTTP-native transport where a batch POST may be answered either as a single JSON body or promoted to an SSE stream, and where individual tools within a batch may independently request stream upgrade. Does not apply to stdio transports, to pure single-request JSON-RPC over HTTP without batching, or to servers that advertise no streaming capability at all.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-an-mcp-streamable-batch-upgrade-mid-tool-call-the-sse-to-stream-promotion-race-and-its-per-tool-capability-invariant.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-an-mcp-streamable-batch-upgrade-mid-tool-call-the-sse-to-stream-promotion-race-and-its-per-tool-capability-invariant.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-an-mcp-streamable-batch-upgrade-mid-tool-call-the-sse-to-stream-promotion-race-and-its-per-tool-capability-invariant.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2558,
    "python_slice_tokens": 584,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between *batch-level transport negotiation* and *per-tool stream semantics*. In the MCP HTTP-native transport, a client sends a JSON-RPC batch and the server chooses a response encoding: either a single `application/json` body containing all responses, or an `text/event-stream` body that emits responses as SSE events. The tran...",
    "what_was_observed": "A client agent issued a batch of three `tools/call` requests over the HTTP-native transport: 1. `search_index` — a short tool, expected to return in <200ms. 2. `run_code` — a long tool that the server implements as a streaming tool, emitting partial stdout as SSE `message` events and a final `result` event. 3. `fetch_url` — a medium tool with no streaming semantics. The client sent `Accept: application/json, text/eve...",
    "condition_of_validity": "The batch-level negotiation is only sound when the following hold simultaneously: - **Encoding commitment precedes first byte.** The server must decide JSON vs. SSE before writing any byte of the response body, and must never switch after the first byte. This is a transport-layer invariant, not a tool-layer one. - **Per-tool streaming intent is declared befo...",
    "decision_boundary": "The decision boundary is the moment the server writes the response status line and `Content-Type`. Before that byte, the server may freely choose JSON or SSE, and the client must be prepared for either. After that byte, the encoding is frozen and the client's reader must be bound to the actual `Content-Type`. For the client, the operative rule is: **do not b...",
    "operational_effect": "The downstream effect on the agent is a *silent partial success* that is worse than a clean failure. In the first variant, all three tool calls time out together — the agent's reasoning loop sees a transport failure and can retry the whole batch, which is recoverable but wasteful. In the second variant, `run_code` returns a partial stdout that the agent's re..."
  },
  "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": "a474885b9d0a52ad20e28b624c83afe66614b10d8e1c2c34b0d57995686a25ec",
    "verified_classes": [
      "StreamNegotiationError",
      "ToolCapability",
      "BatchResponse"
    ],
    "verified_functions": [
      "validate_batch_response",
      "handle_batch"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 7,
    "raised_exceptions": [
      "StreamNegotiationError"
    ],
    "sample_fail_closed_invariants": [
      "Client bound an SSE reader but server returned JSON body; reader framing must follow Content-Type, not Accept.",
      "Server promoted to SSE but client did not accept event-stream."
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "json",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
