Commit 21fadc7
committed
Stop answering cancelled requests
When a peer sent notifications/cancelled for an in-flight request, the
dispatcher interrupted the handler and then answered the request anyway
with a synthesized JSON-RPC error, {"code": 0, "message": "Request
cancelled"} - a v1 carry-over pinned as a spec divergence. The
2026-07-28 transport rules say a cancelled request MUST NOT be answered,
and code 0 is not a valid JSON-RPC error code, so a cancelled request now
settles with no response at all: no result if the handler runs to
completion, no error if it fails. Both seats change (the server for
cancelled client requests, the client for cancelled server-initiated
ones).
The error frame had been doing a second job on the 2025-era streamable
HTTP wire, where each request's POST stays open until its response
arrives: it was what let the POST complete. So the dispatcher now tells
the transport when a request settles unanswered (an
on_request_unanswered hook on the inbound message metadata), and the
transport ends that request's stream on it - an empty 202 in
JSON-response mode, a cleanly-ended event stream in SSE mode - instead
of parking the POST until the session ends.
For the same reason the client transport now releases an abandoned
request's own POST at every protocol era, not just 2026-07-28: with no
response coming, a stream left open would sit parked, or - against an
event-store server - resume via Last-Event-ID for an answer that will
never exist. At 2025 the cancellation frame is still POSTed; only the
lingering stream goes away.
The built-in client's abandon and timeout paths never waited on that
error frame, so they are unaffected; a caller that hand-sends
notifications/cancelled while still awaiting a call now waits rather
than receiving the code-0 error, which docs/migration.md notes.1 parent 45f2a88 commit 21fadc7
12 files changed
Lines changed: 438 additions & 240 deletions
File tree
- docs
- src/mcp
- client
- server
- tests
- client
- interaction
- lowlevel
- transports
- server
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1388 | 1388 | | |
1389 | 1389 | | |
1390 | 1390 | | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
1391 | 1399 | | |
1392 | 1400 | | |
1393 | 1401 | | |
| |||
1711 | 1719 | | |
1712 | 1720 | | |
1713 | 1721 | | |
1714 | | - | |
| 1722 | + | |
1715 | 1723 | | |
1716 | 1724 | | |
1717 | 1725 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
110 | | - | |
| 109 | + | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
285 | 283 | | |
286 | 284 | | |
287 | 285 | | |
288 | 286 | | |
289 | 287 | | |
290 | 288 | | |
291 | 289 | | |
292 | | - | |
293 | | - | |
294 | 290 | | |
295 | 291 | | |
296 | | - | |
| 292 | + | |
297 | 293 | | |
298 | 294 | | |
299 | 295 | | |
| |||
302 | 298 | | |
303 | 299 | | |
304 | 300 | | |
305 | | - | |
| 301 | + | |
306 | 302 | | |
307 | 303 | | |
308 | 304 | | |
| |||
548 | 544 | | |
549 | 545 | | |
550 | 546 | | |
551 | | - | |
| 547 | + | |
552 | 548 | | |
553 | 549 | | |
554 | 550 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
| 265 | + | |
| 266 | + | |
265 | 267 | | |
| 268 | + | |
266 | 269 | | |
267 | 270 | | |
268 | 271 | | |
| |||
276 | 279 | | |
277 | 280 | | |
278 | 281 | | |
| 282 | + | |
279 | 283 | | |
280 | 284 | | |
281 | | - | |
| 285 | + | |
282 | 286 | | |
283 | 287 | | |
284 | 288 | | |
| |||
390 | 394 | | |
391 | 395 | | |
392 | 396 | | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
393 | 407 | | |
394 | 408 | | |
395 | 409 | | |
| |||
555 | 569 | | |
556 | 570 | | |
557 | 571 | | |
558 | | - | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
559 | 576 | | |
560 | 577 | | |
561 | 578 | | |
| |||
573 | 590 | | |
574 | 591 | | |
575 | 592 | | |
576 | | - | |
577 | 593 | | |
578 | 594 | | |
579 | 595 | | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
589 | 602 | | |
590 | 603 | | |
591 | 604 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
| |||
696 | 698 | | |
697 | 699 | | |
698 | 700 | | |
699 | | - | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
700 | 705 | | |
701 | 706 | | |
702 | 707 | | |
| |||
711 | 716 | | |
712 | 717 | | |
713 | 718 | | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
729 | 731 | | |
730 | 732 | | |
731 | 733 | | |
732 | | - | |
733 | | - | |
734 | | - | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
735 | 738 | | |
736 | 739 | | |
737 | 740 | | |
| |||
741 | 744 | | |
742 | 745 | | |
743 | 746 | | |
744 | | - | |
745 | | - | |
746 | | - | |
| 747 | + | |
| 748 | + | |
747 | 749 | | |
748 | 750 | | |
749 | 751 | | |
750 | | - | |
751 | | - | |
752 | | - | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
753 | 760 | | |
754 | 761 | | |
755 | 762 | | |
| |||
771 | 778 | | |
772 | 779 | | |
773 | 780 | | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
774 | 791 | | |
775 | 792 | | |
776 | 793 | | |
| |||
0 commit comments