notifications/cancelled is a client → server notification (no response expected). The client sends it when the user wants to abort an in-flight request — for example, hitting “Stop” while a long-running tools/call is mid-execution.
GetMCP records the cancellation against session_id + request_id in an in-process registry. Code paths that opt into cancellation can poll the flag and bail early.
Wire-level Shape
The
id of the in-flight request the client wants to cancel.Optional human-readable explanation. Logged but not propagated to the upstream API.
Polling the Flag
Once the cancellation lands, any code on the server can check:is_cancelled() is O(1) — cheap enough to poll inside a loop iterating over large datasets or pre-flight before each upstream HTTP call.
Caveats
- The built-in
ToolExecutoris synchronous. It does not yet pollis_cancelled()mid-flight, so an in-flighttools/callwill run to completion regardless. The hook is in place — wiring it into the executor’s loops is a future change. - Custom tools authored via the
getmcp_after_tool_call/getmcp_before_tool_callhooks can poll the flag manually. - Cancellation state is cleared automatically when the request completes (success or error) so re-using the same request id later doesn’t carry a stale cancel.
Cancellation is “best effort” per the spec. The server is not required to honour every cancel signal — it may simply finish the in-flight work and return the result. GetMCP follows this contract.

