Skip to content

[Client] Implement refresh_token grant + offline_access scope #323

Description

@soyuka

Context

When an access token expires, the client must transparently refresh using the stored refresh_token rather than re-prompting the user. Per OIDC/OAuth, offline_access scope is requested at authorize time when the AS advertises it; otherwise the client degrades gracefully (no refresh available).

Scope

  • Mcp\Client\Auth\Grant\RefreshTokenGrant.
  • Pre-flight check: if expires_at - now() < skew, refresh before sending request.
  • Reactive: on 401 with valid refresh token, refresh + retry once.
  • Request offline_access scope at authorize time when scopes_supported contains it; otherwise omit.
  • If the AS does not advertise offline_access and tokens expire, surface a re-auth signal cleanly (no infinite loop).

Conformance scenarios unblocked

auth/offline-access-scope, auth/offline-access-not-supported.

Dependencies

Blocked by: #319 (need access+refresh tokens from auth code flow), #322 (scope handling).

Acceptance

  • Unit tests for proactive + reactive refresh, no-refresh-token degradation, no-offline_access degradation.
  • Conformance: 2 baseline scenarios pass.

cc @soyuka

Activity

  1. added
    ClientIssues & PRs related to the Client component
    P1Significant bug affecting many users, highly requested feature
    authIssues and PRs related to Authentication / OAuth
    improves spec complianceImproves consistency with other SDKs such as TyepScript
    enhancementRequest for a new feature that's not currently supported
    on May 19, 2026
  2. chr-hertel commented on May 26, 2026

    @chr-hertel
    Member

    Cross-reference: this work is gated on SEP-2207 for the MCP Spec 2026-07-28 release — without requesting the offline_access scope at auth-code time, refresh tokens won't be issued by OIDC-flavored authorization servers.

    The offline_access request behavior is tracked separately as #363 and should land alongside this issue. See umbrella #338.

  3. removed
    P1Significant bug affecting many users, highly requested feature
    on Aug 19, 2026
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

    ClientIssues & PRs related to the Client componentauthIssues and PRs related to Authentication / OAuthenhancementRequest for a new feature that's not currently supportedimproves spec complianceImproves consistency with other SDKs such as TyepScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions