Skip to content

Runtime-owned explicit authentication single-flight #21

Description

@ethan-huo

Objective

Move credential usability and explicit Authentication Flow coordination behind the MCP Runtime, with one single-flight per Credential Identity.

Scope

  • Ordinary Calls perform a read-only credential usability check and return reauth-required when unusable.
  • Only explicit refreshServers may refresh tokens, open a browser, or join an interactive flow.
  • Share one refresh/interactive promise per Credential Identity.
  • Track each refresh caller as an independent waiter.
  • Cancel the flow and close callback resources when the final waiter disconnects.
  • Persist one successful credential rotation before releasing waiters.
  • Preserve the current OAuth callback unref() mitigation until lifecycle tests prove cleanup.
  • Remove the cross-process token-cache lock only after Runtime sole-writer and single-flight coverage replaces it.

Non-goals

  • Automatic auth from ordinary Calls.
  • Real OAuth providers.
  • Credential material in Runtime protocol frames.

TDD acceptance

  • Start with failing credential-coordinator tests using local metadata, token, and callback fixtures.
  • An ordinary Call never hits an auth/token endpoint and returns reauth-required.
  • Five concurrent explicit refresh CLI callers cause one token refresh or interactive flow.
  • One waiter disconnect does not cancel while another remains.
  • Final waiter disconnect closes callback resources and settles the flow.
  • Success, rejection, timeout, and cancellation leave no referenced callback server or timer.

Verification

  • Focused credential/auth tests.
  • Concurrent process-level refresh regression.
  • Full test suite, typecheck, formatter check, and git diff --check.

Metadata

Metadata

Assignees

No one assigned

    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