MCP authorization
ThemcpAuthorization policy on an MCP route defines which users can access which tools and resources. Rules are evaluated against the authenticated JWT subject and claims.
Tools and resources that a user is not permitted to access are automatically filtered out of the tools/list and resources/list responses. If a user attempts to call a denied tool directly, the call is also rejected.
Configuration
Here is the full authorization example config fromexamples/authorization/config.yaml:
config.yaml
jwtAuth handles authentication (token validation), while mcpAuthorization handles authorization (what a validated user may do). Both are required for JWT-claim-based rules.
CEL rule syntax
Each rule inmcpAuthorization.rules is a CEL expression that evaluates to a boolean. A request is permitted if any rule evaluates to true.
Allow a tool to all authenticated users
Allow a tool to all authenticated users
echo tool. No JWT claim check is required.Restrict a tool to a specific user
Restrict a tool to a specific user
sub claim is test-user can call add. All other users see this tool filtered from their tool list.Allow access based on a JWT claim value
Allow access based on a JWT claim value
nested.key == "value" may call printEnv. Nested JWT claims are accessed with dot notation: jwt.<field>.<subfield>.Allow a list of tools
Allow a list of tools
Available CEL fields
| Field | Type | Description |
|---|---|---|
mcp.tool.name | string | Name of the MCP tool being called |
jwt.sub | string | Subject claim from the JWT |
jwt.<claim> | any | Any top-level JWT claim |
jwt.<claim>.<field> | any | Nested JWT claim accessed with dot notation |
Rule evaluation
Rules are evaluated in order. A request is permitted as soon as any rule evaluates totrue. If no rule matches, the request is denied.
When
mcpAuthorization is configured, tools are filtered proactively. Clients see only the tools they are permitted to access in tools/list responses — they cannot discover tools they do not have access to.Testing authorization rules
Connect with a restricted token
Use the example token
manifests/jwt/pub-key/example2.key. This token has sub: test-user and no extra claims.Paste the token into MCP Inspector under Authentication > Bearer Token and run List Tools.You should see only echo and add — the two tools accessible to test-user without additional claims.HTTP authorization
For plain HTTP routes, use theauthorization policy instead of mcpAuthorization. The syntax is the same — a list of CEL rules — but the available fields reflect HTTP request context.
HTTP authorization rules apply to all traffic on the route, not just MCP protocol calls. Use
mcpAuthorization specifically when the backend is an MCP server.Combining authentication and authorization
Authentication (jwtAuth or mcpAuthentication) must be configured alongside authorization to make JWT claims available in rules. The typical pattern is: