You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mcp: serve well-known resources at the mcp route path (#1596)
**Description**
Only serve the `.well-known` endpoints at the paths exposed by the
`MCPRoute` and not serve on `/` by default.
According to the spec [1], clients **MUST** use the URL returned in the
`WWW-Authenticate` header and support requesting a `well-known` resource
in the configured path. The "root" resource is just a fallback.
We can't expose the resource at the root because we can have multiple
MCPRoutes with different security configurations, so we need to rely on
clients properly implementing the spec and fetching the well-known
resources from the right path.
**Related Issues/PRs (if applicable)**
Fixes#1585
**Special notes for reviewers (if applicable)**
This has been tested with the MCP inspector and Goose as two of the
popular clients, with Descope as the Authentication provider, and
validated that it works fine with them.
1:
https://mcp.mintlify.app/specification/2025-11-25/basic/authorization#protected-resource-metadata-discovery-requirements
Signed-off-by: Ignasi Barrera <[email protected]>
expected: `Bearer error="invalid_request", error_description="No access token was provided in this request", resource_metadata="https://api.example.com/.well-known/oauth-protected-resource"`,
599
+
expected: `Bearer error="invalid_request", error_description="No access token was provided in this request", resource_metadata="https://api.example.com/.well-known/oauth-protected-resource/mcp/v1"`,
expected: `Bearer error="invalid_request", error_description="No access token was provided in this request", resource_metadata="https://api.example.com/.well-known/oauth-protected-resource"`,
613
+
expected: `Bearer error="invalid_request", error_description="No access token was provided in this request", resource_metadata="https://api.example.com/.well-known/oauth-protected-resource/mcp"`,
614
614
},
615
615
{
616
616
name: "http URL with path",
617
617
metadata: &aigv1a1.ProtectedResourceMetadata{
618
618
Resource: "http://api.example.com/mcp/v1",
619
619
},
620
-
expected: `Bearer error="invalid_request", error_description="No access token was provided in this request", resource_metadata="http://api.example.com/.well-known/oauth-protected-resource"`,
620
+
expected: `Bearer error="invalid_request", error_description="No access token was provided in this request", resource_metadata="http://api.example.com/.well-known/oauth-protected-resource/mcp/v1"`,
expected: `Bearer error="invalid_request", error_description="No access token was provided in this request", resource_metadata="http://api.example.com/.well-known/oauth-protected-resource"`,
634
+
expected: `Bearer error="invalid_request", error_description="No access token was provided in this request", resource_metadata="http://api.example.com/.well-known/oauth-protected-resource/mcp"`,
635
635
},
636
636
{
637
637
name: "URL with port number https",
638
638
metadata: &aigv1a1.ProtectedResourceMetadata{
639
639
Resource: "https://api.example.com:8080/mcp",
640
640
},
641
-
expected: `Bearer error="invalid_request", error_description="No access token was provided in this request", resource_metadata="https://api.example.com:8080/.well-known/oauth-protected-resource"`,
641
+
expected: `Bearer error="invalid_request", error_description="No access token was provided in this request", resource_metadata="https://api.example.com:8080/.well-known/oauth-protected-resource/mcp"`,
642
642
},
643
643
{
644
644
name: "URL with port number http",
645
645
metadata: &aigv1a1.ProtectedResourceMetadata{
646
646
Resource: "http://api.example.com:8080/mcp",
647
647
},
648
-
expected: `Bearer error="invalid_request", error_description="No access token was provided in this request", resource_metadata="http://api.example.com:8080/.well-known/oauth-protected-resource"`,
648
+
expected: `Bearer error="invalid_request", error_description="No access token was provided in this request", resource_metadata="http://api.example.com:8080/.well-known/oauth-protected-resource/mcp"`,
expected: `Bearer error="invalid_request", error_description="No access token was provided in this request", resource_metadata="https://api.example.com/.well-known/oauth-protected-resource"`,
655
+
expected: `Bearer error="invalid_request", error_description="No access token was provided in this request", resource_metadata="https://api.example.com/.well-known/oauth-protected-resource/v1/mcp/endpoint"`,
0 commit comments