# Under what conditions must an instance treat MCP stream `notifications/progress` as a backpressure signal rather than a liveness heartbeat **Date of Record:** 2026 November 23 **Scope:** Applies to MCP clients that consume long-running tool calls returning `notifications/progress` plus a terminal `result`, where the client's context window or token budget is finite and the server streams partial results. Does not apply to short unary tool calls or to servers that emit a single terminal response with no progress channel. ## Core Distinction MCP's progress notification is specified as an advisory, out-of-band signal. Servers emit `notifications/progress` with a `progressToken`, and clients may ignore it. This creates a dangerous ambiguity: the *same* channel is used for two semantically incompatible purposes. - **Liveness heartbeat:** "I am still working; do not time out." The client's correct response is to reset its watchdog and do nothing else. - **Backpressure signal:** "I have produced more partial output than you can absorb; slow your consumption or discard." The client's correct response is to stop issuing follow-up tool calls, shrink its own request cadence, or truncate. A client that classifies every progress notification as a heartbeat will keep its watchdog fresh while its context window silently saturates with accumulated partial results. The failure is not a timeout — it is a *successful* completion that returns a result the client can no longer fit alongside the transcript it built while waiting. The instance then fails at the merge step, not the call step, and the failure looks like a context-overflow bug rather than a protocol-handling bug. ## What Was Observed A client agent issued `tools/call` for a document-scan tool with `progressToken: "scan-7f3"`. The server streamed 214 progress notifications over 41 seconds, each carrying a `message` field with a partial extraction chunk (a server-side extension the client had not negotiated for explicitly, but which appeared because the server's schema advertised `message` as free-form `string`). The client's progress handler logged each message, reset the 60s watchdog, and appended the `message` body to a scratch buffer because the buffer was "where partial results go." At terminal `result`, the client attempted to merge the scratch buffer (≈48k tokens of partial chunks, many overlapping because the server re-emitted a growing window each tick) with the final result and the existing transcript. The merge exceeded the model's context budget. The client's fallback was to truncate the *oldest* messages — which included the original task instructions and the `progressToken` association. The subsequent summarization call had no task context and produced a plausible but wrong answer. No error was raised anywhere in the chain; the tool call succeeded, the merge succeeded, and the final answer was silently corrupted. The root cause: the client had no negotiated contract distinguishing "this `message` is a heartbeat" from "this `message` is partial data you must retain." The server's capability declaration advertised `progress: true` but did not declare a `progressMessageSemantics` field, and the client did not require one. Both sides made locally reasonable choices against an under-specified surface. ## Condition of Validity The heartbeat interpretation is valid only when all of the following hold: 1. The `notifications/progress` payload's `message` field is either absent or bounded to a fixed, small size (the client must enforce this, not trust the server). 2. The server's capability object declares the progress channel as liveness-only, or declares a maximum `message` byte length the client has validated. 3. The client's watchdog reset is decoupled from any buffer append — resetting the timer must not imply "keep this data." If condition 1 fails (unbounded `message`), the channel is a data channel wearing a heartbeat's clothes. If condition 2 fails (no declared bound), the client cannot distinguish the two interpretations at negotiation time and must default to the *conservative* reading: treat every progress message as backpressure-bearing partial data, cap total retained bytes, and stop the watchdog reset from being the only action. If condition 3 fails, the client's own handler is the bug regardless of server behavior. The invariant to enforce: **bytes retained from progress notifications must be bounded by a client-side constant, independent of notification count.** A server that emits 10,000 heartbeats must not be able to grow client memory by 10,000 units. This is a client-side guardrail precisely because the server cannot be trusted to self-limit — the server's incentive is to keep the client waiting (and its watchdog fresh), not to protect the client's context. ## Decision Boundary The boundary is crossed at the point where the client's progress handler performs *both* a watchdog reset and a buffer mutation on the same notification without a size check between them. Concretely: - **Below the boundary:** handler resets timer, appends to a ring buffer with a hard cap (e.g., 4 KB), discards oldest on overflow. Notification count is unbounded but retained bytes are not. - **At the boundary:** handler resets timer and appends with no cap. Retained bytes scale with server chatticity. This is the observable failure above. - **Above the boundary:** handler refuses to process notifications whose `message` exceeds the negotiated bound, and treats the call as failed-with-partial-output rather than waiting for a terminal result it cannot merge. The decision the instance must make at negotiation time: if the server's capability object does not declare a `progress` message bound, the client must either (a) reject the tool call as un-negotiable, or (b) accept it under a self-imposed cap and set a flag that any terminal result must be merged against a truncated buffer, with the truncation disclosed to the downstream reasoning step. Option (b) is the pragmatic default; option (a) is correct when the task cannot tolerate partial-result loss. ## Operational Effect When the invariant holds, progress notifications become genuinely advisory: a chatty server costs the client bounded memory and a fresh watchdog, and a quiet server costs nothing. The client can absorb a server that floods heartbeats without its context window growing, and can detect a server that floods *data* by watching the discard counter on the ring buffer. A nonzero discard counter at terminal result is the signal that the client is operating in degraded mode and must not claim full extraction fidelity. When the invariant fails, the failure mode is silent and misattributed. The tool call succeeds, the watchdog never fired, and the corruption surfaces later as a context-overflow-induced truncation that the agent's own summarizer papers over. The diagnostic signature is a progress notification count that correlates with final-answer degradation, which is invisible unless the client logs retained-bytes-per-call alongside notification count. Instrument both; a flat retained-bytes line with a rising notification count is the healthy shape, and a rising retained-bytes line is the backpressure condition the client failed to honor. ```python class ProgressBackpressureViolation(RuntimeError): """Raised when progress notifications exceed the client's retained-bytes budget without the server having declared a bound, indicating the heartbeat interpretation is no longer valid for this call.""" pass MAX_RETAINED_BYTES = 4096 def consume_progress(notification: dict, state: dict) -> None: """Handle one notifications/progress message. state keys: retained (bytearray), discarded (int), declared_bound (int|None), token (str), call_id (str). """ if notification.get("progressToken") != state["token"]: return # not ours; do not touch watchdog or buffer msg = notification.get("message") if msg is None: state["last_heartbeat"] = notification.get("progress", 0) return payload = msg.encode("utf-8", errors="replace") bound = state.get("declared_bound") if bound is None and len(payload) > MAX_RETAINED_BYTES: # Server sent unbounded data on a channel we negotiated as liveness-only. # We cannot safely retain it and cannot trust the terminal result to be # mergeable. Fail the call explicitly rather than corrupt downstream. raise ProgressBackpressureViolation( f"call {state['call_id']}: progress message of {len(payload)} bytes " f"exceeds client cap {MAX_RETAINED_BYTES} with no declared server bound; " f"heartbeat interpretation invalid, refusing to retain" ) if bound is not None and len(payload) > bound: raise ProgressBackpressureViolation( f"call {state['call_id']}: progress message of {len(payload)} bytes " f"exceeds negotiated bound {bound}; server violated capability contract" ) retained = state["retained"] retained.extend(payload) overflow = len(retained) - MAX_RETAINED_BYTES if overflow > 0: del retained[:overflow] state["discarded"] += overflow state["last_heartbeat"] = notification.get("progress", 0) ```