Remote MCP OAuth tokens never refreshed; restart loses auth state
What happens
- A remote MCP server (IBKR
mcp-public, OAuth via browser flow) works right after activation, then starts failing minutes later with 401 after successful authentication on every endpoint — snapshots, search, everything.
- Restarting opencode flips the server back to
needs_auth on its own.
- Re-authenticating does not reliably revive the running session.
Evidence from my machine (Windows, global opencode.jsonc, type: remote, no custom headers)
~/.local/share/opencode/mcp-auth.json holds the entry with dynamically registered clientInfo, serverUrl, and a tokens object containing accessToken, refreshToken, expiresAt, scope. So both tokens persist — the refresh just never fires.
- Stored access-token lifetimes are on the order of tens of minutes, so any session longer than that hits this wall.
- Same IBKR sessions stay alive fine when driven from other MCP clients, so this is the client's refresh handling, not the authorization server.
Expected
- Silent
refresh_token grant before expiry; running session picks up the rotated token without re-auth or restart.
Related (same symptom family)
Happy to pull redacted mcp debug output if useful — token values stay with me.
Remote MCP OAuth tokens never refreshed; restart loses auth state
What happens
mcp-public, OAuth via browser flow) works right after activation, then starts failing minutes later with401 after successful authenticationon every endpoint — snapshots, search, everything.needs_authon its own.Evidence from my machine (Windows, global
opencode.jsonc,type: remote, no custom headers)~/.local/share/opencode/mcp-auth.jsonholds the entry with dynamically registeredclientInfo,serverUrl, and atokensobject containingaccessToken,refreshToken,expiresAt,scope. So both tokens persist — the refresh just never fires.Expected
refresh_tokengrant before expiry; running session picks up the rotated token without re-auth or restart.Related (same symptom family)
Happy to pull redacted
mcp debugoutput if useful — token values stay with me.