René's URL Explorer Experiment


Title: [v1.x] Validate the authorization server metadata issuer on every discovery path by maxisbey · Pull Request #3431 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: [v1.x] Validate the authorization server metadata issuer on every discovery path by maxisbey · Pull Request #3431 · modelcontextprotocol/python-sdk

X Title: [v1.x] Validate the authorization server metadata issuer on every discovery path by maxisbey · Pull Request #3431 · modelcontextprotocol/python-sdk

Description: v1.x backport of #3398 and #3435. The OAuth client on 1.x now decides which issuer it expects before it fetches any authorization server metadata and checks what follows against that one value: the metadata's issuer (RFC 8414 section 3.3), which 1.x did not check on any path; the binding of stored client credentials to the authorization server they were registered with, which 1.x did not have; and a 403 scope step-up that goes through the same discovery when no metadata is held. The two machine-to-machine providers gain the optional issuer= keyword. Motivation and Context Same as #3398. On 1.x the client accepted authorization server metadata without comparing its issuer to the URL the well-known was built from, and stored client_id/client_secret carried no record of which server issued them, so they were presented to whichever authorization server the resource advertised next (or, on the 2025-03-26 fallback, to the resource server's own origin). This brings the 1.x client to the behaviour main has: the expected issuer is the PRM-advertised server, or on the no-PRM path the resource server's origin; metadata that names anything else is refused (a root issuer with and without its trailing slash is the same server); a registration bound to a different issuer is dropped, together with its tokens, before any metadata is fetched, and the client re-registers; newly registered clients are bound to the expected issuer; a 403 insufficient_scope with no metadata held discovers first; a 5xx/429 on the resource metadata request with no location answering stops the flow; and ClientCredentialsOAuthProvider / PrivateKeyJWTOAuthProvider accept issuer= so pre-provisioned credentials only go to that server. Because 1.x had no credential binding, this also carries the parts of #2921, #2933, #2936, #2946 and #3181 that the change relies on: OAuthClientInformationFull.issuer (recorded by the SDK, never read from a registration response), validate_metadata_issuer, credentials_match_issuer and issuers_match in mcp.client.auth.utils, and the registration step recording the issuer. Differences from #3398: RFC 9207 iss validation is not included; the callback contract on 1.x stays tuple[str, str | None]. 1.x has no SEP-2350 scope union, so a step-up asks for the challenged scope as before. Every parsed issuer renders with a trailing slash on 1.x, so the root-slash allowance lives in validate_metadata_issuer itself (new here) rather than only on the legacy path, and recorded issuers carry the slash. The issuer= keyword follows scopes (the 1.x name); there is no docs page for these providers on 1.x, so the docstrings carry the description. #3435's deprecation of constructing the two providers without issuer= is included as a third commit; 1.x has no MCPDeprecationWarning, so it warns with DeprecationWarning like the other deprecations on this branch, and the note lives in the docstrings (1.x has no deprecations docs page). The conformance harness pinned on 1.x (0.1.13) serves, in auth/metadata-var2 and auth/metadata-var3, authorization server metadata whose issuer omits the tenant path its resource metadata advertises, so a client that checks RFC 8414 section 3.3 refuses it. Those two scenarios are listed in expected-failures.yml with that note; the mock includes the path from conformance 0.1.15 (modelcontextprotocol/conformance#152), so the entries go when the pin moves past it. (Bumping the pin here instead would trade them for two unrelated baseline entries, so that is left for its own change.) How Has This Been Tested? New tests in tests/client/test_auth.py and tests/client/auth/extensions/test_client_credentials.py, ported from #3398 and from main's credential-binding suite: issuer check on the PRM and legacy paths, root-slash tolerance and its limits, binding kept/discarded/stamped/not-stamped cases, registration responses cannot seed the binding, legacy path with no metadata (from a 401 and from a 403), step-up with and without metadata held, non-challenge 403, PRM 5xx/429, issuer= on both providers. The flow tests were checked to fail against v1.x's oauth2.py with the new helpers in place (they import functions 1.x did not have, so the plain "restore src/" recipe cannot collect them). I also drove the 1.x provider through httpx.AsyncClient(auth=...) and streamablehttp_client against local test servers for the PRM and legacy paths, 401-first and 403-first, and client-credentials with and without issuer=. Full suite, coverage, pyright and ruff pass locally. Breaking Changes No API removals or signature changes; additions are the optional issuer= keyword, the optional OAuthClientInformationFull.issuer field (round-trips through the unchanged TokenStorage methods; the server side does not emit it), and three functions in mcp.client.auth.utils. Observable differences: Authorization server metadata whose issuer is not the advertised server (or, without protected resource metadata, the resource server's origin) now gets OAuthFlowError: Authorization server metadata issuer mismatch. No client-side override, as on main. Stored credentials the SDK registers from now on carry an issuer; when the resource later names a different authorization server they are discarded and the client re-registers (one extra POST /register). Records stored by earlier 1.x releases carry no issuer and are left as they are. A scope step-up performs discovery first when no metadata is held; a 403 without insufficient_scope is no longer retried. When no protected resource metadata location answers and one returned a 5xx or 429, the flow raises instead of taking the legacy path. An issuer member in a dynamic client registration response is ignored. Types of changes Bug fix (non-breaking change which fixes an issue) New feature (non-breaking change which adds functionality) Breaking change (fix or feature that would cause existing functionality to change) Documentation update Checklist I am assigned to the linked issue (or it is labeled help wanted, or I'm a maintainer) I have disclosed any AI assistance and can explain the change in my own words I have read the MCP Documentation My code follows the repository's style guidelines New and existing tests pass locally I have added appropriate error handling I have added or updated documentation as needed Additional context Three commits: the discovery change (with the binding layer it needs on 1.x), the issuer= keyword, then its deprecation-when-omitted from #3435. The discovery block in async_auth_flow is re-indented under one new condition; the whitespace-insensitive view is the easier read. AI Disclaimer

Open Graph Description: v1.x backport of #3398 and #3435. The OAuth client on 1.x now decides which issuer it expects before it fetches any authorization server metadata and checks what follows against that one value: the...

X Description: v1.x backport of #3398 and #3435. The OAuth client on 1.x now decides which issuer it expects before it fetches any authorization server metadata and checks what follows against that one value: the...

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

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:1d72b8ac-2c64-7afc-7b38-55d5f396b0cc
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC0A8:364B55:10F1F8:169554:6B00BB3F
html-safe-nonce43711740817122c073302fb49e159353fe3be62e70494e1894ed8e7ab3e183bd
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMEE4OjM2NEI1NToxMEYxRjg6MTY5NTU0OjZCMDBCQjNGIiwidmlzaXRvcl9pZCI6IjIyMDk5NzM3NzQ2ODQ1NjgzODMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac728cf14a59ea7220e8081177298c435dee7aac78c647c2558e09a7a950ac3f1e
hovercard-subject-tagpull_request:4424317086
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/3431/files
twitter:imagehttps://avatars.githubusercontent.com/u/224885523?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/224885523?s=400&v=4
og:image:altv1.x backport of #3398 and #3435. The OAuth client on 1.x now decides which issuer it expects before it fetches any authorization server metadata and checks what follows against that one value: the...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None1d07c25977adfc5ff6acb0a962a9bc168c07afbda6fef765f9761c350c2ae4a2
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
release5429cbfc6aca8c7b9a086a3c8f47400346f38cc9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/pull/3431/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F3431%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F3431%2Ffiles
Sign uphttps://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/3431/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3431/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3431/files
modelcontextprotocolhttps://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Codehttps://github.com/modelcontextprotocol/python-sdk
Issues308 (308)https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests112 (112)https://github.com/modelcontextprotocol/python-sdk/pulls
Actionshttps://github.com/modelcontextprotocol/python-sdk/actions
Projectshttps://github.com/modelcontextprotocol/python-sdk/projects
Security and quality12 (12)https://github.com/modelcontextprotocol/python-sdk/security
Insightshttps://github.com/modelcontextprotocol/python-sdk/insights
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
maxisbeyhttps://github.com/maxisbey
v1.xhttps://github.com/modelcontextprotocol/python-sdk/tree/v1.x
oauth-issuer-binding-v1xhttps://github.com/modelcontextprotocol/python-sdk/tree/oauth-issuer-binding-v1x
Conversation 33 https://github.com/modelcontextprotocol/python-sdk/pull/3431
Commits 3 https://github.com/modelcontextprotocol/python-sdk/pull/3431/commits
Checks 30 https://github.com/modelcontextprotocol/python-sdk/pull/3431/checks
Files changed https://github.com/modelcontextprotocol/python-sdk/pull/3431/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3431/files
[v1.x] Validate the authorization server metadata issuer on every discovery path https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#top
Show all changes 3 commits https://github.com/modelcontextprotocol/python-sdk/pull/3431/files
5717fa2 [v1.x] Derive the expected issuer before fetching authorization serve… maxisbey Sep 2, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/3431/commits/5717fa285eb4e0c38c210c32beb9f3a42ff4807f
e5b6719 [v1.x] Let pre-provisioned OAuth clients name their authorization server maxisbey Sep 2, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/3431/commits/e5b671994da96010ad41b7925cd81e8da24c2a5d
3900bb2 [v1.x] Deprecate constructing the pre-provisioned OAuth clients witho… maxisbey Sep 4, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/3431/commits/3900bb275b8cbe004d1033a785fac4a626413cd5
Clear filters https://github.com/modelcontextprotocol/python-sdk/pull/3431/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3431/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3431/files
expected-failures.yml https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-9554cfe66b53ce3771454545473fbd08be68a3c6ecdd0f837273a3e41e6b67d7
client_credentials.py https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
oauth2.py https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-b7aaf2062da175cea9a532176d6eb78b659eaadb757cc48929f0bafccfdb8d98
utils.py https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-1aed3def34492fb7eafa6e7aee6e9cc9973171b28c9574dc5c5b288a09878996
auth.py https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-01350058961f3196e3373d707e2178962377dc9a85f481ade94e8f05e4701c8d
test_client_credentials.py https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-c84aa56739a1205229f9ca6a502589d65984e9461e55324c600702a40f28986f
test_auth.py https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-f083d075f463e8b1ecfa6b931c33288c3d09b00ee3af3e5f74df16b7e75c3ab1
.github/actions/conformance/expected-failures.ymlhttps://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-9554cfe66b53ce3771454545473fbd08be68a3c6ecdd0f837273a3e41e6b67d7
View file https://github.com/modelcontextprotocol/python-sdk/blob/3900bb275b8cbe004d1033a785fac4a626413cd5/.github/actions/conformance/expected-failures.yml
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3431/{{ revealButtonHref }}
src/mcp/client/auth/extensions/client_credentials.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
View file https://github.com/modelcontextprotocol/python-sdk/blob/3900bb275b8cbe004d1033a785fac4a626413cd5/src/mcp/client/auth/extensions/client_credentials.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3431/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3431/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3431/files
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3431/files
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3431/files
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
https://github.com/modelcontextprotocol/python-sdk/pull/3431/files#diff-6837d10b5e4119fce79b4c19036beeebb72e274519503c921453ce4309f8c2c9
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3431/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3431/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.