You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MCP OAuth refresh races across concurrent expired requests #34074
When several MCP tool calls run in parallel and the OAuth access token has expired, each request independently runs the refresh-token grant with the same stored refresh token. Because the authorization server rotates refresh tokens, one refresh succeeds and the others fail with invalid_grant. The SDK then invalidates the stored credentials, so the MCP server drops to needs_auth and a manual opencode mcp auth <server> is required.
Same race that #28234 fixed for the Codex OAuth provider, but in the MCP Streamable HTTP transport. Related symptom: #21702. Surfaced while fixing #34034 (configured scopes are needed for the AS to issue a refresh token in the first place).
Plugins
No response
OpenCode version
dev
Steps to reproduce
Configure a remote OAuth MCP server (Streamable HTTP) whose scope includes offline_access so a refresh token is stored.
Let the access token expire (~15 min).
In one turn, trigger several MCP tool calls at once.
Some calls return Unauthorized; mcp-auth.json loses its refreshToken; the server drops to needs_auth.
Expected: concurrent expired requests share a single refresh instead of each refreshing and racing the rotating token.
Activity
github-actions commentedon Aug 26, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.