fix(policy): honor plugin group for declared mcp denies

This commit is contained in:
Gio Della-Libera
2026-06-15 06:43:11 -07:00
parent fdf23e668a
commit 30bd34dd7e
2 changed files with 30 additions and 0 deletions

View File

@@ -46,6 +46,7 @@ function denylistBlocksMcpServer(params: {
}): boolean {
return (
denylistBlocksName("bundle-mcp", params.denylist) ||
matchesAnyGlobPattern("group:plugins", params.denylist) ||
denylistContainsMcpServerEntry({
safeServerName: params.safeServerName,
rawDenylist: params.rawDenylist,

View File

@@ -336,6 +336,35 @@ describe("tool-policy-pipeline", () => {
]);
});
test("warns when plugin group is denied and MCP server namespace is allowlisted", () => {
const warnings: string[] = [];
const declared = buildDeclaredToolAllowlistContext({
config: {
mcp: { servers: { paperless: { command: "paperless-mcp" } } },
},
workspaceDir: process.cwd(),
toolDenylist: ["group:plugins"],
});
applyToolPolicyPipeline({
tools: [{ name: "exec" }] as any,
toolMeta: () => undefined,
warn: (msg) => warnings.push(msg),
declaredToolAllowlist: declared,
steps: [
{
policy: { allow: ["paperless__*"] },
label: "tools.allow",
stripPluginOnlyAllowlist: true,
},
],
});
expect(warnings).toEqual([
"tools: tools.allow allowlist contains unknown entries (paperless__*). These entries won't match any tool unless the plugin is enabled.",
]);
});
test("warns when denied duplicate-safe MCP server namespace is allowlisted", () => {
const warnings: string[] = [];
const declared = buildDeclaredToolAllowlistContext({