-
Notifications
You must be signed in to change notification settings - Fork 1.8k
RFC 8 8000 707 Resource Indicators Implementation #991
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
base: ihrpr/auth2
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, couple of nits + could benefit from more tests
src/mcp/client/auth.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to add expectations on resource param to tests/client/test_auth.py similar to https://github.com/modelcontextprotocol/typescript-sdk/pull/638/files#diff-68dc66b14905d1fc01dc142e244a7e13fbdf88062d3a0b426983c333ccdfc9ed
(doesn't look like there's tests for authorize.py or for provider.py yet, not sure how hard they'd be to add)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ihrpr !
RFC 8707 Resource Indicators Implementation
Background:
Spec Changes PR
rfc8707
TS Implementation
Additional changes for not requiring strict matching
Closes: #962
Implements Resource Indicators validation for OAuth 2.0 (RFC 8707; spec change)
.
resource
parameter in OAuth authorization and token exchange flows to bind tokens to the MCP servertoken_verifier.py
to show how to perform resource verification (disabled by default, run with--oauth-strict
to enable)Motivation and Context
Facilitate prevention of token theft/confusion attacks where a malicious MCP server steals tokens meant for other services by explicitly binding tokens to their intended resources and showing how a server can check this binding.
This security vulnerability was identified in modelcontextprotocol/modelcontextprotocol#544.
How Resource Indicators Work
Clients automatically include a
resource
parameter in their OAuth requests that identifies which MCP server they intend to access (e.g.,resource=https://api.example.com/mcp
). This happens transparently without any action from developers using the SDK.Authorization Servers (AS) receive this resource parameter and include it in the tokens they issue, typically as the
aud
(audience) claim in JWT tokens. This cryptographically binds each token to its intended MCP server.MCP Resource Servers (RS) can verify that incoming tokens were specifically issued for them by checking the audience claim matches their server URL. With
--oauth-strict
enabled, the server rejects tokens that don't include the correct resource identifier, preventing token confusion attacks.Breaking Changes
While the change is breaking at a protocol level, it should not require code changes from SDK users (just SDK version bumping).
token_verifier.py
)server.py
only validates theresource
if--oauth-strict
is set.