You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Warn when AuthSettings.validate_token_resource is left unset
validate_token_resource becomes bool | None (default None). With a
resource_server_url configured and no explicit choice, AuthSettings emits an
MCPDeprecationWarning and behaves as False, so existing deployments keep
working but are asked to decide; 3.0 makes True the default. An explicit
False (the verifier checks the audience itself) is silent.
The docs tutorials, the bearer_auth and oauth_client_credentials stories,
and the oauth_server snippet now set it to True and issue tokens bound to
their resource URL; docs/deprecated.md lists the new warning.
Copy file name to clipboardExpand all lines: docs/deprecated.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -136,6 +136,7 @@ These are not spec changes, only SDK usage with a better replacement. They warn
136
136
| Deprecated | What you do instead |
137
137
|---|---|
138
138
|`FuncMetadata.call_fn_with_arg_validation()`|`FuncMetadata.validate_arguments()` and then `FuncMetadata.call_fn()`. Only code that drives `FuncMetadata` directly (a custom `Tool` subclass, say) ever called it. |
139
+
|`AuthSettings(resource_server_url=...)` without `validate_token_resource=`| Set it: `True` has the server refuse bearer tokens your verifier does not report as issued for `resource_server_url`, `False` says your verifier checks the token's audience itself (see **[Authorization](run/authorization.md#a-token-verifier)**). Unset behaves as `False`; 3.0 makes `True` the default. |
139
140
|`ClientCredentialsOAuthProvider(...)` or `PrivateKeyJWTOAuthProvider(...)` without `issuer=`| Pass `issuer=` naming the authorization server that issued the credentials (see **[Writing OAuth clients](client/oauth-clients.md#machine-to-machine)**). Without it the MCP server decides which authorization server receives them; 3.0 makes the keyword required. |
*`TokenVerifier` is a protocol with one async method. `verify_token` gets the raw token from the `Authorization` header and returns an **`AccessToken`** if it's valid, `None` if it isn't. There is nothing else to implement.
26
-
* This one looks the token up in a table. A real one verifies a JWT signature or calls the authorization server's token-introspection endpoint, and reports who the token was issued for (its `aud`) in `AccessToken.resource`. That code is yours; the SDK only calls it.
26
+
* This one looks the token up in a table; each entry records the resource it was issued for. A real one verifies a JWT signature or calls the authorization server's token-introspection endpoint, and reports who the token was issued for (its `aud`) in `AccessToken.resource`. That code is yours; the SDK only calls it.
27
27
*`token_verifier=` and `auth=` always travel together. Pass one without the other and `MCPServer(...)` raises a `ValueError` before it ever serves a request.
28
28
29
29
`AuthSettings` is the public face of your resource server:
30
30
31
31
*`issuer_url`: the authorization server that issues your tokens.
32
32
*`resource_server_url`: the public URL of this MCP endpoint. It names *which* resource a token is for, and it's where the discovery document lives.
33
33
*`required_scopes`: every token must carry all of them.
34
-
*`validate_token_resource`: refuse any token whose `AccessToken.resource` is not `resource_server_url`. Off by default.
34
+
*`validate_token_resource`: refuse any token whose `AccessToken.resource` is not `resource_server_url`. Leaving it unset warns (`MCPDeprecationWarning`) and behaves as `False`; 3.0 makes `True` the default.
35
35
* Turn it on when your authorization server binds tokens to the `resource` the client requested, which MCP clients always send. Keep `resource_server_url` the exact URL clients connect to.
36
36
* Leave it off when your authorization server uses its own audience identifiers (an Auth0 API identifier, an Entra application ID) and check `aud` in your verifier instead, returning `None` for a token that isn't for this server.
37
37
* If `aud` is a list, put the entry that equals `resource_server_url` in `resource`.
@@ -90,7 +90,7 @@ This document is how a client that has never heard of your server finds its way
90
90
91
91
Inside any handler, **`get_access_token()`** is the `AccessToken` your verifier returned for the current request:
0 commit comments