Repository navigation
🍒 fix: Restrict MCP Server Selections to Schedule Grants - #18420
Merged
Merged
Conversation
Under a grant, a run loads only the MCP tools the owner allowed. The filter looked only at keys naming one tool, so a key standing for every tool on a server, or for the server alone, was loaded as it was. The run policy and the call-time check still refused the calls, but the tools were defined for the model and the server was connected to. A key for every tool on a server is no longer loaded under a grant, since the grant lists tools by name. A key for the server alone is kept only where the grant lists a tool on that server for the agent.
Collaborator
Author
|
@codex review the latest head, final review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
danny-avila
marked this pull request as ready for review
November 18, 2026 16:56
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
Under a schedule's grant, a run is meant to load only the MCP tools the owner allowed (#18260). The filter that does this looked only at keys naming one tool. An agent's tool list can also carry a key that stands for every tool on a server (
sys__all__sys_mcp_<server>) or for the server alone (sys__server__sys_mcp_<server>), and those were loaded as they were.Enrollment already refuses to offer a grant for an agent that holds such a key, and the readiness check refuses an enrolled run that reaches one, so this needs an agent edited after the grant was made and a load that is not preceded by that check. In that case the calls were still refused by the run policy and at call time, but the tools the owner left out were defined for the model and the server was connected to.
A key for every tool on a server is no longer loaded under a grant: the grant lists tools by name, and "every tool" names none of them. A key for the server alone is kept only where the grant lists at least one tool on that server for the agent. A run with no grant loads its tools as before.
The complete accessible-server list passed to tool loading (
accessibleMcpServerNames) is left as it is. It is the set of names the loader checks for alias collisions between servers, not a list of servers to connect to, and narrowing it would weaken that check.Related to #18260, #13824.
How it works
const isGrantedKey = (agentId: string, toolKey: string): boolean => { const [selectionName, spelling] = splitMCPToolKey(toolKey, serverSpellings); const serverName = /* the granted server this spelling names, if any */; - return serverName != null && granted.get(serverName)?.get(agentId)?.has(selectionName) === true; + const tools = serverName == null ? undefined : granted.get(serverName)?.get(agentId); + if (!tools || selectionName === Constants.mcp_all) return false; + return selectionName === Constants.mcp_server ? tools.size > 0 : tools.has(selectionName); }; … -toolKeys.filter((key) => !isMCPToolSelection(key) || isGrantedKey(agentId, key)) +toolKeys.filter((key) => !key.includes(Constants.mcp_delimiter) || isGrantedKey(agentId, key))Type of change
Testing
Tested environments/configuration: WSL2, Node.js 24. No external services.
Automated tests:
packages/api/src/schedules/authorization/execution.spec.ts› "loads no key that stands for a whole server unless the grant lists a tool on it": for the granted agent the all-tools keys are dropped and the server key is kept only for the granted server; an agent the grant does not list keeps no MCP key. Letting thesys__keys through again makes it fail.npx tsc --noEmitis clean inpackages/api; thesrc/schedulesand agent initializer suites pass (25 suites).Risk / compatibility
Only runs under a schedule's grant are affected, and schedule consent is off by default (
interface.schedules.mcpConsent.enabled). No stored data or configuration changes.