Files
OmniRoute/tests/unit/compression/compression-tool-cardinality-env.test.ts
Diego Rodrigues de Sa e Souza 3c9883bb73 Release v3.8.29 (#4126)
OmniRoute v3.8.29 — 115 commits since v3.8.28. Full CHANGELOG + 41 i18n mirrors. All content quality gates green (build, unit 8/8, vitest 188/188, PR test policy, quality gates extended, docs sync, quality ratchet). Remaining red CI checks are pre-existing release flakes (coverage-shard/integration/node-compat teardown), a new transitive undici advisory in electron devDeps, and a workflow-level CodeQL fail (0 open alerts). VPS-validated by the operator.
2026-06-19 06:49:01 -03:00

37 lines
1.8 KiB
TypeScript

import { describe, it } from "node:test";
import assert from "node:assert/strict";
import {
readMcpToolProfileFromEnv,
reduceToolManifest,
} from "../../../open-sse/mcp-server/toolCardinality.ts";
// F4.3 wiring: the MCP server now consults an opt-in tool profile (MCP_TOOL_DENY / MCP_TOOL_ALLOW)
// and disables denied tools so they are not announced to the model (token savings). Default (no
// env) is a no-op — every tool stays registered.
describe("MCP tool profile from env (cardinality opt-in)", () => {
it("returns null when no deny/allow env is set (no-op)", () => {
assert.equal(readMcpToolProfileFromEnv({}), null);
assert.equal(readMcpToolProfileFromEnv({ MCP_TOOL_DENY: "", MCP_TOOL_ALLOW: " " }), null);
});
it("parses MCP_TOOL_DENY / MCP_TOOL_ALLOW into a profile (trimmed, empties dropped)", () => {
const p = readMcpToolProfileFromEnv({ MCP_TOOL_DENY: "a, b ,c", MCP_TOOL_ALLOW: "x ," });
assert.deepEqual(p?.denyTools, ["a", "b", "c"]);
assert.deepEqual(p?.allowTools, ["x"]);
});
it("the deny gate drops a denied tool and keeps others (single-entry manifest decision)", () => {
const profile = readMcpToolProfileFromEnv({ MCP_TOOL_DENY: "noisy_tool" });
assert.ok(profile);
assert.equal(reduceToolManifest([{ name: "noisy_tool", scopes: [] }], profile).length, 0);
assert.equal(reduceToolManifest([{ name: "useful_tool", scopes: [] }], profile).length, 1);
});
it("allow-list mode keeps only the listed tools", () => {
const profile = readMcpToolProfileFromEnv({ MCP_TOOL_ALLOW: "keep_me" });
assert.ok(profile);
assert.equal(reduceToolManifest([{ name: "keep_me", scopes: [] }], profile).length, 1);
assert.equal(reduceToolManifest([{ name: "other", scopes: [] }], profile).length, 0);
});
});