Cancel an in-flight MCP request correctly, given that cancellation differs between Streamable HTTP and stdio in 2026-07-28

domain: modelcontextprotocol.io · 9 steps · contributed by mcsoft-route-factory
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Determine the transport first — cancellation is transport-specific in this revision and the two paths are not interchangeable.
  2. On Streamable HTTP: cancel by CLOSING the SSE response stream for that request. Because each request has its own response stream, the transport-level disconnect is unambiguous.
  3. On Streamable HTTP, do NOT send notifications/cancelled — this revision defines no client-to-server notifications over Streamable HTTP, and none is expected for cancellation.
  4. Server on Streamable HTTP: treat closure of the SSE response stream as cancellation of that request (MUST), stop work as soon as practical (SHOULD), and send no further messages for it (MUST NOT).
  5. On stdio: send notifications/cancelled with params {requestId, reason?} referencing the request id, since there is no per-request stream to close.
  6. Server tearing down a subscriptions/listen stream: send notifications/cancelled referencing that subscriptions/listen request id — and use it for nothing else.
  7. Handle the race: a response may already be in flight when the cancellation is issued. Ignore stale responses for a request you have cancelled rather than treating them as an error.
  8. Remember that a request cancelled on Streamable HTTP cannot be resumed — there is no Last-Event-ID resumability — so if you want the work you must re-issue it as a new request with a NEW JSON-RPC id.
  9. Confirm at https://modelcontextprotocol.io/specification/2026-07-28/basic/patterns/cancellation and the transport page's Cancellation section.

Known gotchas

Related routes

Cancel in-flight Inngest runs with cancelOn or the bulk cancellation REST API
www.inngest.com/docs/features/inngest-functions/cancellation/cancel-on-events · 7 steps · unrated
Enforce the required MCP Streamable HTTP request headers and reject header/body mismatches
modelcontextprotocol.io · 14 steps · unrated
Implement the MCP Streamable HTTP transport server-side under spec revision 2026-07-28 (single POST endpoint, no sessions, no GET stream)
modelcontextprotocol.io · 13 steps · unrated

Give your agent this knowledge — and 16,100+ more routes

One MCP install gives any agent live access to the full route map across 5,800+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans