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 — V2 MCP OAuth: serialize credential refresh across locations/processes · Issue #34520 · anomalyco/opencode

V2 MCP OAuth: serialize credential refresh across locations/processes #34520

New issue
Copy link
New issue
Copy link
Closed
Closed
V2 MCP OAuth: serialize credential refresh across locations/processes#34520
Copy link
Assignees
rekram1-node
Labels
2.0bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Description

@rekram1-node
rekram1-node
opened on Jun 29, 2026
Issue body actions

Context

Tracking the deferred concurrency hardening for V2 MCP OAuth (packages/core/src/mcp). The initial OAuth implementation deliberately ignores cross-location/cross-process credential refresh races; this issue captures that follow-up.

Problem

MCP OAuth tokens are stored in the global Credential table (credential.ts, makeGlobalNode), while Integration and the MCP service are location-scoped (integration.ts, makeLocationNode). The credential identity for a remote server is keyed by a hash of its (normalized) URL, so two locations using the same server URL share one global credential row.

When that shared token expires, multiple refreshers can run concurrently:

  1. Same process, multiple locations — separate location-scoped MCP/provider instances each decide to refresh the same global row. With rotating refresh tokens, the second refresh invalidates the first, dropping a location into needs_auth.
  2. Separate processes (daemon + CLI, or two servers) — no shared memory, only the shared SQLite DB. Same race, no in-memory coordination available.

Note: V1 had this race too — its file lock only serialized the write, not the decision to refresh.

Proposed direction

  • In-process: a global single-flight keyed by credential id (in the global tier alongside Credential) so concurrent refreshers coalesce onto one result.
  • Cross-process: optimistic compare-and-swap on the credential row — refresh inside a transaction, re-read, and if the stored refresh token already changed, adopt the existing fresh token instead of overwriting.

Out of scope

The base OAuth layer (provider, DCR, interactive authorize, connect-time credential read, reconnect-on-auth) ships without this; refresh works fine in the single-location happy path.

Reacted by Luc Leray

Activity

  1. rekram1-node
    self-assigned this
    on Jun 29, 2026
  2. github-actions commented on Jun 29, 2026

    @github-actions
    github-actionsBot
    on Jun 29, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • The issue does not use one of the three required templates (Bug Report, Feature Request, or Question). Please resubmit using the appropriate template — this appears to be a Bug Report or tracking issue for a known race condition.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


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

    • MCP OAuth refresh races across concurrent expired requests #34074: MCP OAuth refresh races across concurrent expired requests — describes the same rotating-refresh-token race with concurrent MCP tool calls, same root cause, same affected component.
    • MCP OAuth: opencode mcp auth doesn't refresh token in active sessions #21702: MCP OAuth: opencode mcp auth doesn't refresh token in active sessions — related symptom referenced in MCP OAuth refresh races across concurrent expired requests #34074.

    If you believe this was flagged incorrectly, please let a maintainer know.

  3. github-actions
    added
    needs:complianceThis means the issue will auto-close after 2 hours.
    on Jun 29, 2026
  4. github-actions commented on Jun 30, 2026

    @github-actions
    github-actionsBot
    on Jun 30, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

    Feel free to open a new issue that follows our issue templates.

  5. github-actions
    removed
    needs:complianceThis means the issue will auto-close after 2 hours.
    on Jun 30, 2026
  6. github-actions
    closed this as not plannedon Jun 30, 2026
  7. opencode-agent commented on Jun 30, 2026

    @opencode-agent
    opencode-agentBot
    on Jun 30, 2026 – with OpenCode Agent
    Contributor
    More actions

    Reopening: this was auto-closed by issue compliance automation, but the author is now exempt under the team/opencode-agent automation guard.

  8. opencode-agent
    reopened this on Jun 30, 2026
  9. opencode-agent
    added
    2.0
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    bugSomething isn't working
    on Jul 5, 2026
  10. neriousy commented on Oct 21, 2026

    @neriousy
    neriousy
    on Oct 21, 2026
    Member
    More actions

    Partly done: concurrent refreshes in the same process are now shared (#48937, packages/core/src/mcp/oauth.ts), and invalidation only drops the row if it still holds our refresh token. Cross-process serialization is still open in #50994. Closing this in favor of that PR.

  11. neriousy
    closed this as completedon Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @rekram1-node
    rekram1-node

Labels

2.0bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

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.