-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcp-allowlist.ts
More file actions
53 lines (46 loc) · 1.7 KB
/
Copy pathmcp-allowlist.ts
File metadata and controls
53 lines (46 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {
isMcpToolEnabled,
resolveMcpToolAllowlist,
} from "../../src/application/mcp-tool-allowlist";
import type { McpToolName } from "../../src/application/mcp-tool-allowlist";
import type { GoldenScenario } from "../query-golden/schema";
/** Minimal MCP tools for live eval arms (benchmark § Agent eval harness). */
export const LIVE_EVAL_MCP_TOOLS = ["query", "query_recipe"] as const;
export type LiveEvalMcpTool = (typeof LIVE_EVAL_MCP_TOOLS)[number];
export function defaultLiveEvalMcpToolsEnv(): string {
return LIVE_EVAL_MCP_TOOLS.join(",");
}
/** Apply eval subset when CODEMAP_MCP_TOOLS is unset or blank. */
export function ensureLiveEvalMcpToolsEnv(
env: NodeJS.ProcessEnv = process.env,
): void {
if (env.CODEMAP_MCP_TOOLS?.trim()) return;
env.CODEMAP_MCP_TOOLS = defaultLiveEvalMcpToolsEnv();
}
export function requiredMcpToolForGolden(
golden: GoldenScenario,
): LiveEvalMcpTool {
return golden.recipe !== undefined ? "query_recipe" : "query";
}
export function assertLiveEvalToolEnabled(
tool: McpToolName,
env: NodeJS.ProcessEnv = process.env,
): void {
const { allowlist } = resolveMcpToolAllowlist(env);
if (!isMcpToolEnabled(tool, allowlist)) {
const active =
allowlist === null
? "all tools"
: [...allowlist].join(", ") || "(empty allowlist)";
throw new Error(
`agent-eval live: MCP tool "${tool}" is not enabled (CODEMAP_MCP_TOOLS=${active})`,
);
}
}
export function resolveLiveEvalMcpTools(
env: NodeJS.ProcessEnv = process.env,
): readonly LiveEvalMcpTool[] {
const { allowlist } = resolveMcpToolAllowlist(env);
if (allowlist === null) return LIVE_EVAL_MCP_TOOLS;
return LIVE_EVAL_MCP_TOOLS.filter((tool) => allowlist.has(tool));
}