fix(sdk): enforce workspace approval and block policies on toolkit endpoints (#1752) - #1846
Closed
Adityakk9031 wants to merge 2 commits into
Closed
Conversation
Adityakk9031
force-pushed
the
fix/toolkit-mcp-policies-enforcement
branch
from
August 29, 2026 07:51
6e2ce30 to
9855e18
Compare
Contributor
Author
|
@RhysSullivan have a look |
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.
Problem
Workspace approval policies (
action: "require_approval") and workspace block policies (action: "block") configured in thetool_policytable were enforced on the base/mcpendpoint and general HTTP API, but were silently bypassed on toolkit-scoped MCP endpoints (/mcp/toolkits/<slug>).When a toolkit is active, the executor assigned
activeToolPolicyProvider. InlistActivePolicyRuleSet(), the executor previously branched exclusively toactiveToolPolicyProvider, skippingcore.findMany("tool_policy", {}). Consequently, the ambient workspacetool_policytable was never evaluated for toolkit endpoints, allowing gated tools to dispatch immediately without approval or pause.Solution
combineEffectivePolicies):"block", the tool is blocked.plugin-defaultannotations.plugin-default.listActivePolicyRuleSet()fetches the workspacetool_policyrows across all executor modes.resolvePolicyFromRuleSet()evaluates both the ambient workspace policy and the active provider/prepared resolver, combining them viacombineEffectivePolicies.policiesResolve()now routes throughlistActivePolicyRuleSet()andresolvePolicyFromRuleSet()for consistent resolution.packages/core/sdk/src/policies.test.tsverifying workspacerequire_approvalandblockenforcement with activetoolPolicyProvider.packages/plugins/toolkits/src/server.test.tsverifying toolkit-scoped executors enforce workspace policies, cannot weaken workspace approval rules, and block disallowed tools.Fixes #1752