Skip to content

[Client] Add OAuth 2.0 credential storage interface (TokenStorageInterface) #315

Open
chr-hertel/php-sdk
#53

Description

@soyuka

Context

Foundation for every OAuth flow on the client side. Without a storage abstraction we cannot persist access tokens, refresh tokens, registered client credentials, or PKCE verifiers across requests/sessions.

Scope

  • Define Mcp\Client\Auth\TokenStorageInterface with operations: getToken(string $resourceUrl): ?TokenSet, storeToken(string $resourceUrl, TokenSet $token): void, clearToken(string $resourceUrl): void, plus equivalents for registered client metadata.
  • Value object TokenSet (access_token, refresh_token, expires_at, scope, token_type).
  • Default implementations:
    • InMemoryTokenStorage (ephemeral, per-process).
    • Psr16TokenStorage adapter for PSR-16 CacheInterface.
  • Wire into Client\Builder::setTokenStorage(...) (optional; defaults to in-memory).

Conformance scenarios unblocked

Prerequisite for all auth/* baseline scenarios.

Dependencies

None — must land first.

Acceptance

  • Interface + value object + 2 storage adapters in src/Client/Auth/.
  • Unit tests for both adapters.
  • Builder method documented.

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 required by SEP-2352 for the MCP Spec 2026-07-28 release.

    Specifically, the TokenStorageInterface must key stored credentials by AS issuer URL, not just by MCP server URL — the cache key should be (resource_server, as_issuer). See umbrella #338 and sibling sub-issue #361 (which adds the cross-AS rejection logic on top of this storage layer).

  3. removed
    P1Significant bug affecting many users, highly requested feature
    on Aug 19, 2026
  4. added a commit that references this issue on Sep 8, 2026
    cc4cf09
  5. added a commit that references this issue on Oct 18, 2026
    606afce
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