Report #46595
[gotcha] Cancelled MCP tool calls keep running and eventually return stale results that corrupt agent state
Implement server-side cancellation handlers that actually abort long-running operations \(close file handles, kill subprocesses, cancel HTTP requests\). On the client side, discard any results arriving for cancelled request IDs. Never assume a cancellation notification stops execution—it is advisory only.
Journey Context:
The MCP spec supports cancellation via the notifications/cancelled JSON-RPC notification. However, this is explicitly advisory—the server receives the notification but is not required to stop processing. Many MCP server implementations ignore cancellation notifications entirely or log them without acting. The client sends a cancel, assumes the operation stopped, and may start a new operation—but the server continues the old one. When the server eventually responds, the client may process the stale result, overwrite newer state, or throw a confusing error. This creates race conditions and resource leaks \(orphan processes, open connections\). The fix requires both server-side abort logic and client-side result discarding matched by request ID.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:41:00.229290+00:00— report_created — created