René's URL Explorer Experiment


Title: MCP Python SDK Implementation Gap-17: Missing Cancellation Notifications on Request Timeout · Issue #1458 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: MCP Python SDK Implementation Gap-17: Missing Cancellation Notifications on Request Timeout · Issue #1458 · modelcontextprotocol/python-sdk

X Title: MCP Python SDK Implementation Gap-17: Missing Cancellation Notifications on Request Timeout · Issue #1458 · 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 Summary The MCP Python...

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/1458

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"MCP Python SDK Implementation Gap-17: Missing Cancellation Notifications on Request Timeout","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## Summary\n\nThe MCP Python SDK implementation does not fully comply with the MCP specification regarding timeout handling. While the SDK implements request timeouts, it does not send cancellation notifications when requests timeout.\n\n## Specification Reference\n\nAccording to the MCP specification:\n\n\u003e Implementations **SHOULD** establish timeouts for all sent requests, to prevent hung connections and resource exhaustion. When the request has not received a success or error response within the timeout period, the sender **SHOULD** issue a cancellation notification for that request and stop waiting for a response.\n\n## Current Implementation Analysis\n\n###  What's Working\n\n1. **Timeout Mechanism**: The SDK correctly implements timeout detection in `BaseSession.send_request()` method\n2. **Timeout Configuration**: Supports both session-level and request-level timeout configuration  \n3. **Exception Handling**: Properly raises `McpError` with `REQUEST_TIMEOUT` code when timeout occurs\n4. **Manual Cancellation**: Supports manual cancellation notifications via `CancelledNotification`\n\n###  What's Missing\n\nWhen a request times out, the SDK does not automatically send a `CancelledNotification` to inform the server that the request should be cancelled.\n\n## Code Evidence\n\n### Current Timeout Implementation\n\n**File**: `src/mcp/shared/session.py`  \n**Lines**: 270-283\n\n```python\ntry:\n    with anyio.fail_after(timeout):\n        response_or_error = await response_stream_reader.receive()\nexcept TimeoutError:\n    raise McpError(\n        ErrorData(\n            code=httpx.codes.REQUEST_TIMEOUT,\n            message=(\n                f\"Timed out while waiting for response to \"\n                f\"{request.__class__.__name__}. Waited \"\n                f\"{timeout} seconds.\"\n            ),\n        )\n    )\n```\n\n**Problem**: The code only raises an exception but does not send a cancellation notification to the server.\n\n## Impact\n\n**Specification Non-compliance**: The implementation does not follow the MCP specification requirements\n\n## Proposed Solution\n\nModify the timeout handling in `BaseSession.send_request()` to automatically send a cancellation notification:\n\n```python\nexcept TimeoutError:\n    # Send cancellation notification as per MCP specification\n    try:\n        await self.send_notification(\n            CancelledNotification(\n                params=CancelledNotificationParams(requestId=request_id)\n            )\n        )\n    except Exception:\n        # Log but don't fail if notification sending fails\n        logger.warning(f\"Failed to send cancellation notification for request {request_id}\")\n    \n    raise McpError(\n        ErrorData(\n            code=httpx.codes.REQUEST_TIMEOUT,\n            message=(\n                f\"Timed out while waiting for response to \"\n                f\"{request.__class__.__name__}. Waited \"\n                f\"{timeout} seconds.\"\n            ),\n        )\n    )\n```\n\n## Required Changes\n\n1. **Core Implementation**: Update `BaseSession.send_request()` in `src/mcp/shared/session.py`\n2. **Import Addition**: Add necessary imports for `CancelledNotification` and `CancelledNotificationParams`\n\n## Files to Modify\n\n- `src/mcp/shared/session.py` (primary fix)\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-09T21:50:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1458/python-sdk/issues/1458"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:9d8d184a-204e-dccf-c598-023a073004c6
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD3B4:214886:289943:37713B:6A5A5E64
html-safe-nonce95ceea410d6b3b7fbd398200a4d3b409c2e01298a6596828d3bb7f4b2f97b543
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0I0OjIxNDg4NjoyODk5NDM6Mzc3MTNCOjZBNUE1RTY0IiwidmlzaXRvcl9pZCI6IjkxNzU3NDczMDY2NjIyODg5OTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac0f333292baf9983ce2806823db63f68e03ef472ac2686242b0399402c1fb25e0
hovercard-subject-tagissue:3500724105
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/1458/issue_layout
twitter:imagehttps://opengraph.githubassets.com/0a20a787d54e262c2cafdfb00a968813b9cbb2d5397e60c302997840eb13d00e/modelcontextprotocol/python-sdk/issues/1458
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/0a20a787d54e262c2cafdfb00a968813b9cbb2d5397e60c302997840eb13d00e/modelcontextprotocol/python-sdk/issues/1458
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
None05b9ddf6a47d2dbe13944873a99f5fb4b83ba4871f9cb8a8e256793a63ca9687
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
releasef8d29d1bd03dda2dd14b3f80b8bc27e1111f43bd
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/1458#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F1458
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%2F1458
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/1458
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/1458
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/1458
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/issues/1458
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 256 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 Implementation Gap-17: Missing Cancellation Notifications on Request Timeouthttps://github.com/modelcontextprotocol/python-sdk/issues/1458#top
https://github.com/younaman
younamanhttps://github.com/younaman
on Oct 9, 2025https://github.com/modelcontextprotocol/python-sdk/issues/1458#issue-3500724105
https://github.com/modelcontextprotocol/python-sdk/issueshttps://github.com/modelcontextprotocol/python-sdk/issues
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.