modelcontextprotocol / modelcontextprotocol/php-sdk
[Client] Inject Bearer token into HttpTransport requests + handle 401 re-auth
まだ誰も着手していません。
- 主要言語
- PHP
- スター
- 1.6k
- フォーク
- 173
- 平均マージ
- 2日 49分
- マージ済み PR(30日)
- 23
説明
Context
Once an access token is acquired (via any OAuth grant), every outbound JSON-RPC request on HttpTransport must carry Authorization: Bearer <token>. On a 401 Unauthorized mid-session, the transport must trigger a re-auth attempt and retry the failed request exactly once.
Scope
src/Client/Transport/HttpTransport.php:- Read current token from
TokenStorageInterfacekeyed by endpoint URL. - Add
Authorization: Bearer <token>header onsend()when a token is present. - On
401, parseWWW-Authenticateheader, invoke auth coordinator, retry once.
- Read current token from
- Introduce
Mcp\Client\Auth\AuthCoordinatorto orchestrate discovery → registration → token acquisition. (Implementation details land in dependent issues.)
Conformance scenarios unblocked
All auth/* scenarios depend on this wiring.
Dependencies
Blocked by: #315 (TokenStorageInterface).
Acceptance
- Unit tests for header injection + 401 retry behavior.
- Documented extension point for
AuthCoordinator.
cc @soyuka
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
src/Client/Transport/HttpTransport.php から開始し、#315 の TokenStorageInterface 依存関係を確認します。send() と認証コーディネーターのエントリーポイントを追跡し、その後、Bearer ヘッダーの注入と、401 に対する一度だけの再認証リトライを対象とするユニットテストのカバレッジを追加します。完了条件は、リクエストが現在のエンドポイントトークンを使用し、401 レスポンスが 1 回のリトライを発生させ、AuthCoordinator の拡張ポイントがドキュメント化されていることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- api, authentication, backend
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100