Skip to content

MCP OAuth: opencode mcp auth doesn't refresh token in active sessions #21702

Closed as not planned

Description

@duke8253

Description

After re-authenticating an OAuth MCP server with opencode mcp auth , the new token is written to disk but the running MCP connection still uses the stale one.

opencode mcp debug confirms: shows authenticated with a valid token and future expiry, but the HTTP connection test returns 401 Unauthorized. The only workaround is restarting opencode entirely.

Expected: opencode mcp auth should refresh the active MCP connection with the new token, or there should be an opencode mcp reconnect command to re-establish the connection.

Plugins

none

OpenCode version

1.4.1

Steps to reproduce

  1. Connect to an OAuth-enabled MCP server (Streamable HTTP transport)
  2. Wait for the token to expire or be invalidated server-side
  3. Run opencode mcp auth <server> — completes successfully
  4. MCP calls still fail with auth errors
  5. opencode mcp debug <server> shows valid token but 401 on test

Screenshot and/or share link

No response

Operating System

macos 26.4

Terminal

iTerm2

Activity

  1. github-actions commented on Apr 9, 2026

    @github-actions
    Contributor

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

    If your issue is specifically about the running session not picking up a newly written token (stale in-memory connection), it may be distinct from these — but please review to confirm.

  2. duke8253 commented on Apr 9, 2026

    @duke8253
    Author

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

    If your issue is specifically about the running session not picking up a newly written token (stale in-memory connection), it may be distinct from these — but please review to confirm.

    It's not a duplicate of any of them.

    In my case, the authentication succeeds without any problems, meaning it opens a browser and all checks are fine. But after the authentication, opencode still can't fetch anything through the mcp server, and I had to close the process to do a full restart of opencode.

  3. aks24k commented on Apr 22, 2026

    @aks24k

    Having same problem for JIRA mcp.

  4. removed
    bugSomething isn't working
    on May 3, 2026
  5. added a commit that references this issue on May 12, 2026
    9f552c1
  6. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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