@google/gemini-cli-a2a-server 0.33.0-preview.4 → 0.33.0-preview.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a2a-server.mjs +130 -152
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/a2a-server.mjs
CHANGED
|
@@ -122500,10 +122500,36 @@ var init_tools = __esm({
|
|
|
122500
122500
|
|
|
122501
122501
|
// packages/core/dist/src/tools/mcp-tool.js
|
|
122502
122502
|
function isMcpToolName(name4) {
|
|
122503
|
-
|
|
122504
|
-
|
|
122505
|
-
|
|
122506
|
-
|
|
122503
|
+
return name4.startsWith(MCP_TOOL_PREFIX);
|
|
122504
|
+
}
|
|
122505
|
+
function parseMcpToolName(name4) {
|
|
122506
|
+
if (!isMcpToolName(name4)) {
|
|
122507
|
+
return {};
|
|
122508
|
+
}
|
|
122509
|
+
const withoutPrefix = name4.slice(MCP_TOOL_PREFIX.length);
|
|
122510
|
+
const match2 = withoutPrefix.match(/^([^_]+)_(.+)$/);
|
|
122511
|
+
if (match2) {
|
|
122512
|
+
return {
|
|
122513
|
+
serverName: match2[1],
|
|
122514
|
+
toolName: match2[2]
|
|
122515
|
+
};
|
|
122516
|
+
}
|
|
122517
|
+
return {};
|
|
122518
|
+
}
|
|
122519
|
+
function formatMcpToolName(serverName, toolName) {
|
|
122520
|
+
if (serverName === "*" && !toolName) {
|
|
122521
|
+
return `${MCP_TOOL_PREFIX}*`;
|
|
122522
|
+
} else if (serverName === "*") {
|
|
122523
|
+
return `${MCP_TOOL_PREFIX}*_${toolName}`;
|
|
122524
|
+
} else if (!toolName) {
|
|
122525
|
+
return `${MCP_TOOL_PREFIX}${serverName}_*`;
|
|
122526
|
+
} else {
|
|
122527
|
+
return `${MCP_TOOL_PREFIX}${serverName}_${toolName}`;
|
|
122528
|
+
}
|
|
122529
|
+
}
|
|
122530
|
+
function isMcpToolAnnotation(annotation) {
|
|
122531
|
+
return typeof annotation === "object" && annotation !== null && // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
122532
|
+
typeof annotation["_serverName"] === "string";
|
|
122507
122533
|
}
|
|
122508
122534
|
function transformTextBlock(block) {
|
|
122509
122535
|
return { text: block.text };
|
|
@@ -122598,24 +122624,28 @@ function getStringifiedResultForDisplay(rawResponse) {
|
|
|
122598
122624
|
return displayParts.join("\n");
|
|
122599
122625
|
}
|
|
122600
122626
|
function generateValidName(name4) {
|
|
122601
|
-
let validToolname = name4.
|
|
122627
|
+
let validToolname = name4.startsWith("mcp_") ? name4 : `mcp_${name4}`;
|
|
122628
|
+
validToolname = validToolname.replace(/[^a-zA-Z0-9_\-.:]/g, "_");
|
|
122602
122629
|
if (/^[^a-zA-Z_]/.test(validToolname)) {
|
|
122603
122630
|
validToolname = `_${validToolname}`;
|
|
122604
122631
|
}
|
|
122605
122632
|
const safeLimit = MAX_FUNCTION_NAME_LENGTH - 1;
|
|
122606
122633
|
if (validToolname.length > safeLimit) {
|
|
122634
|
+
debugLogger.warn(`Truncating MCP tool name "${validToolname}" to fit within the 64 character limit. This tool may require user approval.`);
|
|
122607
122635
|
validToolname = validToolname.slice(0, 30) + "..." + validToolname.slice(-30);
|
|
122608
122636
|
}
|
|
122609
122637
|
return validToolname;
|
|
122610
122638
|
}
|
|
122611
|
-
var MCP_QUALIFIED_NAME_SEPARATOR, DiscoveredMCPToolInvocation, DiscoveredMCPTool, MAX_FUNCTION_NAME_LENGTH;
|
|
122639
|
+
var MCP_QUALIFIED_NAME_SEPARATOR, MCP_TOOL_PREFIX, DiscoveredMCPToolInvocation, DiscoveredMCPTool, MAX_FUNCTION_NAME_LENGTH;
|
|
122612
122640
|
var init_mcp_tool = __esm({
|
|
122613
122641
|
"packages/core/dist/src/tools/mcp-tool.js"() {
|
|
122614
122642
|
"use strict";
|
|
122615
122643
|
init_safeJsonStringify();
|
|
122644
|
+
init_debugLogger();
|
|
122616
122645
|
init_tools();
|
|
122617
122646
|
init_tool_error();
|
|
122618
|
-
MCP_QUALIFIED_NAME_SEPARATOR = "
|
|
122647
|
+
MCP_QUALIFIED_NAME_SEPARATOR = "_";
|
|
122648
|
+
MCP_TOOL_PREFIX = "mcp_";
|
|
122619
122649
|
DiscoveredMCPToolInvocation = class _DiscoveredMCPToolInvocation extends BaseToolInvocation {
|
|
122620
122650
|
mcpTool;
|
|
122621
122651
|
serverName;
|
|
@@ -122757,7 +122787,7 @@ var init_mcp_tool = __esm({
|
|
|
122757
122787
|
_toolAnnotations;
|
|
122758
122788
|
constructor(mcpTool, serverName, serverToolName, description, parameterSchema, messageBus, trust, isReadOnly, nameOverride, cliConfig, extensionName, extensionId, _toolAnnotations) {
|
|
122759
122789
|
super(
|
|
122760
|
-
|
|
122790
|
+
nameOverride ?? generateValidName(`${serverName}${MCP_QUALIFIED_NAME_SEPARATOR}${serverToolName}`),
|
|
122761
122791
|
`${serverToolName} (${serverName} MCP Server)`,
|
|
122762
122792
|
description,
|
|
122763
122793
|
Kind.Other,
|
|
@@ -122792,7 +122822,7 @@ var init_mcp_tool = __esm({
|
|
|
122792
122822
|
return this._toolAnnotations;
|
|
122793
122823
|
}
|
|
122794
122824
|
getFullyQualifiedPrefix() {
|
|
122795
|
-
return `${this.serverName}${MCP_QUALIFIED_NAME_SEPARATOR}
|
|
122825
|
+
return generateValidName(`${this.serverName}${MCP_QUALIFIED_NAME_SEPARATOR}`);
|
|
122796
122826
|
}
|
|
122797
122827
|
getFullyQualifiedName() {
|
|
122798
122828
|
return generateValidName(`${this.serverName}${MCP_QUALIFIED_NAME_SEPARATOR}${this.serverToolName}`);
|
|
@@ -214180,8 +214210,8 @@ var GIT_COMMIT_INFO, CLI_VERSION;
|
|
|
214180
214210
|
var init_git_commit = __esm({
|
|
214181
214211
|
"packages/core/dist/src/generated/git-commit.js"() {
|
|
214182
214212
|
"use strict";
|
|
214183
|
-
GIT_COMMIT_INFO = "
|
|
214184
|
-
CLI_VERSION = "0.33.0-preview.
|
|
214213
|
+
GIT_COMMIT_INFO = "a6256cdab";
|
|
214214
|
+
CLI_VERSION = "0.33.0-preview.5";
|
|
214185
214215
|
}
|
|
214186
214216
|
});
|
|
214187
214217
|
|
|
@@ -291439,7 +291469,7 @@ function getVersion() {
|
|
|
291439
291469
|
}
|
|
291440
291470
|
versionPromise = (async () => {
|
|
291441
291471
|
const pkgJson = await getPackageJson(__dirname3);
|
|
291442
|
-
return "0.33.0-preview.
|
|
291472
|
+
return "0.33.0-preview.5";
|
|
291443
291473
|
})();
|
|
291444
291474
|
return versionPromise;
|
|
291445
291475
|
}
|
|
@@ -293618,11 +293648,11 @@ Signal: Signal number or \`(none)\` if no signal was received.
|
|
|
293618
293648
|
buildToolMetadata() {
|
|
293619
293649
|
const toolMetadata = /* @__PURE__ */ new Map();
|
|
293620
293650
|
for (const [name4, tool] of this.allKnownTools) {
|
|
293621
|
-
|
|
293622
|
-
|
|
293623
|
-
|
|
293624
|
-
|
|
293625
|
-
|
|
293651
|
+
const metadata2 = tool.toolAnnotations ? { ...tool.toolAnnotations } : {};
|
|
293652
|
+
if (tool instanceof DiscoveredMCPTool) {
|
|
293653
|
+
metadata2["_serverName"] = tool.serverName;
|
|
293654
|
+
}
|
|
293655
|
+
if (Object.keys(metadata2).length > 0) {
|
|
293626
293656
|
toolMetadata.set(name4, metadata2);
|
|
293627
293657
|
}
|
|
293628
293658
|
}
|
|
@@ -400313,34 +400343,17 @@ function matchesWildcard(pattern, toolName, serverName) {
|
|
|
400313
400343
|
if (pattern === "*") {
|
|
400314
400344
|
return true;
|
|
400315
400345
|
}
|
|
400316
|
-
if (pattern
|
|
400317
|
-
return
|
|
400318
|
-
}
|
|
400319
|
-
return toolName === pattern;
|
|
400320
|
-
}
|
|
400321
|
-
function matchesCompositePattern(pattern, toolName, serverName) {
|
|
400322
|
-
const parts2 = pattern.split("__");
|
|
400323
|
-
if (parts2.length !== 2)
|
|
400324
|
-
return false;
|
|
400325
|
-
const [patternServer, patternTool] = parts2;
|
|
400326
|
-
const { actualServer, actualTool } = getToolMetadata(toolName, serverName);
|
|
400327
|
-
if (actualServer === void 0) {
|
|
400328
|
-
return false;
|
|
400346
|
+
if (pattern === `${MCP_TOOL_PREFIX}*`) {
|
|
400347
|
+
return serverName !== void 0;
|
|
400329
400348
|
}
|
|
400330
|
-
if (
|
|
400331
|
-
|
|
400349
|
+
if (pattern.startsWith(MCP_TOOL_PREFIX) && pattern.endsWith("_*")) {
|
|
400350
|
+
const expectedServerName = pattern.slice(MCP_TOOL_PREFIX.length, -2);
|
|
400351
|
+
if (serverName === void 0 || serverName !== expectedServerName) {
|
|
400352
|
+
return false;
|
|
400353
|
+
}
|
|
400354
|
+
return toolName.startsWith(`${MCP_TOOL_PREFIX}${expectedServerName}_`);
|
|
400332
400355
|
}
|
|
400333
|
-
|
|
400334
|
-
const toolMatch = patternTool === "*" || patternTool === actualTool;
|
|
400335
|
-
return serverMatch && toolMatch;
|
|
400336
|
-
}
|
|
400337
|
-
function getToolMetadata(toolName, serverName) {
|
|
400338
|
-
const sepIndex = toolName.indexOf("__");
|
|
400339
|
-
const isQualified = sepIndex !== -1;
|
|
400340
|
-
return {
|
|
400341
|
-
actualServer: serverName ?? (isQualified ? toolName.substring(0, sepIndex) : void 0),
|
|
400342
|
-
actualTool: isQualified ? toolName.substring(sepIndex + 2) : toolName
|
|
400343
|
-
};
|
|
400356
|
+
return toolName === pattern;
|
|
400344
400357
|
}
|
|
400345
400358
|
function ruleMatches(rule, toolCall, stringifiedArgs, serverName, currentApprovalMode, toolAnnotations) {
|
|
400346
400359
|
if (rule.modes && rule.modes.length > 0) {
|
|
@@ -400348,6 +400361,15 @@ function ruleMatches(rule, toolCall, stringifiedArgs, serverName, currentApprova
|
|
|
400348
400361
|
return false;
|
|
400349
400362
|
}
|
|
400350
400363
|
}
|
|
400364
|
+
if (rule.mcpName) {
|
|
400365
|
+
if (rule.mcpName === "*") {
|
|
400366
|
+
if (serverName === void 0)
|
|
400367
|
+
return false;
|
|
400368
|
+
} else {
|
|
400369
|
+
if (serverName !== rule.mcpName)
|
|
400370
|
+
return false;
|
|
400371
|
+
}
|
|
400372
|
+
}
|
|
400351
400373
|
if (rule.toolName) {
|
|
400352
400374
|
if (rule.toolName === "*") {
|
|
400353
400375
|
} else if (isWildcardPattern(rule.toolName)) {
|
|
@@ -400389,6 +400411,7 @@ var init_policy_engine = __esm({
|
|
|
400389
400411
|
init_protocol2();
|
|
400390
400412
|
init_shell_utils();
|
|
400391
400413
|
init_tool_names();
|
|
400414
|
+
init_mcp_tool();
|
|
400392
400415
|
PolicyEngine = class {
|
|
400393
400416
|
rules;
|
|
400394
400417
|
checkers;
|
|
@@ -400517,6 +400540,15 @@ var init_policy_engine = __esm({
|
|
|
400517
400540
|
* Returns the decision and the matching rule (if any).
|
|
400518
400541
|
*/
|
|
400519
400542
|
async check(toolCall, serverName, toolAnnotations) {
|
|
400543
|
+
if (!serverName && isMcpToolAnnotation(toolAnnotations)) {
|
|
400544
|
+
serverName = toolAnnotations._serverName;
|
|
400545
|
+
}
|
|
400546
|
+
if (!serverName && toolCall.name) {
|
|
400547
|
+
const parsed = parseMcpToolName(toolCall.name);
|
|
400548
|
+
if (parsed.serverName) {
|
|
400549
|
+
serverName = parsed.serverName;
|
|
400550
|
+
}
|
|
400551
|
+
}
|
|
400520
400552
|
let stringifiedArgs;
|
|
400521
400553
|
if (toolCall.args && (this.rules.some((rule) => rule.argsPattern) || this.checkers.some((checker) => checker.argsPattern))) {
|
|
400522
400554
|
stringifiedArgs = stableStringify(toolCall.args);
|
|
@@ -400538,12 +400570,6 @@ var init_policy_engine = __esm({
|
|
|
400538
400570
|
const toolCallsToTry = [];
|
|
400539
400571
|
for (const name4 of toolNamesToTry) {
|
|
400540
400572
|
toolCallsToTry.push({ ...toolCall, name: name4 });
|
|
400541
|
-
if (serverName && !name4.includes("__")) {
|
|
400542
|
-
toolCallsToTry.push({
|
|
400543
|
-
...toolCall,
|
|
400544
|
-
name: `${serverName}__${name4}`
|
|
400545
|
-
});
|
|
400546
|
-
}
|
|
400547
400573
|
}
|
|
400548
400574
|
for (const rule of this.rules) {
|
|
400549
400575
|
const match2 = toolCallsToTry.some((tc) => ruleMatches(rule, tc, stringifiedArgs, serverName, this.approvalMode, toolAnnotations));
|
|
@@ -400689,107 +400715,52 @@ var init_policy_engine = __esm({
|
|
|
400689
400715
|
*/
|
|
400690
400716
|
getExcludedTools(toolMetadata, allToolNames) {
|
|
400691
400717
|
const excludedTools = /* @__PURE__ */ new Set();
|
|
400692
|
-
|
|
400693
|
-
|
|
400694
|
-
|
|
400695
|
-
|
|
400696
|
-
|
|
400697
|
-
|
|
400698
|
-
|
|
400699
|
-
|
|
400700
|
-
|
|
400701
|
-
|
|
400702
|
-
|
|
400703
|
-
|
|
400704
|
-
|
|
400705
|
-
|
|
400706
|
-
|
|
400707
|
-
|
|
400708
|
-
|
|
400709
|
-
|
|
400710
|
-
|
|
400711
|
-
|
|
400712
|
-
|
|
400713
|
-
|
|
400714
|
-
|
|
400715
|
-
|
|
400716
|
-
|
|
400717
|
-
annotationsMatch = false;
|
|
400718
|
+
if (!allToolNames) {
|
|
400719
|
+
return excludedTools;
|
|
400720
|
+
}
|
|
400721
|
+
for (const toolName of allToolNames) {
|
|
400722
|
+
const annotations = toolMetadata?.get(toolName);
|
|
400723
|
+
const serverName = isMcpToolAnnotation(annotations) ? annotations._serverName : void 0;
|
|
400724
|
+
let staticallyExcluded = false;
|
|
400725
|
+
let matchFound = false;
|
|
400726
|
+
for (const rule of this.rules) {
|
|
400727
|
+
const ruleWithoutArgs = { ...rule, argsPattern: void 0 };
|
|
400728
|
+
const toolCall = { name: toolName, args: {} };
|
|
400729
|
+
const appliesToTool = ruleMatches(
|
|
400730
|
+
ruleWithoutArgs,
|
|
400731
|
+
toolCall,
|
|
400732
|
+
void 0,
|
|
400733
|
+
// stringifiedArgs
|
|
400734
|
+
serverName,
|
|
400735
|
+
this.approvalMode,
|
|
400736
|
+
annotations
|
|
400737
|
+
);
|
|
400738
|
+
if (appliesToTool) {
|
|
400739
|
+
if (rule.argsPattern) {
|
|
400740
|
+
if (rule.decision !== PolicyDecision.DENY) {
|
|
400741
|
+
staticallyExcluded = false;
|
|
400742
|
+
matchFound = true;
|
|
400718
400743
|
break;
|
|
400719
400744
|
}
|
|
400720
|
-
}
|
|
400721
|
-
if (!annotationsMatch) {
|
|
400722
400745
|
continue;
|
|
400723
|
-
}
|
|
400724
|
-
if (rule.toolName) {
|
|
400725
|
-
if (isWildcardPattern(rule.toolName)) {
|
|
400726
|
-
const rawServerName = annotations["_serverName"];
|
|
400727
|
-
const serverName = typeof rawServerName === "string" ? rawServerName : void 0;
|
|
400728
|
-
const qualifiedName = serverName && !toolName2.includes("__") ? `${serverName}__${toolName2}` : toolName2;
|
|
400729
|
-
if (!matchesWildcard(rule.toolName, qualifiedName, void 0)) {
|
|
400730
|
-
continue;
|
|
400731
|
-
}
|
|
400732
|
-
} else if (toolName2 !== rule.toolName) {
|
|
400733
|
-
continue;
|
|
400734
|
-
}
|
|
400735
|
-
}
|
|
400736
|
-
let decision2;
|
|
400737
|
-
if (globalVerdict !== void 0) {
|
|
400738
|
-
decision2 = globalVerdict;
|
|
400739
400746
|
} else {
|
|
400740
|
-
|
|
400741
|
-
|
|
400742
|
-
|
|
400743
|
-
excludedTools.add(toolName2);
|
|
400744
|
-
}
|
|
400745
|
-
processedTools.add(toolName2);
|
|
400746
|
-
}
|
|
400747
|
-
continue;
|
|
400748
|
-
}
|
|
400749
|
-
if (!rule.toolName) {
|
|
400750
|
-
if (globalVerdict === void 0) {
|
|
400751
|
-
globalVerdict = rule.decision;
|
|
400752
|
-
if (globalVerdict !== PolicyDecision.DENY) {
|
|
400747
|
+
const decision = this.applyNonInteractiveMode(rule.decision);
|
|
400748
|
+
staticallyExcluded = decision === PolicyDecision.DENY;
|
|
400749
|
+
matchFound = true;
|
|
400753
400750
|
break;
|
|
400754
400751
|
}
|
|
400755
400752
|
}
|
|
400756
|
-
continue;
|
|
400757
|
-
}
|
|
400758
|
-
const toolName = rule.toolName;
|
|
400759
|
-
if (processedTools.has(toolName)) {
|
|
400760
|
-
continue;
|
|
400761
400753
|
}
|
|
400762
|
-
|
|
400763
|
-
|
|
400764
|
-
if (
|
|
400765
|
-
|
|
400766
|
-
excludedTools.add(toolName);
|
|
400767
|
-
}
|
|
400768
|
-
coveredByWildcard = true;
|
|
400769
|
-
break;
|
|
400754
|
+
if (!matchFound) {
|
|
400755
|
+
const defaultDec = this.applyNonInteractiveMode(this.defaultDecision);
|
|
400756
|
+
if (defaultDec === PolicyDecision.DENY) {
|
|
400757
|
+
staticallyExcluded = true;
|
|
400770
400758
|
}
|
|
400771
400759
|
}
|
|
400772
|
-
if (
|
|
400773
|
-
continue;
|
|
400774
|
-
}
|
|
400775
|
-
processedTools.add(toolName);
|
|
400776
|
-
let decision;
|
|
400777
|
-
if (globalVerdict !== void 0) {
|
|
400778
|
-
decision = globalVerdict;
|
|
400779
|
-
} else {
|
|
400780
|
-
decision = rule.decision;
|
|
400781
|
-
}
|
|
400782
|
-
if (decision === PolicyDecision.DENY) {
|
|
400760
|
+
if (staticallyExcluded) {
|
|
400783
400761
|
excludedTools.add(toolName);
|
|
400784
400762
|
}
|
|
400785
400763
|
}
|
|
400786
|
-
if (globalVerdict === PolicyDecision.DENY && allToolNames) {
|
|
400787
|
-
for (const name4 of allToolNames) {
|
|
400788
|
-
if (!processedTools.has(name4)) {
|
|
400789
|
-
excludedTools.add(name4);
|
|
400790
|
-
}
|
|
400791
|
-
}
|
|
400792
|
-
}
|
|
400793
400764
|
return excludedTools;
|
|
400794
400765
|
}
|
|
400795
400766
|
applyNonInteractiveMode(decision) {
|
|
@@ -414054,7 +414025,10 @@ function validateShellCommandSyntax(rule, ruleIndex) {
|
|
|
414054
414025
|
return null;
|
|
414055
414026
|
}
|
|
414056
414027
|
function validateToolName(name4, ruleIndex) {
|
|
414057
|
-
if (
|
|
414028
|
+
if (name4.includes("__")) {
|
|
414029
|
+
return `Rule #${ruleIndex + 1}: The "__" syntax for MCP tools is strictly deprecated. Please use the 'mcpName = "..."' property or the 'mcp_server_tool' format instead.`;
|
|
414030
|
+
}
|
|
414031
|
+
if (isValidToolName(name4, { allowWildcards: true })) {
|
|
414058
414032
|
return null;
|
|
414059
414033
|
}
|
|
414060
414034
|
const allNames = [...ALL_BUILTIN_TOOL_NAMES];
|
|
@@ -414139,8 +414113,6 @@ async function loadPoliciesFromToml(policyPaths, getPolicyTier) {
|
|
|
414139
414113
|
}
|
|
414140
414114
|
for (let i4 = 0; i4 < tomlRules.length; i4++) {
|
|
414141
414115
|
const rule = tomlRules[i4];
|
|
414142
|
-
if (rule.mcpName)
|
|
414143
|
-
continue;
|
|
414144
414116
|
const toolNames = rule.toolName ? Array.isArray(rule.toolName) ? rule.toolName : [rule.toolName] : [];
|
|
414145
414117
|
for (const name4 of toolNames) {
|
|
414146
414118
|
const warning = validateToolName(name4, i4);
|
|
@@ -414163,16 +414135,14 @@ async function loadPoliciesFromToml(policyPaths, getPolicyTier) {
|
|
|
414163
414135
|
return argsPatterns.flatMap((argsPattern) => {
|
|
414164
414136
|
const toolNames = rule.toolName ? Array.isArray(rule.toolName) ? rule.toolName : [rule.toolName] : [void 0];
|
|
414165
414137
|
return toolNames.map((toolName) => {
|
|
414166
|
-
let effectiveToolName;
|
|
414167
|
-
|
|
414168
|
-
|
|
414169
|
-
|
|
414170
|
-
effectiveToolName = `${rule.mcpName}__*`;
|
|
414171
|
-
} else {
|
|
414172
|
-
effectiveToolName = toolName;
|
|
414138
|
+
let effectiveToolName = toolName;
|
|
414139
|
+
const mcpName = rule.mcpName;
|
|
414140
|
+
if (mcpName) {
|
|
414141
|
+
effectiveToolName = formatMcpToolName(mcpName, effectiveToolName);
|
|
414173
414142
|
}
|
|
414174
414143
|
const policyRule = {
|
|
414175
414144
|
toolName: effectiveToolName,
|
|
414145
|
+
mcpName: rule.mcpName,
|
|
414176
414146
|
decision: rule.decision,
|
|
414177
414147
|
priority: transformPriority(rule.priority, tier),
|
|
414178
414148
|
modes: rule.modes,
|
|
@@ -414246,14 +414216,15 @@ Error: ${error2.message}`,
|
|
|
414246
414216
|
return toolNames.map((toolName) => {
|
|
414247
414217
|
let effectiveToolName;
|
|
414248
414218
|
if (checker.mcpName && toolName) {
|
|
414249
|
-
effectiveToolName = `${checker.mcpName}
|
|
414219
|
+
effectiveToolName = `${MCP_TOOL_PREFIX}${checker.mcpName}_${toolName}`;
|
|
414250
414220
|
} else if (checker.mcpName) {
|
|
414251
|
-
effectiveToolName = `${checker.mcpName}
|
|
414221
|
+
effectiveToolName = `${MCP_TOOL_PREFIX}${checker.mcpName}_*`;
|
|
414252
414222
|
} else {
|
|
414253
414223
|
effectiveToolName = toolName;
|
|
414254
414224
|
}
|
|
414255
414225
|
const safetyCheckerRule = {
|
|
414256
414226
|
toolName: effectiveToolName,
|
|
414227
|
+
mcpName: checker.mcpName,
|
|
414257
414228
|
priority: transformPriority(checker.priority, tier),
|
|
414258
414229
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
414259
414230
|
checker: checker.checker,
|
|
@@ -414312,14 +414283,19 @@ Error: ${error2.message}`
|
|
|
414312
414283
|
return { rules, checkers, errors };
|
|
414313
414284
|
}
|
|
414314
414285
|
function validateMcpPolicyToolNames(serverName, discoveredToolNames, policyRules) {
|
|
414315
|
-
const prefix = `${serverName}
|
|
414286
|
+
const prefix = `${MCP_TOOL_PREFIX}${serverName}_`;
|
|
414316
414287
|
const warnings = [];
|
|
414317
414288
|
for (const rule of policyRules) {
|
|
414318
414289
|
if (!rule.toolName)
|
|
414319
414290
|
continue;
|
|
414320
|
-
|
|
414291
|
+
let toolPart;
|
|
414292
|
+
if (rule.mcpName === serverName && rule.toolName.startsWith(prefix)) {
|
|
414293
|
+
toolPart = rule.toolName.slice(prefix.length);
|
|
414294
|
+
} else if (rule.toolName.startsWith(prefix)) {
|
|
414295
|
+
toolPart = rule.toolName.slice(prefix.length);
|
|
414296
|
+
} else {
|
|
414321
414297
|
continue;
|
|
414322
|
-
|
|
414298
|
+
}
|
|
414323
414299
|
if (toolPart === "*")
|
|
414324
414300
|
continue;
|
|
414325
414301
|
if (discoveredToolNames.includes(toolPart))
|
|
@@ -414347,6 +414323,7 @@ var init_toml_loader = __esm({
|
|
|
414347
414323
|
import_toml = __toESM(require_toml(), 1);
|
|
414348
414324
|
init_zod();
|
|
414349
414325
|
init_errors();
|
|
414326
|
+
init_mcp_tool();
|
|
414350
414327
|
MAX_TYPO_DISTANCE = 3;
|
|
414351
414328
|
PolicyRuleSchema = external_exports.object({
|
|
414352
414329
|
toolName: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]).optional(),
|
|
@@ -414429,6 +414406,7 @@ var init_config3 = __esm({
|
|
|
414429
414406
|
init_shell_utils();
|
|
414430
414407
|
init_tool_names();
|
|
414431
414408
|
init_errors();
|
|
414409
|
+
init_mcp_tool();
|
|
414432
414410
|
init_security();
|
|
414433
414411
|
__filename3 = fileURLToPath15(import.meta.url);
|
|
414434
414412
|
__dirname7 = path77.dirname(__filename3);
|