Add 2025-03-26 OAuth backward compatibility for client conformance#1374
Merged
jeffhandley merged 6 commits intomodelcontextprotocol:mainfrom Feb 24, 2026
Merged
Conversation
Implement legacy OAuth fallback so the client can authenticate against MCP servers that predate Protected Resource Metadata (RFC 9728): - When PRM discovery fails, synthesize minimal metadata using the MCP server's origin as the authorization server - When auth server metadata discovery also fails, fall back to the default endpoint paths (/authorize, /token, /register) specified by the MCP 2025-03-26 spec - Conditionally omit the 'resource' parameter from authorization and token requests when operating in legacy mode - Skip resource-match verification only for synthesized (not fetched) PRM Enable the two previously-commented-out client conformance test scenarios: auth/2025-03-26-oauth-metadata-backcompat auth/2025-03-26-oauth-endpoint-fallback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
halter73
reviewed
Feb 24, 2026
src/ModelContextProtocol.Core/Authentication/ClientOAuthProvider.cs
Outdated
Show resolved
Hide resolved
halter73
reviewed
Feb 24, 2026
Refactor GetAuthServerMetadataAsync to accept an allowDefaultFallback parameter and return BuildDefaultAuthServerMetadata directly instead of throwing and catching McpException at the call site. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add two tests to AuthTests.cs covering legacy server scenarios: - CanAuthenticate_WithLegacyServerWithoutProtectedResourceMetadata: Server lacks RFC 9728 PRM but serves auth server metadata at well-known URLs on the MCP server origin. - CanAuthenticate_WithLegacyServerUsingDefaultEndpointFallback: Server lacks both PRM and auth server metadata, forcing fallback to default /authorize, /token, /register endpoint paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
9 tasks
halter73
reviewed
Feb 24, 2026
Update CanAuthenticate_WithLegacyServerWithoutProtectedResourceMetadata to use McpServerUrl for auth metadata endpoints and proxy OAuth requests to the real OAuth server, matching the pattern used by the endpoint fallback test. Update TestOAuthServer RequireResource=false to reject requests that include a resource parameter, ensuring the client correctly omits it in legacy mode. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The property now rejects requests that include a resource parameter when set to false, so ExpectResource better describes the bidirectional validation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
halter73
approved these changes
Feb 24, 2026
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement legacy OAuth fallback so the client can authenticate against MCP servers that predate Protected Resource Metadata (RFC 9728):
Enable the two previously-commented-out client conformance test scenarios:
auth/2025-03-26-oauth-metadata-backcompat
auth/2025-03-26-oauth-endpoint-fallback