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
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]>
Copy file name to clipboardExpand all lines: docs/specification/draft/basic/authorization.mdx
+33-8Lines changed: 33 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,12 +88,19 @@ guidance on implementation details.
88
88
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
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).
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:
95
94
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
97
104
98
105
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.
99
106
@@ -120,12 +127,30 @@ sequenceDiagram
120
127
participant M as MCP Server (Resource Server)
121
128
participant A as Authorization Server
122
129
130
+
Note over C: Attempt unauthenticated MCP request
123
131
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
126
153
127
-
C->>M: GET /.well-known/oauth-protected-resource
128
-
M-->>C: Resource metadata with authorization server URL
129
154
Note over C: Validate RS metadata,<br />build AS metadata URL
0 commit comments