modelcontextprotocol / modelcontextprotocol/php-sdk

[Client] Implement Protected Resource Metadata discovery (RFC 9728)

Open
#317 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auth Client enhancement improves spec compliance
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-Authenticate for resource_metadata.
    • GET the URL, parse JSON.
    • Resolve authorization_servers[], bearer_methods_supported, scopes_supported, resource (audience).
  • Validate resource matches the MCP server origin (defense-in-depth for auth/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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.