René's URL Explorer Experiment


Title: Let a token verifier gate the server without AuthSettings by maxisbey · Pull Request #3292 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: Let a token verifier gate the server without AuthSettings by maxisbey · Pull Request #3292 · modelcontextprotocol/python-sdk

X Title: Let a token verifier gate the server without AuthSettings by maxisbey · Pull Request #3292 · modelcontextprotocol/python-sdk

Description: MCPServer(token_verifier=...) no longer requires auth=AuthSettings(...). A verifier on its own is now a plain bearer gate; AuthSettings is what you add to describe that gate to OAuth clients. Motivation and Context Closes #3283 (see also #431, #702). Someone with a pre-shared token and no authorization server anywhere had to write AuthSettings(issuer_url=, resource_server_url=...) just to get past the constructor, and the made-up issuer then got advertised in the RFC 9728 metadata document, which sends OAuth-capable clients off to discover an AS that doesn't exist. In resource-server-only mode issuer_url is never contacted; it's only echoed into that document. The TypeScript and Go SDKs both treat "verifier, metadata optional" as the primitive (requireBearerAuth({verifier}), RequireBearerToken(verifier, nil)); this brings the Python high-level API in line. There was also a low-level inconsistency behind it: Server.streamable_http_app(token_verifier=V) with no auth= was accepted but built an app that 401'd every request, valid token included, because AuthenticationMiddleware(BearerAuthBackend) was installed under if auth: while RequireAuthMiddleware was installed under if token_verifier:. MCPServer refused the same shape with a ValueError, so the two layers disagreed about one state. What changes: lowlevel.Server.streamable_http_app and MCPServer.sse_app: the authentication backend + auth-context middleware are installed whenever a verifier is present. auth layers on required scopes, the metadata route, and the resource_metadata pointer in the 401. Every previously-valid combination produces the same routes (same order), middleware and responses as before. MCPServer.__init__: a bare token_verifier= is accepted. Still refused: auth= with nothing to gate with, auth_server_provider= without auth= (it needs the issuer), and both a provider and a verifier. docs/run/authorization.md: new "Just a pre-shared token" section with a runnable docs_src example (constant-time compare, token from the environment, fails closed when unset), and the "always travel together" wording is corrected. What this deliberately doesn't do: Split the resource-server fields out of AuthSettings (it still mixes embedded-AS config with RS discovery config). That's the principled follow-up and touches shipped 2.x surface; this change is a strict subset of it. Deduplicate the auth wiring between Server.streamable_http_app and MCPServer.sse_app. Change how a TokenVerifier that raises is surfaced (still a 500 from Starlette's AuthenticationMiddleware). At the low level, auth_server_provider without auth is still silently ignored, as before. How Has This Been Tested? New docs tests for the pre-shared-token example (route list, exact 401 challenge, no metadata route, Client round trip with a static header), an interaction test for the low-level verifier-only shape, two sse_app tests (verifier-only, and verifier + settings), and constructor tests for the refused shapes. Three # pragma: no cover markers on the touched wiring/validation come off as a result; the embedded-AS-over-SSE branch keeps its pre-existing one. Driven end to end under uvicorn with curl and the SDK client over both streamable HTTP and SSE: no/wrong token → 401 without resource_metadata, metadata paths → 404, valid token → initialize 200 and whoami returns the verifier's client_id; non-ASCII and malformed Authorization headers → 401. ./scripts/test (100% coverage, strict-no-cover), ruff, pyright, and the strict docs build pass locally. Breaking Changes None. A constructor call that used to raise ValueError now succeeds; everything that worked before behaves identically. Two error messages are reworded (... without auth settings now names only auth_server_provider; ... when auth is enabled → ... with auth settings). 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 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 The spec makes authorization OPTIONAL and only SHOULD for HTTP transports, and basic allows custom authentication strategies, so a pre-shared bearer with no metadata is outside the OAuth profile rather than in violation of it. The docs section says so in practical terms: with nothing to discover, the client has to arrive already holding the token.

Open Graph Description: MCPServer(token_verifier=...) no longer requires auth=AuthSettings(...). A verifier on its own is now a plain bearer gate; AuthSettings is what you add to describe that gate to OAuth clients. Motiv...

X Description: MCPServer(token_verifier=...) no longer requires auth=AuthSettings(...). A verifier on its own is now a plain bearer gate; AuthSettings is what you add to describe that gate to OAuth clients. Motiv...

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

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:682fa8d9-4592-b551-0e41-5376d614d3e7
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idAAB6:BEE52:9F2BC:D214C:6B00B938
html-safe-nonce8ffbe44f672598efe5a139bc3e9d2a626c98f8264f242ed32f1b0e5c90c8c945
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQUI2OkJFRTUyOjlGMkJDOkQyMTRDOjZCMDBCOTM4IiwidmlzaXRvcl9pZCI6Ijg5MTA3ODA0NzQ4NTEzNzU0MTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacf852f637471eba59ee23ab4c8494b1815b4fc84bbb55407e782a5dc496d4988f
hovercard-subject-tagpull_request:4257089537
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/3292/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:altMCPServer(token_verifier=...) no longer requires auth=AuthSettings(...). A verifier on its own is now a plain bearer gate; AuthSettings is what you add to describe that gate to OAuth clients. Motiv...
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/3292/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F3292%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%2F3292%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/3292/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3292/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3292/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
mainhttps://github.com/modelcontextprotocol/python-sdk/tree/main
token-verifier-without-auth-settingshttps://github.com/modelcontextprotocol/python-sdk/tree/token-verifier-without-auth-settings
Conversation 8 https://github.com/modelcontextprotocol/python-sdk/pull/3292
Commits 1 https://github.com/modelcontextprotocol/python-sdk/pull/3292/commits
Checks 40 https://github.com/modelcontextprotocol/python-sdk/pull/3292/checks
Files changed https://github.com/modelcontextprotocol/python-sdk/pull/3292/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3292/files
Let a token verifier gate the server without AuthSettings https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#top
Show all changes 1 commit https://github.com/modelcontextprotocol/python-sdk/pull/3292/files
f94ffd5 Let a token verifier gate the server without AuthSettings maxisbey Aug 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/3292/commits/f94ffd585d6a156ad271c03cf291fa427861af11
Clear filters https://github.com/modelcontextprotocol/python-sdk/pull/3292/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3292/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3292/files
authorization.md https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-47a591f8855d0e6c7629fcfcf8f49471b54858df074ddd11e2f6931dc6de75ca
tutorial003.py https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-b5916507541a13f657c52b8839241034c4cc6990f8b5d90666d6d3fce037482a
server.py https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-b21bf5e21c058ccfddb404c209f2d4288e4f32b121111ffc9d466638631d13e4
server.py https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
test_authorization.py https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-3544daae19d2cf5f421d66ae2e297daa4df4b73b082ccefd1d77d8a10bc5f2e8
_requirements.py https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-c12ce54cbf13a11daa3f93343e5df8c89ca2b25d0f20f00b5408a2402a223228
test_bearer.py https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-39fa737f86bf4beb1870f6befa727071547fb7bd57257244223688eb618bd79f
test_auth_integration.py https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-5a81a6a5148119d275223ade78614223f48f68203d1ef375fb1b271621d5894c
test_server.py https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-c191383f010475fc22bf69d35f14f16d7e45098b05a1a0f03ad66d6c151d1f34
docs/run/authorization.mdhttps://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-47a591f8855d0e6c7629fcfcf8f49471b54858df074ddd11e2f6931dc6de75ca
View file https://github.com/modelcontextprotocol/python-sdk/blob/f94ffd585d6a156ad271c03cf291fa427861af11/docs/run/authorization.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3292/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-47a591f8855d0e6c7629fcfcf8f49471b54858df074ddd11e2f6931dc6de75ca
cubic-dev-aihttps://github.com/apps/cubic-dev-ai
Sep 4, 2026https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#r3935427712
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3292/files
https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-47a591f8855d0e6c7629fcfcf8f49471b54858df074ddd11e2f6931dc6de75ca
https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-47a591f8855d0e6c7629fcfcf8f49471b54858df074ddd11e2f6931dc6de75ca
https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-47a591f8855d0e6c7629fcfcf8f49471b54858df074ddd11e2f6931dc6de75ca
docs_src/authorization/tutorial003.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-b5916507541a13f657c52b8839241034c4cc6990f8b5d90666d6d3fce037482a
View file https://github.com/modelcontextprotocol/python-sdk/blob/f94ffd585d6a156ad271c03cf291fa427861af11/docs_src/authorization/tutorial003.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3292/{{ revealButtonHref }}
src/mcp/server/lowlevel/server.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-b21bf5e21c058ccfddb404c209f2d4288e4f32b121111ffc9d466638631d13e4
View file https://github.com/modelcontextprotocol/python-sdk/blob/f94ffd585d6a156ad271c03cf291fa427861af11/src/mcp/server/lowlevel/server.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3292/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-b21bf5e21c058ccfddb404c209f2d4288e4f32b121111ffc9d466638631d13e4
https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-b21bf5e21c058ccfddb404c209f2d4288e4f32b121111ffc9d466638631d13e4
https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-b21bf5e21c058ccfddb404c209f2d4288e4f32b121111ffc9d466638631d13e4
claudehttps://github.com/apps/claude
Sep 4, 2026https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#r3935481666
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3292/files
claudehttps://github.com/apps/claude
Sep 4, 2026https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#r3935481678
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3292/files
https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-b21bf5e21c058ccfddb404c209f2d4288e4f32b121111ffc9d466638631d13e4
src/mcp/server/mcpserver/server.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
View file https://github.com/modelcontextprotocol/python-sdk/blob/f94ffd585d6a156ad271c03cf291fa427861af11/src/mcp/server/mcpserver/server.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3292/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
cubic-dev-aihttps://github.com/apps/cubic-dev-ai
Sep 4, 2026https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#r3935427683
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3292/files
https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
https://github.com/modelcontextprotocol/python-sdk/pull/3292/files#diff-51d6996c0b80b8a5c42e7071451cb9ed3c91b398facebe99b94aad911059190e
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3292/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3292/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.