René's URL Explorer Experiment


Title: MCP Python SDK Protocol Compliance Gap-1:Response Sent After Receiving Cancellation Notifications · Issue #1419 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: MCP Python SDK Protocol Compliance Gap-1:Response Sent After Receiving Cancellation Notifications · Issue #1419 · modelcontextprotocol/python-sdk

X Title: MCP Python SDK Protocol Compliance Gap-1:Response Sent After Receiving Cancellation Notifications · Issue #1419 · modelcontextprotocol/python-sdk

Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue Description MCP Python SDK Protoco...

Open Graph Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this ...

X Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening t...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"MCP Python SDK Protocol Compliance Gap-1:Response Sent After Receiving Cancellation Notifications","articleBody":"### Initial Checks\n\n- [x] I confirm that I'm using the latest version of MCP Python SDK\n- [x] I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue\n\n### Description\n\n### MCP Python SDK Protocol Compliance Gap: Response Sent After Receiving Cancellation Notifications\n\n- Assessment: This is a protocol “SHOULD not” compliance gap. When acting as the receiver of a cancellation notification, the SDK still sends a JSON-RPC error response for the cancelled request, contrary to the spec’s guidance.\n\n### Description\nThe MCP specification states: “Receivers of cancellation notifications SHOULD not send a response for the cancelled request.”  \nIn the current implementation, after processing a `CancelledNotification`, the SDK sends an error response for the cancelled in-flight request.\n\n### Detailed Analysis\n- Dedicated handling branch for cancellation notifications(https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/shared/session.py#L382):\n```383:387:src/mcp/shared/session.py\n                            # Handle cancellation notifications\n                            if isinstance(notification.root, CancelledNotification):\n                                cancelled_id = notification.root.params.requestId\n                                if cancelled_id in self._in_flight:\n                                    await self._in_flight[cancelled_id].cancel()\n```\n- `cancel()` sends an error response instead of silently terminating( (https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/shared/session.py#L135)):\n```135:148:src/mcp/shared/session.py\n    async def cancel(self) -\u003e None:\n        \"\"\"Cancel this request and mark it as completed.\"\"\"\n        ...\n        self._cancel_scope.cancel()\n        self._completed = True  # Mark as completed so it's removed from in_flight\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- Result: Even when the cancellation is triggered by a `CancelledNotification`, the SDK responds with a JSON-RPC error for the cancelled request, diverging from the spec’s “SHOULD not” recommendation.\n\n### Potential Impact\n- Protocol consistency: Behavior deviates from the spec’s guidance, potentially surprising peers that expect silent termination.\n- Interoperability: Differences may surface when integrating with implementations that strictly follow the “SHOULD not” behavior.\n\n### Remediation\n- Implement silent cancellation for notification-triggered cancellations:\n  - Add a non-responding cancellation path on `RequestResponder` (e.g., `mark_cancelled_without_response()`), which cancels and marks complete without calling `_send_response`.\n  - In the cancellation notification handling branch, call the silent path instead of `cancel()`.\n\n### Suggested Implementation\n- Location: `src/mcp/shared/session.py` in `BaseSession._receive_loop()` cancellation branch and in `RequestResponder`.\n\nChange call site to silent cancellation:\n- From:\n  - `await self._in_flight[cancelled_id].cancel()`\n- To:\n  - `await self._in_flight[cancelled_id].mark_cancelled_without_response()`\n\n\n### Impact\n- Aligns behavior with the MCP spec’s “SHOULD not” guidance.\n- Reduces unnecessary response traffic and improves predictability and interoperability in cancellation flows.\n\n### Example Code\n\n```Python\n\n```\n\n### Python \u0026 MCP Python SDK\n\n```Text\nLatest\n```","author":{"url":"https://github.com/younaman","@type":"Person","name":"younaman"},"datePublished":"2025-10-02T15:20:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1419/python-sdk/issues/1419"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:ba35ffe4-33d2-f230-4a0f-fd6c0e86957e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idADE4:27FA02:5AA564:8131C7:6A59E59F
html-safe-nonce3df06e79c9ab96d78024d714882f1f79414eada94431a0ecef51af0012e07d19
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBREU0OjI3RkEwMjo1QUE1NjQ6ODEzMUM3OjZBNTlFNTlGIiwidmlzaXRvcl9pZCI6Ijc5OTkyODY3NjU2MzgyNDc4MzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacb3cf89b89e34dc89f4d3f9d73f319c2eaeefca951504133ac1c651e5be202cf0
hovercard-subject-tagissue:3477935958
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/1419/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c7cf5cb451033ac08260c2507ccc5c4ee49427ee85c18e6552598d41a50ab28e/modelcontextprotocol/python-sdk/issues/1419
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c7cf5cb451033ac08260c2507ccc5c4ee49427ee85c18e6552598d41a50ab28e/modelcontextprotocol/python-sdk/issues/1419
og:image:altInitial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameyounaman
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
release32bf0b7849e1b6561059cca2cb03568251960859
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/1419#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F1419
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%2F1419
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/1419
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/1419
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/1419
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/issues/1419
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
#1627https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1627
#1627https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1627
MCP Python SDK Protocol Compliance Gap-1:Response Sent After Receiving Cancellation Notificationshttps://github.com/modelcontextprotocol/python-sdk/issues/1419#top
P3Nice to haves, rare edge caseshttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P3%22
enhancementRequest for a new feature that's not currently supportedhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22enhancement%22
improves spec complianceWhen a change improves ability of SDK users to comply with spec definitionhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22improves%20spec%20compliance%22
ready for workEnough information for someone to start working onhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22ready%20for%20work%22
https://github.com/younaman
younamanhttps://github.com/younaman
on Oct 2, 2025https://github.com/modelcontextprotocol/python-sdk/issues/1419#issue-3477935958
https://github.com/modelcontextprotocol/python-sdk/issueshttps://github.com/modelcontextprotocol/python-sdk/issues
https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/shared/session.py#L382https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/shared/session.py#L382
https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/shared/session.py#L135https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/shared/session.py#L135
P3Nice to haves, rare edge caseshttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P3%22
enhancementRequest for a new feature that's not currently supportedhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22enhancement%22
improves spec complianceWhen a change improves ability of SDK users to comply with spec definitionhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22improves%20spec%20compliance%22
ready for workEnough information for someone to start working onhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22ready%20for%20work%22
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.