Skip to content

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

@duke8253

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions