fix(workers): use configured OAUTH_TOKEN_URL for proactive refresh - #2
Open
DjWarmonger wants to merge 1 commit into
Open
fix(workers): use configured OAUTH_TOKEN_URL for proactive refresh#2DjWarmonger wants to merge 1 commit into
DjWarmonger wants to merge 1 commit into
Conversation
buildProviderRefreshConfig() in the Workers adapter omitted tokenEndpointPath, so refreshProviderToken() fell back to the default token path and POSTed to the provider accounts host instead of the configured token endpoint. Wire tokenEndpointPath from config.OAUTH_TOKEN_URL so proactive refresh hits the configured endpoint. (The Hono adapter already uses the shared buildProviderRefreshConfig() in src/shared/oauth/refresh.ts, which sets this.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
buildProviderRefreshConfig()in the Workers adapter (src/adapters/http-workers/mcp.handler.ts) returns onlyclientId,clientSecret, andaccountsUrl— it omitstokenEndpointPath. As a result,refreshProviderToken()falls back to the default token path and POSTs proactive refreshes to the provider accounts host instead of the configured token endpoint (OAUTH_TOKEN_URL).For providers whose token endpoint differs from the accounts host (e.g. Linear: accounts on
linear.app, token endpoint onapi.linear.app), proactive refresh hits the wrong host and fails, so provider-token expiry never self-heals and later surfaces as an opaque "Authentication required" error.Fix
Wire
tokenEndpointPathfromconfig.OAUTH_TOKEN_URLin the Workers adapter'sbuildProviderRefreshConfig(), so proactive refresh targets the configured endpoint.The Hono adapter is unaffected — it already uses the shared
buildProviderRefreshConfig()insrc/shared/oauth/refresh.ts, which sets this correctly. This one-line change brings the Workers adapter in line with it.