Set MCP parent on resource entities for server-scoped policies#4965
Merged
Set MCP parent on resource entities for server-scoped policies#4965
Conversation
When serverName is configured on the Cedar authorizer, resource entities (Tool, Prompt, Resource) need an MCP parent so that server-scoped Cedar policies like `resource in MCP::"github"` evaluate correctly. Without this parent, those policies silently match nothing and deny all requests. Add serverName parameter to CreateEntitiesForRequest and build an MCP::"<serverName>" parent UID when non-empty. Thread a.serverName through all four authorize* methods in core.go. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
936ad59 to
3cbc17e
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4965 +/- ##
==========================================
- Coverage 69.55% 69.49% -0.07%
==========================================
Files 551 551
Lines 55906 55917 +11
==========================================
- Hits 38887 38858 -29
- Misses 14025 14063 +38
- Partials 2994 2996 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
amirejaz
approved these changes
Apr 21, 2026
This was referenced Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Server-scoped Cedar policies like
resource in MCP::"github"silently matched nothing because resource entities (Tool, Prompt, Resource) had no MCP parent in their entity hierarchy. The serverName stored on the authorizer (#4861) was available but unused when building request entities.a.serverNamethroughauthorizeToolCall,authorizePromptGet,authorizeResourceRead, andauthorizeFeatureListintoCreateEntitiesForRequestserverNameis non-empty, addMCP::"<serverName>"as a parent UID on the resource entity so Cedar'sinoperator can traverse the hierarchyAuthorizeWithJWTClaims(the production entry point) to pin the serverName threading at all four call sitesType of change
Test plan
task test)task lint-fix)Tested end-to-end on a Kind cluster with a real Entra ID token (
roles: ["developer", "mcp-admin"]) against two MCPServers sharing one compiled Cedar ConfigMap with server-scoped policies:permit(principal in THVRole::"dev-access", action, resource in MCP::"github")— github server:tools/listreturned tools,call_toolreturned HTTP 200permit(principal in THVRole::"ops-access", action, resource in MCP::"internal-tools")— internal-tools server:call_toolreturned HTTP 403 (noops-teamrole in token, default deny)Does this introduce a user-facing change?
No — enables server-scoped Cedar policies that were previously inert.
Special notes for reviewers
The test uses
AuthorizeWithJWTClaimsrather than callingCreateEntitiesForRequestdirectly, so it would fail if any of the foura.serverNamecall sites were accidentally dropped.Generated with Claude Code