modelcontextprotocol / modelcontextprotocol/php-sdk

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

Open
#315 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auth Client enhancement improves spec compliance
Dominant language
PHP
Stars
1.6k
Forks
173
Avg merge
2d 49m
Merged PRs (30d)
23

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Client\Builder and the auth/* baseline scenarios, then inspect the src/Client/Auth/ area. Track the interface, TokenSet, both adapters, builder wiring, and unit tests against the listed operations and acceptance criteria; done when optional builder configuration and its documentation are covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, authentication
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.