René's URL Explorer Experiment


Title: fix(auth): validate redirect_uri schemes at DCR registration (RFC 9700 §4.1.1, RFC 7591 §2) by CrypticCortex · Pull Request #2630 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: fix(auth): validate redirect_uri schemes at DCR registration (RFC 9700 §4.1.1, RFC 7591 §2) by CrypticCortex · Pull Request #2630 · modelcontextprotocol/python-sdk

X Title: fix(auth): validate redirect_uri schemes at DCR registration (RFC 9700 §4.1.1, RFC 7591 §2) by CrypticCortex · Pull Request #2630 · modelcontextprotocol/python-sdk

Description: Closes #2629. Summary Adds validate_registered_redirect_uri(url: AnyUrl) and wires it into RegistrationHandler.handle so each submitted redirect_uri is validated immediately after model_validate_json succeeds. On failure, returns 400 invalid_redirect_uri per RFC 7591 §3.2.2. The helper mirrors the existing validate_issuer_url policy: https is allowed. http is allowed only for loopback hosts (localhost, 127.0.0.1, [::1]) per RFC 8252 §7.3. Fragments are rejected per RFC 7591 §2 — including empty trailing-# fragments. Query strings are permitted (explicitly allowed by RFC 7591 §2). The helper lives in a new mcp.server.auth._redirect_uri module to avoid a circular import with handlers.register (the existing mcp.server.auth.routes re-exports it so the public import path stays stable). Why now OAuthClientMetadata.redirect_uris is typed list[AnyUrl], which Pydantic accepts for any well-formed URL — including javascript:, data:, file:, vbscript:, ftp:, cleartext http:// to non-loopback hosts, and https://...#. The handler stores those values verbatim and authorize-time validation accepts them by exact match. Issue # has the full reproduction. Tests tests/server/auth/test_routes.py: 13 unit tests covering each accept/reject path of the new helper, mirroring the existing test_validate_issuer_url_* cases (includes an explicit empty-fragment test). tests/server/auth/test_error_handling.py: 5 end-to-end tests posting against /register — three rejection cases (javascript:, cleartext-http://, fragment) and two acceptance cases (HTTPS, loopback HTTP). Local: ./scripts/test green; 1190 passed, 100.00% coverage, strict-no-cover clean. Compatibility No public-API removal. The change tightens what /register accepts; clients submitting non-spec-compliant URIs will now get 400 invalid_redirect_uri where they previously got 201. Existing stored client records are not re-validated. Related Adjacent to #1934 (RFC 8252 loopback port relaxation at authorize-time) — no conflict; touches different code paths. Question raised earlier in #1446 (closed as duplicate). Checks uv run --frozen ruff format . uv run --frozen ruff check . uv run --frozen pyright ./scripts/test — green, 100% coverage, strict-no-cover clean

Open Graph Description: Closes #2629. Summary Adds validate_registered_redirect_uri(url: AnyUrl) and wires it into RegistrationHandler.handle so each submitted redirect_uri is validated immediately after model_validate_js...

X Description: Closes #2629. Summary Adds validate_registered_redirect_uri(url: AnyUrl) and wires it into RegistrationHandler.handle so each submitted redirect_uri is validated immediately after model_validate_js...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:1c1c3e47-0531-4b97-22a5-0e492efe811c
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB6D0:3424AE:DA70AF:1231020:6A5B5FB2
html-safe-nonce39983c10d4c466ad11730b0e2c4b5076a92a8f2b36c5317408c26659f2fc8202
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkQwOjM0MjRBRTpEQTcwQUY6MTIzMTAyMDo2QTVCNUZCMiIsInZpc2l0b3JfaWQiOiIyNzA4NTU4OTk2MDA5ODY5MjM0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacde8cac283dbad9c831bcc8a7d7d413a513e3e65534ceb2f3a02719b17fde58e0
hovercard-subject-tagpull_request:3701708568
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/2630/files
twitter:imagehttps://avatars.githubusercontent.com/u/152802887?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/152802887?s=400&v=4
og:image:altCloses #2629. Summary Adds validate_registered_redirect_uri(url: AnyUrl) and wires it into RegistrationHandler.handle so each submitted redirect_uri is validated immediately after model_validate_js...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b
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
release9c975978430e9ad293956f2bbdaf153b1bd84a99
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/pull/2630/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F2630%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%2F2630%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/2630/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2630/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2630/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2630/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 259 https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests 304 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
CrypticCortexhttps://github.com/CrypticCortex
modelcontextprotocol:mainhttps://github.com/modelcontextprotocol/python-sdk/tree/main
CrypticCortex:dcr-redirect-uri-scheme-validationhttps://github.com/CrypticCortex/python-sdk/tree/dcr-redirect-uri-scheme-validation
Conversation 0 https://github.com/modelcontextprotocol/python-sdk/pull/2630
Commits 3 https://github.com/modelcontextprotocol/python-sdk/pull/2630/commits
Checks 25 https://github.com/modelcontextprotocol/python-sdk/pull/2630/checks
Files changed https://github.com/modelcontextprotocol/python-sdk/pull/2630/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2630/files
fix(auth): validate redirect_uri schemes at DCR registration (RFC 9700 §4.1.1, RFC 7591 §2) https://github.com/modelcontextprotocol/python-sdk/pull/2630/files#top
Show all changes 3 commits https://github.com/modelcontextprotocol/python-sdk/pull/2630/files
3ee84a9 feat(auth): add validate_registered_redirect_uri helper CrypticCortex May 18, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2630/commits/3ee84a96a8ed0fda85f5c06bd1dc93315e12c847
35df944 fix(auth): reject empty-fragment redirect_uri (RFC 7591 §2) CrypticCortex May 18, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2630/commits/35df94476bcc981c4a6c0dee2251eee00ef20ca2
759c9be fix(auth): reject non-spec redirect_uris in DCR handler CrypticCortex May 18, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2630/commits/759c9be25488abe2e052399afccb22841bc0549e
Clear filters https://github.com/modelcontextprotocol/python-sdk/pull/2630/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2630/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2630/files
_redirect_uri.py https://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-4c170cc4c7bef1551df408d689cf1a54b8766d486642a32773a16b2d561b3eb2
register.py https://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-6643f748c6f203d6b3c55593361c894373aa78f360ebaa4f3b60b445efccc5af
routes.py https://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-6dfb076f1d9772b9a78be06b88bbbae0f92a0108284fcf247f342cd1a88433f2
test_error_handling.py https://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-91ee20daa15c8be5663ae23f6ebbc6294ef39fd9f22c8165b93f1b6ed9a415ba
test_routes.py https://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-bc60cb989fbbc80ad7d8060a2d4e94eb842ae941dde869cb293a9bd94c452ba9
src/mcp/server/auth/_redirect_uri.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-4c170cc4c7bef1551df408d689cf1a54b8766d486642a32773a16b2d561b3eb2
View file https://github.com/modelcontextprotocol/python-sdk/blob/759c9be25488abe2e052399afccb22841bc0549e/src/mcp/server/auth/_redirect_uri.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2630/{{ revealButtonHref }}
src/mcp/server/auth/handlers/register.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-6643f748c6f203d6b3c55593361c894373aa78f360ebaa4f3b60b445efccc5af
View file https://github.com/modelcontextprotocol/python-sdk/blob/759c9be25488abe2e052399afccb22841bc0549e/src/mcp/server/auth/handlers/register.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2630/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-6643f748c6f203d6b3c55593361c894373aa78f360ebaa4f3b60b445efccc5af
https://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-6643f748c6f203d6b3c55593361c894373aa78f360ebaa4f3b60b445efccc5af
https://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-6643f748c6f203d6b3c55593361c894373aa78f360ebaa4f3b60b445efccc5af
https://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-6643f748c6f203d6b3c55593361c894373aa78f360ebaa4f3b60b445efccc5af
src/mcp/server/auth/routes.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-6dfb076f1d9772b9a78be06b88bbbae0f92a0108284fcf247f342cd1a88433f2
View file https://github.com/modelcontextprotocol/python-sdk/blob/759c9be25488abe2e052399afccb22841bc0549e/src/mcp/server/auth/routes.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2630/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-6dfb076f1d9772b9a78be06b88bbbae0f92a0108284fcf247f342cd1a88433f2
https://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-6dfb076f1d9772b9a78be06b88bbbae0f92a0108284fcf247f342cd1a88433f2
https://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-6dfb076f1d9772b9a78be06b88bbbae0f92a0108284fcf247f342cd1a88433f2
tests/server/auth/test_error_handling.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-91ee20daa15c8be5663ae23f6ebbc6294ef39fd9f22c8165b93f1b6ed9a415ba
View file https://github.com/modelcontextprotocol/python-sdk/blob/759c9be25488abe2e052399afccb22841bc0549e/tests/server/auth/test_error_handling.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2630/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-91ee20daa15c8be5663ae23f6ebbc6294ef39fd9f22c8165b93f1b6ed9a415ba
tests/server/auth/test_routes.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-bc60cb989fbbc80ad7d8060a2d4e94eb842ae941dde869cb293a9bd94c452ba9
View file https://github.com/modelcontextprotocol/python-sdk/blob/759c9be25488abe2e052399afccb22841bc0549e/tests/server/auth/test_routes.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2630/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-bc60cb989fbbc80ad7d8060a2d4e94eb842ae941dde869cb293a9bd94c452ba9
https://github.com/modelcontextprotocol/python-sdk/pull/2630/files#diff-bc60cb989fbbc80ad7d8060a2d4e94eb842ae941dde869cb293a9bd94c452ba9
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2630/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.