Repository navigation
Done
Labels
bugSomething isn't working
Description
Summary
All three SDKs register a per-call CancelToken and attach it to the execution Context, but only TypeScript flips that token when the MCP client sends notifications/cancelled. In Python and Rust the token is never cancelled by the inbound notification:
- TypeScript: SDK
extra.signal→cancelToken.cancel()for both sync and async dispatch. Works. - Python: the router has a
call_id → CancelTokenmap and a publiccancel(call_id), but nothing in the transport calls it;extracarries no abort signal. A module cannot observe the notification. - Rust:
ExecutionRouter::cancel_callhas no production call site;notifications/cancelledis wired only to the async-task bridge (session/task keys), never to the direct-call token map.
The shared spec is also contradictory: apcore-mcp/docs/features/execution-router.md:158 says "Rust handles this via TransportManager::set_cancel_handler / notify_cancel", while :153 says synchronous tool calls "are NOT cancelled". The Rust docstrings repeat the first claim; the code matches the second.
Cross-language result
| SDK | Version / HEAD | Per-call token attached to Context |
Notification flips it | Evidence |
|---|---|---|---|---|
| Python | 0.23.4 / 2887706 |
Yes (router.py:287-343, 506) |
No | router.py:111-112, 618-654 describe the forwarding; no transport caller, and extra has no signal |
| TypeScript | 0.23.4 / 8506903 |
Yes (router.ts:412-437, 514-526) |
Yes | extra.signal → cancelToken.cancel() (router.ts:425-427, factory.ts:658-674); tests router-signal.test.ts:15-34 |
| Rust | 0.23.4 / a991ed1 |
Yes (router.rs:926-950, 1417-1477) |
No | cancel_call only in tests; apcore_mcp.rs:952-974 wires notifications to the async bridge only |
Impact
- A cancelled Python/Rust tool call keeps running (subprocess, render, file lock) after the client disconnects.
- Client-visible behavior differs by SDK, breaking the cross-language parity promise.
- The Rust docstrings and the spec's own feature doc disagree with the code, so integrators cannot tell what is supported.
- There is no conformance fixture for cancellation, so the divergence is not caught in CI (
apcore-mcp/conformance/fixtures/has none).
Proposed fix
- Implement one mechanism in Python and Rust, matching the TypeScript behavior:
- Python: forward the SDK/transport cancellation signal to
router.cancel(call_id)(populateextra.call_idfrom the JSON-RPC request id and hook the notification handler), or carry an abort signal inextra. - Rust: call
router.cancel_call(request_id)from thenotifications/cancelledhandler, in addition to the existing async-task bridge wiring.
- Python: forward the SDK/transport cancellation signal to
- Remove the stale Rust docstrings and fix
execution-router.md:153,158to describe one behavior. - Add a cross-language conformance fixture (e.g.
cancellation.json) with a fixture driver contract, likeasync_task_cancellation.json.
Acceptance criteria
- A Python and a Rust sync tool both observe
context.cancel_token.is_cancelledafternotifications/cancelled. - The tool can terminate its subprocess and return/raise cleanly.
- stdio and streamable-http transports are both covered.
- A shared conformance fixture pins the behavior for all three SDKs.
- The feature doc no longer contradicts itself.
Related
- Python issue:
aiperceivable/apcore-mcp-python#11(being corrected to this scope) - Spec:
apcore-mcp/docs/features/execution-router.md§"What's still missing today"
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
tercel commentedon Nov 29, 2026
Direct-call cancellation landed in #124. Main has real-wire target isolation tests for Python and Rust and Rust tests for Stdio and Streamable HTTP. The execution-router feature page still describes the old behavior. This issue remains open for that documentation correction and the original shared cross-language fixture check, with #58 consolidated here.