[Client] Implement client_credentials grant (client_secret_basic + private_key_jwt)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- php
- Domain
- api, authentication, security
Research direction
Start by reading the blocked work in #318 for token_endpoint and #321 for auth methods, then inspect Mcp\Client\Auth\Grant\ClientCredentialsGrant and the Builder OAuth client configuration points named here. Run or add coverage for auth/client-credentials-basic and auth/client-credentials-jwt, including verification against the fixture public key. Done means both authentication shapes pass unit tests and the JWT dependency decision is documented in the PR description.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- PHP
- Stars
- 1.6k
- Forks
- 173
- Avg merge
- 2d 49m
- Merged PRs (30d)
- 23
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelcontextprotocol/php-sdk
-
[Server] Handler type uses bare Closure, hard to decorate RegistryInterface under strict PHPStan OpenServer
Difficulty 1/5 Under an hour Newbie friendliness 78/100
modelcontextprotocol/php-sdk#468 · 2 comments ·
-
needs confirmation needs maintainer action Server
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
modelcontextprotocol/php-sdk#398 · 1 reaction ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
modelcontextprotocol/php-sdk#370 ·
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 55/100
modelcontextprotocol/php-sdk#510 · 1 comment ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
modelcontextprotocol/php-sdk#504 ·
All issues in modelcontextprotocol/php-sdk
Similar issues
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
phpstan/phpstan-doctrine#794 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Automattic/static-site-importer#1767 ·