Conversation
ochafik
left a comment
There was a problem hiding this comment.
Looks good, couple of nits + could benefit from more tests
There was a problem hiding this comment.
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)
|
Heads up that I'm going to submit a PR imminently to omit the Whether servers should be able to support more recent protocol versions without the resource parameter is an open question. |
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)
.
resourceparameter in OAuth authorization and token exchange flows to bind tokens to the MCP servertoken_verifier.pyto show how to perform resource verification (disabled by default, run with--oauth-strictto 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
resourceparameter 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-strictenabled, 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.pyonly validates theresourceif--oauth-strictis set.