René's URL Explorer Experiment


Title: OAuth token refresh hits the wrong endpoint when the auth server lives under a path · Issue #3240 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: OAuth token refresh hits the wrong endpoint when the auth server lives under a path · Issue #3240 · modelcontextprotocol/python-sdk

X Title: OAuth token refresh hits the wrong endpoint when the auth server lives under a path · Issue #3240 · modelcontextprotocol/python-sdk

Description: Ran into this with a hosted MCP server whose authorization server isn't at the origin root — token endpoint is https://host/oauth2/api/v1/token, not https://host/token. If a client starts up with a cached-but-expired access token (+ refr...

Open Graph Description: Ran into this with a hosted MCP server whose authorization server isn't at the origin root — token endpoint is https://host/oauth2/api/v1/token, not https://host/token. If a client starts up with a...

X Description: Ran into this with a hosted MCP server whose authorization server isn't at the origin root — token endpoint is https://host/oauth2/api/v1/token, not https://host/token. If a client starts up wi...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/3240

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"OAuth token refresh hits the wrong endpoint when the auth server lives under a path","articleBody":"Ran into this with a hosted MCP server whose authorization server isn't at the origin root — token endpoint is `https://host/oauth2/api/v1/token`, not `https://host/token`.\n\nIf a client starts up with a cached-but-expired access token (+ refresh token) and hasn't done discovery yet, `async_auth_flow` refreshes at the very top — before any 401/metadata discovery. So `oauth_metadata is None` and `_refresh_token` uses the fallback `urljoin(get_authorization_base_url(server_url), \"/token\")`, i.e. just `{scheme}://{netloc}/token`. That 404s, `_handle_refresh_response` clears the tokens, and the flow drops to full interactive auth — which a headless/gateway client can't do. So the server silently disconnects every time the access token expires (mine are 5 min, so… constantly).\n\nSame path-stripping fallback is in `_get_token_endpoint`, `_perform_authorization_code_grant` (`/authorize`) and DCR (`/register`) — refresh is just the one that bites silently.\n\nRepro (roughly):\n- MCP server whose AS metadata puts `token_endpoint` under a path, not `{origin}/token`\n- log in normally so tokens get cached\n- let the access token expire (or clear the expiry), reconnect with a fresh provider\n- watch the refresh POST go to `https://host/token` → 404 → \"Token refresh failed\" → tokens cleared → it tries to open a browser\n\nFix looks like: discover metadata before the eager refresh (or stop dropping the issuer path in the fallback). Happy to PR — have a branch that pulls the PRM/ASM discovery out of the 401 branch and runs it before the refresh.\n\n(used some AI help digging into this)","author":{"url":"https://github.com/mfadul24","@type":"Person","name":"mfadul24"},"datePublished":"2026-08-03T12:55:14Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3240"}

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/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:9ce57f7a-35d2-1dbc-f245-5aa5057f9a79
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE0C4:269AD9:1229920:184C351:6B0120A9
html-safe-noncef211c36791c598db4235ad61958c8bd9fa53c4c908bb81d8faa250619c0c2507
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMEM0OjI2OUFEOToxMjI5OTIwOjE4NEMzNTE6NkIwMTIwQTkiLCJ2aXNpdG9yX2lkIjoiMzM4Mjk2MzY4MTQ4NTcyNTg2NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac175daeafab04215c753fb17b009ee6dba265b7ae6255cd94da41352d679fce39
hovercard-subject-tagissue:5049999877
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/3240/issue_layout
twitter:imagehttps://opengraph.githubassets.com/859b1b6e2fcbe24e41cb4e204167652f65ae1811c73916b8a40b985b1787e64b/modelcontextprotocol/python-sdk/issues/3240
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/859b1b6e2fcbe24e41cb4e204167652f65ae1811c73916b8a40b985b1787e64b/modelcontextprotocol/python-sdk/issues/3240
og:image:altRan into this with a hosted MCP server whose authorization server isn't at the origin root — token endpoint is https://host/oauth2/api/v1/token, not https://host/token. If a client starts up with a...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemfadul24
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
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
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/3240#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F3240
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%2Fissues%2F3240
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3240
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3240
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3240
modelcontextprotocolhttps://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Codehttps://github.com/modelcontextprotocol/python-sdk
Issues310 (310)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
https://github.com/modelcontextprotocol/python-sdk
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3240
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3240
#3263https://github.com/modelcontextprotocol/python-sdk/pull/3263
OAuth token refresh hits the wrong endpoint when the auth server lives under a pathhttps://github.com/modelcontextprotocol/python-sdk/issues/3240#top
#3263https://github.com/modelcontextprotocol/python-sdk/pull/3263
P1Significant bug affecting many users, highly requested featurehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P1%22
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
v1Affects the v1.x maintenance linehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v1%22
v2Affects the v2 line (2.x on main)https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
https://github.com/mfadul24
mfadul24https://github.com/mfadul24
on Aug 3, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3240#issue-5049999877
https://github.com/zsxh1990
zsxh1990https://github.com/zsxh1990
on Aug 4, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3240#issuecomment-5173457504
#3093https://github.com/modelcontextprotocol/python-sdk/pull/3093
zsxh1990https://github.com/zsxh1990
on Aug 4, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3240#event-28937327463
fix: skip eager token refresh when OAuth metadata is unavailablehttps://github.com/zsxh1990/python-sdk/commit/ebff43587e2b5d342300086414fa56dc76a35c4b
https://docs.github.com/articles/closing-issues-via-commit-messages
ebff435https://github.com/zsxh1990/python-sdk/commit/ebff43587e2b5d342300086414fa56dc76a35c4b
test: verify eager refresh is skipped when oauth_metadata is Nonehttps://github.com/zsxh1990/python-sdk/commit/0ee7f76a669000926a8b1acc03d3fcf0502e91cf
https://docs.github.com/articles/closing-issues-via-commit-messages
0ee7f76https://github.com/zsxh1990/python-sdk/commit/0ee7f76a669000926a8b1acc03d3fcf0502e91cf
fix: skip eager token refresh when OAuth metadata is unavailablehttps://github.com/zsxh1990/python-sdk/commit/a9d322e259e411b790e276d86dca4425f7fa744a
https://docs.github.com/articles/closing-issues-via-commit-messages
a9d322ehttps://github.com/zsxh1990/python-sdk/commit/a9d322e259e411b790e276d86dca4425f7fa744a
https://github.com/Ecocitizenz
Ecocitizenzhttps://github.com/Ecocitizenz
on Aug 4, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3240#issuecomment-5182496504
maxisbeyhttps://github.com/maxisbey
P1Significant bug affecting many users, highly requested featurehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P1%22
on Aug 12, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3240#event-29354912813
maxisbeyhttps://github.com/maxisbey
on Aug 18, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3240#event-29619254239
OAuth client: refresh before re-authorizing, and discover before refr…https://github.com/modelcontextprotocol/python-sdk/commit/2bc618ab6de57dcb6ae08181d2e40ddd77cdd49a
https://docs.github.com/articles/closing-issues-via-commit-messages
2bc618ahttps://github.com/modelcontextprotocol/python-sdk/commit/2bc618ab6de57dcb6ae08181d2e40ddd77cdd49a
maxisbeyhttps://github.com/maxisbey
v1Affects the v1.x maintenance linehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v1%22
v2Affects the v2 line (2.x on main)https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
on Aug 18, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3240#event-29625154151
claudehttps://github.com/apps/claude
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
on Oct 8, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3240#event-32781074806
https://github.com/zsxh1990
zsxh1990https://github.com/zsxh1990
on Oct 14, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3240#issuecomment-6164713084
#3263https://github.com/modelcontextprotocol/python-sdk/pull/3263
fix(client/auth): discover AS metadata before cold-start token refresh, with issuer-binding check #3263https://github.com/modelcontextprotocol/python-sdk/pull/3263
https://github.com/magnus-longva-bouvet
magnus-longva-bouvethttps://github.com/magnus-longva-bouvet
on Oct 24, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3240#issuecomment-6384026611
mistralai/mistral-vibe#1246https://github.com/mistralai/mistral-vibe/issues/1246
#3263https://github.com/modelcontextprotocol/python-sdk/pull/3263
https://github.com/fernandesemmanuel454-ship-it
fernandesemmanuel454-ship-ithttps://github.com/fernandesemmanuel454-ship-it
on Nov 18, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3240#issuecomment-6992659888
ChatGPT Codex Connectorhttps://www.chatgpt.com
@mfadul24https://github.com/mfadul24
#3263https://github.com/modelcontextprotocol/python-sdk/pull/3263
Sign up for freehttps://github.com/signup?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3240
Sign in to commenthttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3240
P1Significant bug affecting many users, highly requested featurehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P1%22
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
v1Affects the v1.x maintenance linehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v1%22
v2Affects the v2 line (2.x on main)https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
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.