@chkp/documentation-mcp 1.4.10 → 1.4.12
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/index.js +68 -10
- package/dist/package.json +1 -1
- package/package.json +1 -1
- package/package.json.bak +1 -1
package/dist/index.js
CHANGED
|
@@ -368,6 +368,11 @@ var init_ui_dialog = __esm({
|
|
|
368
368
|
// src/index.ts
|
|
369
369
|
import { z } from "zod";
|
|
370
370
|
|
|
371
|
+
// ../mcp-utils/dist/cli-options.js
|
|
372
|
+
function booleanOptionDefault(envValue, optionDefault) {
|
|
373
|
+
return envValue === "true" || optionDefault === "true";
|
|
374
|
+
}
|
|
375
|
+
|
|
371
376
|
// ../mcp-utils/dist/launcher.js
|
|
372
377
|
import { Command } from "commander";
|
|
373
378
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
@@ -598,6 +603,31 @@ async function trackToolCall(mcpName, toolName, clientVersion, extra) {
|
|
|
598
603
|
}
|
|
599
604
|
|
|
600
605
|
// ../mcp-utils/dist/launcher.js
|
|
606
|
+
function optionKey(flag) {
|
|
607
|
+
const long = flag.split(/[,\s]+/).find((part) => part.startsWith("--"));
|
|
608
|
+
if (!long)
|
|
609
|
+
return void 0;
|
|
610
|
+
const negated = long.startsWith("--no-");
|
|
611
|
+
return {
|
|
612
|
+
key: long.replace(/^--(no-)?/, "").replace(/-([a-z])/g, (_match, char) => char.toUpperCase()),
|
|
613
|
+
negated
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
function mirrorBooleanFlagsToEnv(config, options) {
|
|
617
|
+
for (const option of config.options) {
|
|
618
|
+
if (option.type !== "boolean" || !option.env)
|
|
619
|
+
continue;
|
|
620
|
+
const derived = optionKey(option.flag);
|
|
621
|
+
if (!derived)
|
|
622
|
+
continue;
|
|
623
|
+
if (derived.negated) {
|
|
624
|
+
throw new Error(`Option '${option.flag}' in the configuration for '${config.name}' is a negatable flag paired with env var '${option.env}', which cannot be mirrored automatically: commander keys it as '${derived.key}' and inverts its meaning, so whether the flag being present should set '${option.env}' to 'true' or 'false' depends on how that variable is named. Mirror it explicitly in launchMCPServer instead, the way --no-telemetry does for TELEMETRY_DISABLED.`);
|
|
625
|
+
}
|
|
626
|
+
if (options[derived.key] === true) {
|
|
627
|
+
process.env[option.env] = "true";
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
601
631
|
async function launchMCPServer(configPath, serverModule2) {
|
|
602
632
|
const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
|
|
603
633
|
const program = new Command();
|
|
@@ -608,7 +638,7 @@ async function launchMCPServer(configPath, serverModule2) {
|
|
|
608
638
|
const envValue = option.env ? process.env[option.env] : void 0;
|
|
609
639
|
const defaultValue = envValue || option.default;
|
|
610
640
|
if (option.type === "boolean") {
|
|
611
|
-
const boolDefault = envValue
|
|
641
|
+
const boolDefault = booleanOptionDefault(envValue, option.default);
|
|
612
642
|
program.option(option.flag, option.description, boolDefault);
|
|
613
643
|
} else {
|
|
614
644
|
program.option(option.flag, option.description, defaultValue);
|
|
@@ -632,6 +662,7 @@ async function launchMCPServer(configPath, serverModule2) {
|
|
|
632
662
|
if (options.telemetryUrl) {
|
|
633
663
|
process.env.TELEMETRY_URL = options.telemetryUrl;
|
|
634
664
|
}
|
|
665
|
+
mirrorBooleanFlagsToEnv(config, options);
|
|
635
666
|
if (!serverModule2.settingsManager) {
|
|
636
667
|
throw new Error("ServerModule must have a settingsManager. Create it with createServerModule.");
|
|
637
668
|
}
|
|
@@ -1376,10 +1407,11 @@ function wrapServerWithTracking(server2, createServerFn) {
|
|
|
1376
1407
|
newServer[reg.method](...reg.args);
|
|
1377
1408
|
}
|
|
1378
1409
|
}
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1410
|
+
const toolPolicy = typeof server2.getToolPolicy === "function" ? server2.getToolPolicy() : void 0;
|
|
1411
|
+
if (toolPolicy && typeof newServer.setToolPolicy === "function") {
|
|
1412
|
+
newServer.setToolPolicy(toolPolicy);
|
|
1413
|
+
if (typeof newServer.applyToolPolicy === "function") {
|
|
1414
|
+
newServer.applyToolPolicy();
|
|
1383
1415
|
}
|
|
1384
1416
|
}
|
|
1385
1417
|
return newServer;
|
|
@@ -1435,35 +1467,61 @@ var CPMcpServer = class extends McpServer {
|
|
|
1435
1467
|
console.error("[CPMcpServer] Setting tool policy callback");
|
|
1436
1468
|
this.toolPolicyCallback = callback;
|
|
1437
1469
|
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Get the tool policy callback, if one was set.
|
|
1472
|
+
*
|
|
1473
|
+
* Needed so the policy can be carried onto the per-session server instances
|
|
1474
|
+
* created for HTTP transport. A typed accessor keeps that transfer honest:
|
|
1475
|
+
* callers do not have to reach into the private field, where a misspelling
|
|
1476
|
+
* would go unnoticed by the compiler.
|
|
1477
|
+
*/
|
|
1478
|
+
getToolPolicy() {
|
|
1479
|
+
return this.toolPolicyCallback;
|
|
1480
|
+
}
|
|
1438
1481
|
/**
|
|
1439
1482
|
* Apply the tool policy by checking all registered tools
|
|
1440
1483
|
* This should be called after all tools are registered but before connecting
|
|
1484
|
+
*
|
|
1485
|
+
* Per-tool tracing is behind the debug flag. This used to run once per process
|
|
1486
|
+
* on the template server, where a line per tool was a cheap startup banner.
|
|
1487
|
+
* It now also runs per session under HTTP transport, so unconditional tracing
|
|
1488
|
+
* would scale stderr with sessions x tools and bury the summary. The summary
|
|
1489
|
+
* line always prints — it is the fact worth having for every session.
|
|
1441
1490
|
*/
|
|
1442
1491
|
applyToolPolicy() {
|
|
1492
|
+
const verbose = SettingsManager.globalDebugState === true || SettingsManager.globalDebugState === "true";
|
|
1443
1493
|
if (!this.toolPolicyCallback) {
|
|
1444
|
-
|
|
1494
|
+
if (verbose) {
|
|
1495
|
+
console.error("[CPMcpServer] No tool policy callback set, allowing all tools");
|
|
1496
|
+
}
|
|
1445
1497
|
return;
|
|
1446
1498
|
}
|
|
1447
|
-
console.error("[CPMcpServer] Applying tool policy");
|
|
1448
1499
|
const registeredTools = this._registeredTools;
|
|
1449
1500
|
if (!registeredTools || typeof registeredTools !== "object") {
|
|
1450
1501
|
console.error("[CPMcpServer] No tools registered yet");
|
|
1451
1502
|
return;
|
|
1452
1503
|
}
|
|
1453
1504
|
const toolNames = Object.keys(registeredTools);
|
|
1454
|
-
|
|
1505
|
+
if (verbose) {
|
|
1506
|
+
console.error(`[CPMcpServer] Applying tool policy`);
|
|
1507
|
+
console.error(`[CPMcpServer] Found ${toolNames.length} registered tools:`, toolNames);
|
|
1508
|
+
}
|
|
1455
1509
|
let enabledCount = 0;
|
|
1456
1510
|
let disabledCount = 0;
|
|
1457
1511
|
for (const [toolName, tool] of Object.entries(registeredTools)) {
|
|
1458
1512
|
const isAllowed = this.toolPolicyCallback(toolName);
|
|
1459
1513
|
if (!isAllowed) {
|
|
1460
|
-
|
|
1514
|
+
if (verbose) {
|
|
1515
|
+
console.error(`[CPMcpServer] Tool '${toolName}' is NOT allowed by policy - disabling`);
|
|
1516
|
+
}
|
|
1461
1517
|
if (typeof tool.disable === "function") {
|
|
1462
1518
|
tool.disable();
|
|
1463
1519
|
disabledCount++;
|
|
1464
1520
|
}
|
|
1465
1521
|
} else {
|
|
1466
|
-
|
|
1522
|
+
if (verbose) {
|
|
1523
|
+
console.error(`[CPMcpServer] Tool '${toolName}' is allowed by policy`);
|
|
1524
|
+
}
|
|
1467
1525
|
enabledCount++;
|
|
1468
1526
|
}
|
|
1469
1527
|
}
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
package/package.json.bak
CHANGED