GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(mcp): invalidate stale credentials before re-authentication by lexlian · Pull Request #29521 · anomalyco/opencode

Conversation

@lexlian

@lexlian lexlian commented May 27, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #29227

Type of change

  • Bug fix

What does this PR do?

startAuth() was not clearing stored credentials before starting a new OAuth flow. When tokens existed in mcp-auth.json for a previous account, McpOAuthProvider.tokens() returned them and the SDK used them — the server rejected them and returned needs_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 typecheck in packages/opencode — clean
  • bun test --grep mcp — all 12 tests pass

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions

github-actions Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

The search found one potentially related PR:

Related PR:

  • #26236: fix: force OAuth flow when server accepts unauthenticated connections

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lexlian lexlian mentioned this pull request May 27, 2026
Unexpected status: needs_auth when trying to authenticate MCP after changing account (already authenticated) #29227
Closed
@Arcadi4 Arcadi4 mentioned this pull request May 27, 2026
[FEATURE]: Full MCP client capabilities #28567
Closed
1 task done
@lexlian
fix(mcp): invalidate stale credentials before re-authentication
de6e48e
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
@lexlian
lexlian force-pushed the fix/mcp-auth-clean branch from b687609 to de6e48e Compare June 1, 2026 05:24
@rekram1-node rekram1-node mentioned this pull request Jun 24, 2026
fix(mcp): refresh credentials on reauthentication #33717
Merged
@rekram1-node

rekram1-node commented Jun 27, 2026

Copy link
Copy Markdown
Member

fixed by separate pr, thanks for pr tho

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rekram1-node rekram1-node closed this Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Unexpected status: needs_auth when trying to authenticate MCP after changing account (already authenticated)

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@lexlian @rekram1-node
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.