-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Initial Checks
- I confirm that I'm using the latest version of MCP Python SDK
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Description
The current MCP Server implementation appears to use a fixed URL pattern [domain]/.well-known/oauth-protected-resource
for the protected resource URL. After reviewing RFC9728, I believe this doesn't fully align with the specification's requirements.
Expected behavior:
If the resource URL is https://resource.example.com/resource1
, the protected resource metadata URL to be https://resource.example.com/.well-known/oauth-protected-resource/resource1
Current behavior:
If the resource URL is https://resource.example.com/resource1
, the protected resource metadata URL to be https://resource.example.com/.well-known/oauth-protected-resource
Link to the source code:
python-sdk/src/mcp/server/auth/routes.py
Line 219 in 7942184
"/.well-known/oauth-protected-resource", |
return [
Route(
"/.well-known/oauth-protected-resource",
endpoint=cors_middleware(handler.handle, ["GET", "OPTIONS"]),
methods=["GET", "OPTIONS"],
)
]
RFC 9728
Protected resources supporting metadata MUST make a JSON document containing metadata as specified in Section 2 available at a URL formed by inserting a well-known URI string into the protected resource's resource identifier between the host component and the path and/or query components, if any.
...
The consumer of the metadata would make the following request when the resource identifier is https://resource.example.com/resource1 and the well-known URI path suffix is oauth-protected-resource to obtain the metadata, since the resource identifier contains a path component:GET /.well-known/oauth-protected-resource/resource1 HTTP/1.1
Host: resource.example.com
As the RFC correctly states:
Using path components enables supporting multiple resources per host. This is required in some multi-tenant hosting configurations.
which is difficult to achieve with the current implementation.
Example Code
Python & MCP Python SDK
Latest version