Skip to content

Allow servers to advertise lack of RFC 8707 resource indicator support - #1953

Open
erwinkramer wants to merge 2 commits into
modelcontextprotocol:mainfrom
erwinkramer:fix/resource-indicator-support
Open

erwinkramer wants to merge 2 commits into
modelcontextprotocol:mainfrom
erwinkramer:fix/resource-indicator-support

Conversation

@erwinkramer

Copy link
Copy Markdown

Some authorization servers, such as Microsoft Entra ID, do not support RFC 8707 resource indicators and reject authorization and token requests that include the resource parameter (AADSTS901002). Removing the parameter unilaterally on the client is not acceptable: the MCP specification requires it, and it binds the token audience, so omitting it silently opens a token theft window against servers that do support it.

Instead, the decision is delegated to the server, which is the component that validates the token. Add an optional resource_indicators_supported extension to the protected resource metadata (RFC 9728). Servers that use an authorization server without RFC 8707 support set it to false, and clients then omit the resource parameter and bind the token audience through scopes.

Changes:

  • ProtectedResourceMetadata: new optional ResourceIndicatorsSupported property (null = assume support, the spec-conformant default).
  • ClientOAuthProvider: when the protected resource metadata advertises the lack of support, omit the resource parameter from authorization, token, and refresh requests and log a warning explaining that audience is bound by scopes only.
  • Tests: end-to-end test simulating an Entra-like authorization server that rejects the resource parameter in both authorization and token requests, plus coverage for the new Clone() property.

Fixes #648

Motivation and Context

How Has This Been Tested?

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Some authorization servers, such as Microsoft Entra ID, do not support RFC 8707 resource indicators and reject authorization and token requests that include the resource parameter (AADSTS901002). Removing the parameter unilaterally on the client is not acceptable: the MCP specification requires it, and it binds the token audience, so omitting it silently opens a token theft window against servers that do support it.

Instead, the decision is delegated to the server, which is the component that validates the token. Add an optional resource_indicators_supported extension to the protected resource metadata (RFC 9728). Servers that use an authorization server without RFC 8707 support set it to false, and clients then omit the resource parameter and bind the token audience through scopes.

Changes:
- ProtectedResourceMetadata: new optional ResourceIndicatorsSupported property (null = assume support, the spec-conformant default).
- ClientOAuthProvider: when the protected resource metadata advertises the lack of support, omit the resource parameter from authorization, token, and refresh requests and log a warning explaining that audience is bound by scopes only.
- Tests: end-to-end test simulating an Entra-like authorization server that rejects the resource parameter in both authorization and token requests, plus coverage for the new Clone() property.

Fixes modelcontextprotocol#648
@erwinkramer

Copy link
Copy Markdown
Author

Tagging @jeffhandley and @halter73 since you've both been involved in the related issue and previous attempts to resolve it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OAuth authentication request fails with MS Entra-ID

1 participant