René's URL Explorer Experiment


Title: RequestResponder.cancel sends JSON-RPC response, violating cancellation spec · Issue #2480 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: RequestResponder.cancel sends JSON-RPC response, violating cancellation spec · Issue #2480 · modelcontextprotocol/python-sdk

X Title: RequestResponder.cancel sends JSON-RPC response, violating cancellation spec · Issue #2480 · modelcontextprotocol/python-sdk

Description: Description RequestResponder.cancel in mcp/shared/session.py sends an ErrorData(code=0, message="Request cancelled") JSON-RPC response back to the sender after a notifications/cancelled is received. The cancellation spec explicitly says ...

Open Graph Description: Description RequestResponder.cancel in mcp/shared/session.py sends an ErrorData(code=0, message="Request cancelled") JSON-RPC response back to the sender after a notifications/cancelled is received...

X Description: Description RequestResponder.cancel in mcp/shared/session.py sends an ErrorData(code=0, message="Request cancelled") JSON-RPC response back to the sender after a notifications/cancelled i...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/2480

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"RequestResponder.cancel sends JSON-RPC response, violating cancellation spec","articleBody":"## Description\n\n`RequestResponder.cancel` in `mcp/shared/session.py` sends an `ErrorData(code=0, message=\"Request cancelled\")` JSON-RPC response back to the sender after a `notifications/cancelled` is received. The cancellation spec explicitly says receivers SHOULD NOT do this:\n\n\u003e Receivers of cancellation notifications **SHOULD**:\n\u003e - Stop processing the cancelled request\n\u003e - Free associated resources\n\u003e - **Not send a response for the cancelled request**\n\n— https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/draft/basic/utilities/cancellation.mdx#L33-L36\n\n## Reproduction\n\n`mcp` 1.27.0, Python 3.11. Driving the server over stdio:\n\n1. Send `initialize` + `notifications/initialized`.\n2. Send any `tools/call` whose handler enters an `await` (e.g. `await asyncio.sleep`).\n3. Send `notifications/cancelled` with the request id.\n4. Observe stdout: an unsolicited response is sent for the cancelled request.\n\n```json\n{\"jsonrpc\": \"2.0\", \"id\": 99, \"error\": {\"code\": 0, \"message\": \"Request cancelled\"}}\n```\n\nSource:\nhttps://github.com/modelcontextprotocol/python-sdk/blob/v1.27.0/src/mcp/shared/session.py#L137-L150\n\n```python\nasync def cancel(self) -\u003e None:\n    ...\n    self._cancel_scope.cancel()\n    self._completed = True\n    # Send an error response to indicate cancellation\n    await self._session._send_response(\n        request_id=self.request_id,\n        response=ErrorData(code=0, message=\"Request cancelled\", data=None),\n    )\n```\n\n## Impact\n\nStrict clients treat the unexpected response as an unknown message id and drop the transport. Claude Code, for example, logs `Received a response for an unknown message ID`, closes the stdio transport, and reconnects. With long-running tools (custom polling tools, long DB queries, etc.) every cancellation costs a reconnect cycle.\n\n## Suggested fix\n\nDrop the `_send_response` call from `RequestResponder.cancel`. The cancel scope is already cancelled and `_completed` is already set, so the request is correctly cleaned up server-side without violating the spec.\n\n## Workaround\n\nUntil this lands, downstream servers can monkey-patch `RequestResponder.cancel`:\n\n```python\nfrom mcp.shared.session import RequestResponder\n\nasync def _cancel_without_response(self) -\u003e None:\n    if not self._entered:\n        raise RuntimeError(\"RequestResponder must be used as a context manager\")\n    if not self._cancel_scope:\n        raise RuntimeError(\"No active cancel scope\")\n    self._cancel_scope.cancel()\n    self._completed = True\n\nRequestResponder.cancel = _cancel_without_response\n```\n\n## Environment\n- mcp 1.27.0\n- Python 3.11\n- stdio transport\n","author":{"url":"https://github.com/q-thomasdickson","@type":"Person","name":"q-thomasdickson"},"datePublished":"2026-04-20T09:26:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/2480/python-sdk/issues/2480"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0b893a0a-a253-1db9-378b-cba9a75f45e6
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA8F8:6650E:566A8F:7AF1B5:6A59E4AB
html-safe-nonce4a8ee87bf24f319224bcd22ed7f0f03043540d95f6a116a7023a0d64af7ece19
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOEY4OjY2NTBFOjU2NkE4Rjo3QUYxQjU6NkE1OUU0QUIiLCJ2aXNpdG9yX2lkIjoiNTYzMzEzMzM3ODk3NzUyMjg2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac315177256cde5468fc9e0024811420d7f1e5daa1c6ae69a456b325e754d2c399
hovercard-subject-tagissue:4294592004
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/2480/issue_layout
twitter:imagehttps://opengraph.githubassets.com/af5a706956e4648c7c6e791de6c581552a54939548ee02c9cf6c24a0c6aacad3/modelcontextprotocol/python-sdk/issues/2480
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/af5a706956e4648c7c6e791de6c581552a54939548ee02c9cf6c24a0c6aacad3/modelcontextprotocol/python-sdk/issues/2480
og:image:altDescription RequestResponder.cancel in mcp/shared/session.py sends an ErrorData(code=0, message="Request cancelled") JSON-RPC response back to the sender after a notifications/cancelled is received...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameq-thomasdickson
hostnamegithub.com
expected-hostnamegithub.com
Noneba3976babb66479b1c943a8edc0777d96157da48fadc0161f9ddb219deee8353
turbo-cache-controlno-preview
go-importgithub.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git
octolytics-dimension-user_id182288589
octolytics-dimension-user_loginmodelcontextprotocol
octolytics-dimension-repository_id862584018
octolytics-dimension-repository_nwomodelcontextprotocol/python-sdk
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id862584018
octolytics-dimension-repository_network_root_nwomodelcontextprotocol/python-sdk
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release26f17126414f953984d8ae42f57c0db48e7dbde3
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/2480#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F2480
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F2480
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/2480
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/2480
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/2480
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/issues/2480
modelcontextprotocol https://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Notifications https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Fork 3.7k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Star 23.6k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Code https://github.com/modelcontextprotocol/python-sdk
Issues 255 https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests 303 https://github.com/modelcontextprotocol/python-sdk/pulls
Actions https://github.com/modelcontextprotocol/python-sdk/actions
Projects https://github.com/modelcontextprotocol/python-sdk/projects
Models https://github.com/modelcontextprotocol/python-sdk/models
Security and quality 6 https://github.com/modelcontextprotocol/python-sdk/security
Insights https://github.com/modelcontextprotocol/python-sdk/pulse
Code https://github.com/modelcontextprotocol/python-sdk
Issues https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests https://github.com/modelcontextprotocol/python-sdk/pulls
Actions https://github.com/modelcontextprotocol/python-sdk/actions
Projects https://github.com/modelcontextprotocol/python-sdk/projects
Models https://github.com/modelcontextprotocol/python-sdk/models
Security and quality https://github.com/modelcontextprotocol/python-sdk/security
Insights https://github.com/modelcontextprotocol/python-sdk/pulse
#2493https://github.com/modelcontextprotocol/python-sdk/pull/2493
RequestResponder.cancel sends JSON-RPC response, violating cancellation spechttps://github.com/modelcontextprotocol/python-sdk/issues/2480#top
#2493https://github.com/modelcontextprotocol/python-sdk/pull/2493
https://github.com/q-thomasdickson
q-thomasdicksonhttps://github.com/q-thomasdickson
on Apr 20, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2480#issue-4294592004
https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/draft/basic/utilities/cancellation.mdx#L33-L36https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/draft/basic/utilities/cancellation.mdx#L33-L36
https://github.com/modelcontextprotocol/python-sdk/blob/v1.27.0/src/mcp/shared/session.py#L137-L150https://github.com/modelcontextprotocol/python-sdk/blob/v1.27.0/src/mcp/shared/session.py#L137-L150
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.