Skip to content

Commit 95ed261

Browse files
sunishsheth2009pcarletondendggoodman
authored
SEP-985: Updating the Authorization spec to fallback to WWW-Authenticate when Protected Resource Metadata is not found (modelcontextprotocol#971)
* Updating the Authorization spec to fallback to WWW-Authenticate when Protected Resource Metadata is not found * Updating the sequence diagram based on SEP changes * clarify metadata hosting options * make mermaid more explicit * Apply suggestions from code review Co-authored-by: Den Delimarsky <[email protected]> * Update docs/specification/draft/basic/authorization.mdx * Apply suggestions from code review Co-authored-by: Geoff Goodman <[email protected]> * Apply suggestions from code review * formatting --------- Co-authored-by: Paul Carleton <[email protected]> Co-authored-by: Den Delimarsky <[email protected]> Co-authored-by: Paul Carleton <[email protected]> Co-authored-by: Geoff Goodman <[email protected]>
1 parent c484b79 commit 95ed261

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

docs/specification/draft/basic/authorization.mdx

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,19 @@ guidance on implementation details.
8888
Implementors should note that Protected Resource Metadata documents can define multiple authorization servers. The responsibility for selecting which authorization server to use lies with the MCP client, following the guidelines specified in
8989
[RFC9728 Section 7.6 "Authorization Servers"](https://datatracker.ietf.org/doc/html/rfc9728#name-authorization-servers).
9090

91-
MCP servers **MUST** use the HTTP header `WWW-Authenticate` when returning a _401 Unauthorized_ to indicate the location of the resource server metadata URL
92-
as described in [RFC9728 Section 5.1 "WWW-Authenticate Response"](https://datatracker.ietf.org/doc/html/rfc9728#name-www-authenticate-response).
91+
#### Protected Resource Metadata Discovery Requirements
9392

94-
MCP clients **MUST** be able to parse `WWW-Authenticate` headers and respond appropriately to `HTTP 401 Unauthorized` responses from the MCP server.
93+
MCP servers **MUST** implement one of the following discovery mechanisms to provide authorization server location information to MCP clients:
9594

96-
#### Server Metadata Discovery
95+
1. **WWW-Authenticate Header**: Include the resource metadata URL in the `WWW-Authenticate` HTTP header under `resource_metadata` when returning `401 Unauthorized` responses, as described in [RFC9728 Section 5.1](https://datatracker.ietf.org/doc/html/rfc9728#name-www-authenticate-response).
96+
97+
2. **Well-Known URI**: Serve metadata at a well-known URI as specified in [RFC9728](https://datatracker.ietf.org/doc/html/rfc9728). This can be either:
98+
- At the path of the server's MCP endpoint: `https://example.com/public/mcp` could host metadata at `https://example.com/.well-known/oauth-protected-resource/public/mcp`
99+
- At the root: `https://example.com/.well-known/oauth-protected-resource`
100+
101+
MCP clients **MUST** support both discovery mechanisms and use the resource metadata URL from the parsed WWW-Authenticate headers when present; otherwise, they **MUST** fall back to constructing and requesting the well-known URIs in the order listed above.
102+
103+
#### Authorization Server Metadata Discovery
97104

98105
To handle different issuer URL formats and ensure interoperability with both OAuth 2.0 Authorization Server Metadata and OpenID Connect Discovery 1.0 specifications, MCP clients **MUST** attempt multiple well-known endpoints when discovering authorization server metadata.
99106

@@ -120,12 +127,30 @@ sequenceDiagram
120127
participant M as MCP Server (Resource Server)
121128
participant A as Authorization Server
122129
130+
Note over C: Attempt unauthenticated MCP request
123131
C->>M: MCP request without token
124-
M-->>C: HTTP 401 Unauthorized with WWW-Authenticate header
125-
Note over C: Extract resource_metadata<br />from WWW-Authenticate
132+
M-->>C: HTTP 401 Unauthorized (may include WWW-Authenticate header)
133+
134+
alt Header includes resource_metadata
135+
Note over C: Extract resource_metadata URL from header
136+
C->>M: GET resource_metadata URI
137+
M-->>C: Resource metadata with authorization server URL
138+
else No resource_metadata in header
139+
Note over C: Fallback to well-known URI probing
140+
Note over M: _Not applicable if the MCP server is at the root_
141+
C->>M: GET /.well-known/oauth-protected-resource/mcp
142+
alt Sub-path metadata found
143+
M-->>C: Resource metadata with authorization server URL
144+
else Sub-path not found
145+
C->>M: GET /.well-known/oauth-protected-resource
146+
alt Root metadata found
147+
M-->>C: Resource metadata with authorization server URL
148+
else Root metadata not found
149+
Note over C: Abort or use pre-configured values
150+
end
151+
end
152+
end
126153
127-
C->>M: GET /.well-known/oauth-protected-resource
128-
M-->>C: Resource metadata with authorization server URL
129154
Note over C: Validate RS metadata,<br />build AS metadata URL
130155
131156
C->>A: GET Authorization server metadata endpoint

0 commit comments

Comments
 (0)