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 — Unexpected status: needs_auth when trying to authenticate MCP after changing account (already authenticated) · Issue #29227 · anomalyco/opencode

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

New issue
Copy link
New issue
Copy link
Closed
#33717
Closed
Unexpected status: needs_auth when trying to authenticate MCP after changing account (already authenticated)#29227
#33717
Copy link
Assignees
jlongster

Description

@leobrqz
leobrqz
opened on May 25, 2026
Issue body actions

Description

Context:
A couple people share the same computer, each use their own opencode account. Today, i changed the GO(zen) token to my account, and suddendly the MCP asked for authentication. I did the usual flow opencode mcp auth xxx, it opened the browser, i accepted, but it returned Unexpected status: needs_auth - when i do the same auth command again, it says valid credentials were found and asks if i want to reuse them, saying yes doesn't authenticate, opening opencode just shows the mcp needs auth and it's disabled.

I've tried clearing .config/opencode + .cache/opencode and .share/opencode

I've also removed the bearer token from opencode.json inside the project repo, and tried the key oauth and enabled, neither worked.

And i completely removed opencode.json and tried making it again, no luck.

This is the first time this happens.

Plugins

No response

OpenCode version

1.15.10

Steps to reproduce

  1. /provider, change api key
  2. refresh window
  3. opencode asks for mcp auth
  4. do opencode mcp auth xxxx
    Either:
    5.1. Valid credentials found
    5.2. Browser opens
  5. error appears either way

Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

Bash

Activity

  1. github-actions
    assigned
    jlongster
    on May 25, 2026
  2. github-actions commented on May 25, 2026

    @github-actions
    github-actionsBot
    on May 25, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue might be a duplicate of existing issues. Please check:

    • MCP OAuth: opencode mcp auth doesn't refresh token in active sessions #21702: MCP OAuth auth completes successfully but the active connection still uses stale credentials — MCP continues to show as needing auth until opencode is restarted
    • MCP OAuth flow fails before opening the browser #28741: MCP OAuth flow fails (browser never opens / auth returns unexpected status) in a similar re-authentication scenario

    If your issue is distinct from these, please add a note clarifying how it differs.

  3. leobrqz commented on May 25, 2026

    @leobrqz
    leobrqz
    on May 25, 2026
    Author
    More actions

    Not quite duplicate, similar, but not exactly duplicate, similar to #21702

    It's the supabase MCP.

  4. lexlian commented on May 27, 2026

    @lexlian
    lexlian
    on May 27, 2026
    More actions

    I created a PR #29521 to fix this.

    Root cause

    startAuth() in packages/opencode/src/mcp/index.ts did not clear stored credentials before starting a new OAuth flow. When a user changed their API key and ran opencode mcp auth servername, McpOAuthProvider.tokens() returned the old tokens from mcp-auth.json. The SDK tried to use them, the server rejected them, and needs_auth was returned — but the tokens were never removed, so the cycle repeated on every subsequent auth attempt.

    Fix

    Added auth.remove(mcpName) and pendingOAuthTransports.delete(mcpName) at the start of startAuth() to invalidate stale credentials before the OAuth flow begins. This ensures the SDK triggers a fresh authorization rather than reusing tokens from a previous account.

    Reacted by Leonardo Briquezi
  5. lexlian
    added a commit that references this issue on Jun 1, 2026

    fix(mcp): invalidate stale credentials before re-authentication

    This issue will close once commit de6e48e is merged into the 'dev' branch.
    de6e48e
  6. rekram1-node
    closed this as completedin #33717on Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @jlongster
    jlongster

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    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.