Skip to content

Commit 58f42ac

Browse files
authored
Merge pull request modelcontextprotocol#797 from mcp-auth/spec-support-oidc-discovery
feat: enhance auth server discovery with OAuth2 and OpenID metadata support
2 parents 30c7afb + 245429b commit 58f42ac

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

docs/specification/draft/basic/authorization.mdx

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,12 @@ specifies how an MCP server indicates the location of its corresponding authoriz
6363
1. MCP servers **MUST** implement OAuth 2.0 Protected Resource Metadata ([RFC9728](https://datatracker.ietf.org/doc/html/rfc9728)).
6464
MCP clients **MUST** use OAuth 2.0 Protected Resource Metadata for authorization server discovery.
6565

66-
1. MCP authorization servers **MUST** provide OAuth 2.0 Authorization
67-
Server Metadata ([RFC8414](https://datatracker.ietf.org/doc/html/rfc8414)).
68-
MCP clients **MUST** use the OAuth 2.0 Authorization Server Metadata.
66+
1. MCP authorization servers **MUST** provide at least one of the following discovery mechanisms:
67+
68+
- OAuth 2.0 Authorization Server Metadata ([RFC8414](https://datatracker.ietf.org/doc/html/rfc8414))
69+
- [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html)
70+
71+
MCP clients **MUST** support both discovery mechanisms to obtain the information required to interact with the authorization server.
6972

7073
### Authorization Server Discovery
7174

@@ -93,8 +96,20 @@ MCP clients **MUST** be able to parse `WWW-Authenticate` headers and respond app
9396

9497
#### Server Metadata Discovery
9598

96-
MCP clients **MUST** follow the OAuth 2.0 Authorization Server Metadata [RFC8414](https://datatracker.ietf.org/doc/html/rfc8414)
97-
specification to obtain the information required to interact with the authorization server.
99+
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.
100+
101+
The discovery approach is based on [RFC8414 Section 3.1 "Authorization Server Metadata Request"](https://datatracker.ietf.org/doc/html/rfc8414#section-3.1) for OAuth 2.0 Authorization Server Metadata discovery and [RFC8414 Section 5 "Compatibility Notes"](https://datatracker.ietf.org/doc/html/rfc8414#section-5) for OpenID Connect Discovery 1.0 interoperability.
102+
103+
For issuer URLs with path components (e.g., `https://auth.example.com/tenant1`), clients **MUST** try endpoints in the following priority order:
104+
105+
1. OAuth 2.0 Authorization Server Metadata with path insertion: `https://auth.example.com/.well-known/oauth-authorization-server/tenant1`
106+
2. OpenID Connect Discovery 1.0 with path insertion: `https://auth.example.com/.well-known/openid-configuration/tenant1`
107+
3. OpenID Connect Discovery 1.0 path appending: `https://auth.example.com/tenant1/.well-known/openid-configuration`
108+
109+
For issuer URLs without path components (e.g., `https://auth.example.com`), clients **MUST** try:
110+
111+
1. OAuth 2.0 Authorization Server Metadata: `https://auth.example.com/.well-known/oauth-authorization-server`
112+
2. OpenID Connect Discovery 1.0: `https://auth.example.com/.well-known/openid-configuration`
98113

99114
#### Sequence Diagram
100115

@@ -114,7 +129,8 @@ sequenceDiagram
114129
M-->>C: Resource metadata with authorization server URL
115130
Note over C: Validate RS metadata,<br />build AS metadata URL
116131
117-
C->>A: GET /.well-known/oauth-authorization-server
132+
C->>A: GET Authorization server metadata endpoint
133+
Note over C,A: Try OAuth 2.0 and OpenID Connect<br/>discovery endpoints in priority order
118134
A-->>C: Authorization server metadata
119135
120136
Note over C,A: OAuth 2.1 authorization flow happens here
@@ -170,8 +186,9 @@ sequenceDiagram
170186
171187
Note over C: Parse metadata and extract authorization server(s)<br/>Client determines AS to use
172188
173-
C->>A: GET /.well-known/oauth-authorization-server
174-
A->>C: Authorization server metadata response
189+
C->>A: GET Authorization server metadata endpoint
190+
Note over C,A: Try OAuth 2.0 and OpenID Connect<br/>discovery endpoints in priority order
191+
A-->>C: Authorization server metadata
175192
176193
alt Dynamic client registration
177194
C->>A: POST /register
@@ -326,9 +343,19 @@ Specifically:
326343
An attacker who has gained access to an authorization code contained in an authorization response can try to redeem the authorization code for an access token or otherwise make use of the authorization code.
327344
(Further described in [OAuth 2.1 Section 7.5](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13#section-7.5))
328345

329-
To mitigate this, MCP clients **MUST** implement PKCE according to [OAuth 2.1 Section 7.5.2](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13#section-7.5.2).
346+
To mitigate this, MCP clients **MUST** implement PKCE according to [OAuth 2.1 Section 7.5.2](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13#section-7.5.2) and **MUST** verify PKCE support before proceeding with authorization.
330347
PKCE helps prevent authorization code interception and injection attacks by requiring clients to create a secret verifier-challenge pair, ensuring that only the original requestor can exchange an authorization code for tokens.
331348

349+
MCP clients **MUST** use the `S256` code challenge method when technically capable, as required by [OAuth 2.1 Section 4.1.1](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13#section-4.1.1).
350+
351+
Since OAuth 2.1 and PKCE specifications do not define a mechanism for clients to discover PKCE support, MCP clients **MUST** rely on authorization server metadata to verify this capability:
352+
353+
- **OAuth 2.0 Authorization Server Metadata**: If `code_challenge_methods_supported` is absent, the authorization server does not support PKCE and MCP clients **MUST** refuse to proceed.
354+
355+
- **OpenID Connect Discovery 1.0**: While the [OpenID Provider Metadata](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata) does not define `code_challenge_methods_supported`, this field is commonly included by OpenID providers. MCP clients **MUST** verify the presence of `code_challenge_methods_supported` in the provider metadata response. If the field is absent, MCP clients **MUST** refuse to proceed.
356+
357+
Authorization servers providing OpenID Connect Discovery 1.0 **MUST** include `code_challenge_methods_supported` in their metadata to ensure MCP compatibility.
358+
332359
### Open Redirection
333360

334361
An attacker may craft malicious redirect URIs to direct users to phishing sites.

docs/specification/draft/changelog.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ the previous revision, [2025-06-18](/specification/2025-06-18).
99

1010
## Major changes
1111

12+
1. Enhance authorization server discovery with support for [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html). (PR [#797](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/797))
13+
1214
## Other schema changes
1315

1416
## Full changelog

0 commit comments

Comments
 (0)