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 #
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
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:1c1c3e47-0531-4b97-22a5-0e492efe811c |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B6D0:3424AE:DA70AF:1231020:6A5B5FB2 |
| html-safe-nonce | 39983c10d4c466ad11730b0e2c4b5076a92a8f2b36c5317408c26659f2fc8202 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkQwOjM0MjRBRTpEQTcwQUY6MTIzMTAyMDo2QTVCNUZCMiIsInZpc2l0b3JfaWQiOiIyNzA4NTU4OTk2MDA5ODY5MjM0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | de8cac283dbad9c831bcc8a7d7d413a513e3e65534ceb2f3a02719b17fde58e0 |
| hovercard-subject-tag | pull_request:3701708568 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/2630/files |
| twitter:image | https://avatars.githubusercontent.com/u/152802887?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/152802887?s=400&v=4 |
| og:image:alt | 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... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width