modelcontextprotocol / modelcontextprotocol/php-sdk
[Client] Implement client_credentials grant (client_secret_basic + private_key_jwt)
まだ誰も着手していません。
- 主要言語
- PHP
- スター
- 1.6k
- フォーク
- 173
- 平均マージ
- 2日 49分
- マージ済み PR(30日)
- 23
説明
Context
For non-interactive / machine-to-machine MCP clients, the client_credentials grant (RFC 6749 §4.4) is used directly against token_endpoint. Two client authentication shapes are required by conformance:
- Basic:
Authorization: Basic base64(client_id:client_secret)+ bodygrant_type=client_credentials. - JWT assertion (private_key_jwt, RFC 7521/7523): body
client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer+client_assertion=<signed JWT>. JWT signed with the client's private key (ES256/RS256),iss+sub=client_id,aud=token_endpoint,jti=random,exp=now+60s.
Scope
Mcp\Client\Auth\Grant\ClientCredentialsGrantwith pluggable assertion signer.- JWT signing: prefer a thin built-in using
openssl_signto avoid heavy deps; if dep is preferred, chooselcobucci/jwt(modern, typed) overfirebase/php-jwt. - Configure via
Builder::setOAuthClient($id, $secret)orBuilder::setOAuthClientWithKey($id, $privateKeyPem, $algorithm).
Conformance scenarios unblocked
auth/client-credentials-basic, auth/client-credentials-jwt.
Dependencies
Blocked by: #318 (token_endpoint), #321 (auth methods).
Acceptance
- Unit tests for both shapes; JWT signing verified against a fixture public key.
- Decision on JWT dep documented in PR description.
cc @soyuka
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、token_endpoint の #318 と auth methods の #321 にあるブロック中の作業を読み、次に Mcp\Client\Auth\Grant\ClientCredentialsGrant と、ここで示されている Builder OAuth クライアントの設定箇所を調べます。auth/client-credentials-basic と auth/client-credentials-jwt のカバレッジを実行または追加し、fixture の公開鍵に対する検証も含めます。両方の認証形式が単体テストに合格し、JWT 依存関係の判断が PR の説明に記録されていれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- api, authentication, security
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100