fix(mcp): invalidate stale credentials before re-authentication#29521
Open
lexlian wants to merge 1 commit into
Open
fix(mcp): invalidate stale credentials before re-authentication#29521lexlian wants to merge 1 commit into
lexlian wants to merge 1 commit into
Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: The search found one potentially related PR: Related PR: This PR addresses OAuth flow and authentication handling, which is related to your fix about invalidating stale credentials before re-authentication. It may be worth checking if it's already merged or if there's any overlap in the authentication logic being modified. |
1 task
Before starting a new OAuth flow, remove any stored tokens so the MCP SDK triggers a fresh authorization rather than reusing stale credentials from a previous account or API key. This breaks the needs_auth loop where stale tokens exist but belong to a different account. Fixes anomalyco#29227
b687609 to
de6e48e
Compare
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.
Issue for this PR
Closes #29227
Type of change
What does this PR do?
startAuth()was not clearing stored credentials before starting a new OAuth flow. When tokens existed inmcp-auth.jsonfor a previous account,McpOAuthProvider.tokens()returned them and the SDK used them — the server rejected them and returnedneeds_auth. Since the tokens were never removed, the cycle repeated on every re-auth attempt.The fix removes stored credentials at the start of
startAuth()so the SDK triggers a fresh OAuth flow.How did you verify your code works?
bun typecheckin packages/opencode — cleanbun test --grep mcp— all 12 tests passChecklist