Skip to content

[vMCP] Handle auth credential expiration with retry and proactive refresh #3869

Open

Description

@yrobla

Depends on #3865

With session-scoped clients, short-lived outgoing credentials (e.g., OAuth tokens) resolved at client creation can become stale mid-session. Implement automatic client recreation on auth failure with proper safeguards.

Phase 1 (this issue):

  • Detect 401/403 from backend; recreate client with fresh credentials from OutgoingAuthRegistry
  • Retry with exponential backoff, max 3 attempts
  • Circuit-breaker: after N consecutive auth failures per backend, disable retries and log a warning
  • Use singleflight to deduplicate concurrent recreation attempts for the same backend
  • Auth-failure retries add non-trivial latency — surface this overhead in distributed traces

Phase 2 (follow-up, separate issue):

  • Modify identityPropagatingRoundTripper to read identity from request context per-operation, eliminating the stale credential problem entirely
  • For credentials with a known expiry (JWT exp, OAuth expires_in): schedule proactive client recreation before expiry

Acceptance Criteria

  • A 401 or 403 from a backend triggers client recreation with fresh credentials
  • Recreation is retried with exponential backoff up to a maximum of 3 attempts
  • After N consecutive auth failures for a backend, the circuit breaker opens and further retries are skipped
  • Concurrent auth failures for the same backend result in only one recreation attempt (via singleflight)
  • Auth-failure retry latency is visible in distributed traces
  • The raw credentials are never logged
  • Unit tests cover: successful recreation, max retries exhausted, circuit breaker opens, concurrent failures deduplicated

RFC: THV-0038 — Session-scoped client lifecycle

Activity

  1. added
    vmcp
    on Feb 18, 2026
  2. added
    enhancement
    go
    on Feb 18, 2026
  3. added 5 commits that reference this issue on Mar 16, 2026
    5ab7f12
    37f13cf
    63b4c42
    e59bbd3
    b53818c
  4. added a commit that references this issue on Apr 15, 2026
    ab3a793
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    authenticationenhancementgovmcp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions