modelcontextprotocol / modelcontextprotocol/php-sdk
[Client] Implement Protected Resource Metadata discovery (RFC 9728)
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.6k
- Forks
- 173
- Avg merge
- 2d 49m
- Merged PRs (30d)
- 23
Description
Context
Per the MCP authorization spec (2025-06-18+), an unauthenticated client receiving a 401 MUST parse WWW-Authenticate: Bearer resource_metadata="<url>", fetch the indicated /.well-known/oauth-protected-resource document, and use it to locate the authorization server.
Scope
Mcp\Client\Auth\ProtectedResourceMetadataDiscoverer:- Parse
WWW-Authenticateforresource_metadata. - GET the URL, parse JSON.
- Resolve
authorization_servers[],bearer_methods_supported,scopes_supported,resource(audience).
- Parse
- Validate
resourcematches the MCP server origin (defense-in-depth forauth/resource-mismatch, already passing).
Conformance scenarios unblocked
auth/metadata-default, auth/metadata-var1, auth/metadata-var2, auth/metadata-var3, auth/basic-cimd.
Dependencies
Blocked by: #316 (Bearer injection plumbs the 401 hook).
Acceptance
- Unit + integration tests against fixtures from the conformance fixtures dir.
- Conformance: 4 baseline scenarios above pass.
cc @soyuka
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.
Research direction
Start with #316 to understand the 401 hook, then inspect Mcp\Client\Auth\ProtectedResourceMetadataDiscoverer and the conformance fixtures directory. Implement the metadata discovery scope and add unit and integration coverage; done means the four listed baseline scenarios pass and resource-mismatch validation remains passing.
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