-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: enhance auth server discovery with OAuth2 and OpenID metadata support #797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: enhance auth server discovery with OAuth2 and OpenID metadata support #797
Conversation
73f39e6 to
cacef40
Compare
cacef40 to
29720c3
Compare
|
$0.02 on this ... I 100% support the OIDC metadata fallback but RFC8414 already mentions this fallback. Supporting that RFC fully would mean that the fallback support is required and wouldn't need to be spelled out explicitly. I think the spec could say something to the effect of:
... or thereabouts. Edit: Latest spec (2025-06-18) feels like it gets the wording right: Maybe the diagram could note the fallback but that's not critical in my mind. Original wording was too prescriptive and current is definitely an improvement. Related PRs/discussions: |
|
Hi @joshcanhelp thank you for the feedback and suggestions. However, I believe that treating “support for RFC 8414” as a blanket requirement misses a key architectural consideration, for the following reasons: As you noted, Section 3 of RFC 8414 states:
The spec mentions that for an auth server used by a specific application (e.g., "example"), its metadata endpoint could be For the MCP spec, considering its goal of ecosystem compatibility (to adapt to general-purpose auth servers), the more appropriate choice is the default discovery endpoint, which RFC 8414 also mentions:
Regarding
So, from the perspective of RFC 8414, there isn't really an "OIDC concept" at play here. The name This distinction frames our decision as a choice between two architectural paths:
This PR deliberately chooses the second path. @localden @aaronpk @D-McAdams I'd be interested to hear your point of view on this. |
|
At the end of the day, we want these applications to be able to get the authorization server metadata so they're able to log in. Whether it's one of specific URLs stated or an application-specific one doesn't matter. I don't think we should be deciding that one of those two paths, both of which are currently being used, is the right way when the goal is the same. The question, in my mind, is ... does allowing the application-specific path limit this in any way or affect developers that aren't using it? The RFC solves the problem, I suggest we just point there and leave it at that. Appreciate the thoughtful conversation, either way! |
If I understand correctly from RFC 8414:
This limits that even for application-specific URLs, they have to be listed in IANA. Also regarding allowing application specific path (that may not be on the IANA list), could you suggest a few use cases? I'm struggling to understand the value it provides, given that |
|
@xiaoyijun Regarding a remaining question from previous PR:
AS Metadata and OIDC config requires different fields. See the comparison that @localden shared: I've took a glance and it doesn't seem to me that supporting OIDC requires handling the difference. However could you help with a second eye on checking if any of the differences are required by Auth implementations like modelcontextprotocol/python-sdk@17f9c00? |
@joshcanhelp I doubt falling back to OIDC discovery is same as the fallback mentioned in the authorization server metadata spec. This is much noticeable in scenarios where issuer has a path component. The Authz server metadata spec defines the URL to be [1] https://datatracker.ietf.org/doc/html/rfc8414#:~:text=formed%20by%20inserting%0A%20%20%20%22/.well%2Dknown/example%2Dconfiguration%22%20between%20the%20host%20and%20path%0A%20%20%20components%20of%20the%20authorization%20server%27s%20issuer%20identifier. |
29720c3 to
f23c328
Compare
|
Hi @LucaButBoring , thanks for your review, I’ve updated the spec to address your concerns, PTAL. ❤️ |
|
$0.02 on the subject. https://modelcontextprotocol.io/specification/draft/basic/authorization#sequence-diagram Current Auth Server discovery sequence require /.well-known/oauth-authorization-server be hosted under Auth Server domain. Plus, it opens the possibilities for Resource Server to provide its own Dynamic Client Registration Endpoint while other Endpoints remain pointed to the Enterprise Auth Server. Looking forward to learning more about your thoughts and other common Enterprise Auth Server support of this scenario. |
Please Correct me if Im missing something, but isn't this already covered by the protected resource metadata spec[1]? |
It depends on the Auth Server required by Enterprise Context, for Auth Server like Microsoft Entra, there is no support for /.well-known/oauth-authorization-server, and personally I believe that is not practical for such Auth Server which targeted for multi tenants/enterprises. The current spec's assumption of Auth Server I believe assumed the Auth Server have strong flexibility to the Resource Server owner which isn't the case for Enterprise Scenarios. |
@softnado can you give a specific example of the problem, including what you'd like the Also, unless I'm missing something, that's not OIDC-related, so we can spin that off to another RFC if there is a gap there. |
Hi @LucaButBoring, thanks for raising this important point! You're absolutely right to be concerned about I did some research into this issue, and here's what I found: The Core Problem:
Current Reality:
My proposed solution:Since OIDC is based on OAuth 2.0, there's no alternative reliable discovery mechanism, and MCP absolutely requires PKCE for security, I'm planning to update the spec to require:
This ensures we never compromise on PKCE security while providing a clear, implementable standard for OIDC providers. What do you think of this approach? |
Yes, this sounds reasonable to me - aligned with this way of handling it for the time being. |
|
@xiaoyijun Do we have implementations for these in Python or Typescript? Per the new process: https://modelcontextprotocol.io/community/sep-guidelines we really would love to see at least one implementation |
|
|
This was accepted by @modelcontextprotocol/core-maintainers with a 7 YES votes, 0 NO votes and 1 ABSENT |
Hi @LucaButBoring , I'm glad this approach sounds reasonable to you. I've implemented the changes as discussed in the "Authorization Code Protection" section. I also added a clarification about Please let me know if this looks good to you! |
|
Hi @pcarleton and @localden , thanks for the earlier approval! I added a small clarification about PKCE support verification based on feedback. This new commit automatically requires re-review, but the main changes you approved are still intact. Quick look appreciated when you have time! |
Hi @dsp-ant , yes, I have a related WIP TypeScript SDK PR here: modelcontextprotocol/typescript-sdk#652 Now let this spec is basically settled now, I'll update the SDK implementation to match these new requirements. Will let you know when it's ready! |
Add OpenID Connect Discovery Support for Authorization Server Discovery
Note: this PR reopens #677
Motivation and Context
This PR enhances the authorization server discovery mechanism by adding support for OpenID Connect Discovery 1.0 alongside the existing OAuth 2.0 Authorization Server Metadata.
OpenID Connect (OIDC) is built on top of OAuth 2.0, extending it with standardized identity functionality. Many modern authorization servers implement OIDC as their primary protocol, making it crucial for MCP to support both discovery mechanisms. Popular authorization providers such as Keycloak, Auth0, and Logto all implement OIDC discovery by default.
Key benefits:
How Has This Been Tested?
N/A
Breaking Changes
None. This change is fully backwards compatible:
Types of changes
Checklist
Additional context
The addition of OIDC discovery support is particularly valuable because:
.well-known/openid-configurationendpoint is widely supported