Title: fix: stop sending JSON-RPC response on request cancellation by flobo3 · Pull Request #2481 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: fix: stop sending JSON-RPC response on request cancellation by flobo3 · Pull Request #2481 · modelcontextprotocol/python-sdk
X Title: fix: stop sending JSON-RPC response on request cancellation by flobo3 · Pull Request #2481 · modelcontextprotocol/python-sdk
Description: Summary RequestResponder.cancel() in mcp/shared/session.py sent an ErrorData(code=0, message="Request cancelled") JSON-RPC response back to the sender after a notifications/cancelled was received. The MCP cancellation spec explicitly states: Receivers of cancellation notifications SHOULD NOT send a response for the cancelled request. This unexpected response caused strict clients (e.g. Claude Code) to treat it as an unknown message ID, close the transport, and reconnect — making every cancellation of a long-running tool cost a full reconnect cycle. Changes src/mcp/shared/session.py: Removed _send_response() call from RequestResponder.cancel(). Added spec reference comment. src/mcp/server/lowlevel/server.py: Updated log message and comment to reflect that no response is sent (was "duplicate response suppressed", now "no response sent per spec"). tests/shared/test_session.py: Rewrote test_request_cancellation to verify the server handler's cancel scope is cancelled, rather than expecting an MCPError response. tests/server/test_cancel_handling.py: Added request_read_timeout_seconds to the cancelled request so it times out cleanly (no response is sent). Fixes #2480
Open Graph Description: Summary RequestResponder.cancel() in mcp/shared/session.py sent an ErrorData(code=0, message="Request cancelled") JSON-RPC response back to the sender after a notifications/cancelled was ...
X Description: Summary RequestResponder.cancel() in mcp/shared/session.py sent an ErrorData(code=0, message="Request cancelled") JSON-RPC response back to the sender after a notifications/cancel...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/2481
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:98631b81-9d86-6ba9-ce49-f41cac01b393 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 80B2:1EF8:166FBC6:1DB8812:6A5AE5B3 |
| html-safe-nonce | 3d3f81764891b03e16b889bd4e5c8ebc6a25257eba58487158401979c68a2a01 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MEIyOjFFRjg6MTY2RkJDNjoxREI4ODEyOjZBNUFFNUIzIiwidmlzaXRvcl9pZCI6IjEyNzM4OTY4NjIzNzUxNDI4MzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | efabe51b9776cc9fbe78342c4e4d9e379e1b95d1b9a583cfd63247f7141b640e |
| hovercard-subject-tag | pull_request:3555251557 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/2481/files |
| twitter:image | https://avatars.githubusercontent.com/u/268352850?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/268352850?s=400&v=4 |
| og:image:alt | Summary RequestResponder.cancel() in mcp/shared/session.py sent an ErrorData(code=0, message="Request cancelled") JSON-RPC response back to the sender after a notifications/cancelled was ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width