modelcontextprotocol / modelcontextprotocol/php-sdk

[Client] Implement client_credentials grant (client_secret_basic + private_key_jwt)

オープン
#324 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

auth Client enhancement improves spec compliance
主要言語
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) + body grant_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\ClientCredentialsGrant with pluggable assertion signer.
  • JWT signing: prefer a thin built-in using openssl_sign to avoid heavy deps; if dep is preferred, choose lcobucci/jwt (modern, typed) over firebase/php-jwt.
  • Configure via Builder::setOAuthClient($id, $secret) or Builder::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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. 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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。