René's URL Explorer Experiment


Title: fix: return INVALID_PARAMS (-32602) for resource-not-found errors by leoneperdigao · Pull Request #2325 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: fix: return INVALID_PARAMS (-32602) for resource-not-found errors by leoneperdigao · Pull Request #2325 · modelcontextprotocol/python-sdk

X Title: fix: return INVALID_PARAMS (-32602) for resource-not-found errors by leoneperdigao · Pull Request #2325 · modelcontextprotocol/python-sdk

Description: Summary Fix read_resource() to raise MCPError(code=INVALID_PARAMS) instead of ResourceError, so resource-not-found errors return -32602 instead of 0 Aligns with the TypeScript SDK behavior and emerging spec consensus (modelcontextprotocol#1545) Adds regression test verifying the error code for both unknown resources and resource read failures Root cause ResourceError extends MCPServerError which extends Exception, it is not an MCPError. When the low-level server's request handler catches it, it falls into the generic except Exception branch which returns ErrorData(code=0, ...). The fix raises MCPError directly at the protocol boundary in read_resource(), following the same pattern used elsewhere in the codebase (validation errors, session errors, UrlElicitationRequiredError). Test plan New test test_1579_resource_error_code.py verifies error code is -32602 for unknown resources and read failures Updated test_141_resource_templates.py to catch MCPError instead of ResourceError All 364 existing tests pass with no regressions Closes #1579

Open Graph Description: Summary Fix read_resource() to raise MCPError(code=INVALID_PARAMS) instead of ResourceError, so resource-not-found errors return -32602 instead of 0 Aligns with the TypeScript SDK behavior and eme...

X Description: Summary Fix read_resource() to raise MCPError(code=INVALID_PARAMS) instead of ResourceError, so resource-not-found errors return -32602 instead of 0 Aligns with the TypeScript SDK behavior and eme...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/2325

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:d59ca8b9-d8cf-00c7-7941-4ce554171a5a
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9244:61DF9:1EAF7FE:2C43D0E:6A58D965
html-safe-nonce60b56ba4b11eb641afe346b4ace2603579d6a16bb95e114c5caa1ce9090a1756
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MjQ0OjYxREY5OjFFQUY3RkU6MkM0M0QwRTo2QTU4RDk2NSIsInZpc2l0b3JfaWQiOiI2MzQ3NjM4OTI0MjQ5NzE3MDkzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac88f4d9f924b47bd2294c35d5faf8e30e15149c225f93dca3ac9f4dadd5748152
hovercard-subject-tagpull_request:3428169671
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/2325/files
twitter:imagehttps://avatars.githubusercontent.com/u/8030485?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/8030485?s=400&v=4
og:image:altSummary Fix read_resource() to raise MCPError(code=INVALID_PARAMS) instead of ResourceError, so resource-not-found errors return -32602 instead of 0 Aligns with the TypeScript SDK behavior and eme...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6
turbo-cache-controlno-preview
diff-viewunified
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 full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8aae7b8d6caacacf5c66eaeb2702d8dc88d85b4a
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/pull/2325/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F2325%2Ffiles
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%2Fpull%2F2325%2Ffiles
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%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2325/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2325/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2325/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2325/files
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 290 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
Sign up for GitHub https://github.com/signup?return_to=%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2Fnew%2Fchoose
leoneperdigaohttps://github.com/leoneperdigao
modelcontextprotocol:mainhttps://github.com/modelcontextprotocol/python-sdk/tree/main
leoneperdigao:fix/resource-error-code-1579https://github.com/leoneperdigao/python-sdk/tree/fix/resource-error-code-1579
Conversation 1 https://github.com/modelcontextprotocol/python-sdk/pull/2325
Commits 2 https://github.com/modelcontextprotocol/python-sdk/pull/2325/commits
Checks 26 https://github.com/modelcontextprotocol/python-sdk/pull/2325/checks
Files changed https://github.com/modelcontextprotocol/python-sdk/pull/2325/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2325/files
fix: return INVALID_PARAMS (-32602) for resource-not-found errors https://github.com/modelcontextprotocol/python-sdk/pull/2325/files#top
Show all changes 2 commits https://github.com/modelcontextprotocol/python-sdk/pull/2325/files
4f5cb28 fix: return INVALID_PARAMS (-32602) error code for resource-not-found leoneperdigao Mar 21, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2325/commits/4f5cb2888ae68d79b80a8ff498350522b9b5013c
4e8666a fix: remove unused resource to satisfy 100% coverage requirement leoneperdigao Mar 21, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2325/commits/4e8666a38ca66cf447e250dd2afa00d42d1b86f0
Clear filters https://github.com/modelcontextprotocol/python-sdk/pull/2325/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2325/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2325/files
server.py https://github.com/modelcontextprotocol/python-sdk/pull/2325/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
test_141_resource_templates.py https://github.com/modelcontextprotocol/python-sdk/pull/2325/files#diff-045ed4cd08494a48b9629af457dcfd79eba43786c41e5178b64f38508d48e77f
test_1579_resource_error_code.py https://github.com/modelcontextprotocol/python-sdk/pull/2325/files#diff-8c67de26171ba034da19959466ed7aa55d1d8bf2110240a2d1be282c05437b0a
src/mcp/server/mcpserver/server.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2325/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
View file https://github.com/leoneperdigao/python-sdk/blob/4e8666a38ca66cf447e250dd2afa00d42d1b86f0/src/mcp/server/mcpserver/server.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2325/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2325/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
https://github.com/modelcontextprotocol/python-sdk/pull/2325/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
https://github.com/modelcontextprotocol/python-sdk/pull/2325/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
https://github.com/modelcontextprotocol/python-sdk/pull/2325/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
https://github.com/modelcontextprotocol/python-sdk/pull/2325/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
tests/issues/test_141_resource_templates.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2325/files#diff-045ed4cd08494a48b9629af457dcfd79eba43786c41e5178b64f38508d48e77f
View file https://github.com/leoneperdigao/python-sdk/blob/4e8666a38ca66cf447e250dd2afa00d42d1b86f0/tests/issues/test_141_resource_templates.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2325/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2325/files#diff-045ed4cd08494a48b9629af457dcfd79eba43786c41e5178b64f38508d48e77f
https://github.com/modelcontextprotocol/python-sdk/pull/2325/files#diff-045ed4cd08494a48b9629af457dcfd79eba43786c41e5178b64f38508d48e77f
https://github.com/modelcontextprotocol/python-sdk/pull/2325/files#diff-045ed4cd08494a48b9629af457dcfd79eba43786c41e5178b64f38508d48e77f
https://github.com/modelcontextprotocol/python-sdk/pull/2325/files#diff-045ed4cd08494a48b9629af457dcfd79eba43786c41e5178b64f38508d48e77f
tests/issues/test_1579_resource_error_code.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2325/files#diff-8c67de26171ba034da19959466ed7aa55d1d8bf2110240a2d1be282c05437b0a
View file https://github.com/leoneperdigao/python-sdk/blob/4e8666a38ca66cf447e250dd2afa00d42d1b86f0/tests/issues/test_1579_resource_error_code.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2325/{{ revealButtonHref }}
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2325/files
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.