@chkp/harmony-email-mcp 0.1.1 → 0.1.3
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
|
@@ -365,6 +365,11 @@ var init_ui_dialog = __esm({
|
|
|
365
365
|
}
|
|
366
366
|
});
|
|
367
367
|
|
|
368
|
+
// ../mcp-utils/dist/cli-options.js
|
|
369
|
+
function booleanOptionDefault(envValue, optionDefault) {
|
|
370
|
+
return envValue === "true" || optionDefault === "true";
|
|
371
|
+
}
|
|
372
|
+
|
|
368
373
|
// ../mcp-utils/dist/launcher.js
|
|
369
374
|
import { Command } from "commander";
|
|
370
375
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
@@ -595,6 +600,31 @@ async function trackToolCall(mcpName, toolName, clientVersion, extra) {
|
|
|
595
600
|
}
|
|
596
601
|
|
|
597
602
|
// ../mcp-utils/dist/launcher.js
|
|
603
|
+
function optionKey(flag) {
|
|
604
|
+
const long = flag.split(/[,\s]+/).find((part) => part.startsWith("--"));
|
|
605
|
+
if (!long)
|
|
606
|
+
return void 0;
|
|
607
|
+
const negated = long.startsWith("--no-");
|
|
608
|
+
return {
|
|
609
|
+
key: long.replace(/^--(no-)?/, "").replace(/-([a-z])/g, (_match, char) => char.toUpperCase()),
|
|
610
|
+
negated
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
function mirrorBooleanFlagsToEnv(config, options) {
|
|
614
|
+
for (const option of config.options) {
|
|
615
|
+
if (option.type !== "boolean" || !option.env)
|
|
616
|
+
continue;
|
|
617
|
+
const derived = optionKey(option.flag);
|
|
618
|
+
if (!derived)
|
|
619
|
+
continue;
|
|
620
|
+
if (derived.negated) {
|
|
621
|
+
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.`);
|
|
622
|
+
}
|
|
623
|
+
if (options[derived.key] === true) {
|
|
624
|
+
process.env[option.env] = "true";
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
598
628
|
async function launchMCPServer(configPath, serverModule2) {
|
|
599
629
|
const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
|
|
600
630
|
const program = new Command();
|
|
@@ -605,7 +635,7 @@ async function launchMCPServer(configPath, serverModule2) {
|
|
|
605
635
|
const envValue = option.env ? process.env[option.env] : void 0;
|
|
606
636
|
const defaultValue = envValue || option.default;
|
|
607
637
|
if (option.type === "boolean") {
|
|
608
|
-
const boolDefault = envValue
|
|
638
|
+
const boolDefault = booleanOptionDefault(envValue, option.default);
|
|
609
639
|
program.option(option.flag, option.description, boolDefault);
|
|
610
640
|
} else {
|
|
611
641
|
program.option(option.flag, option.description, defaultValue);
|
|
@@ -629,6 +659,7 @@ async function launchMCPServer(configPath, serverModule2) {
|
|
|
629
659
|
if (options.telemetryUrl) {
|
|
630
660
|
process.env.TELEMETRY_URL = options.telemetryUrl;
|
|
631
661
|
}
|
|
662
|
+
mirrorBooleanFlagsToEnv(config, options);
|
|
632
663
|
if (!serverModule2.settingsManager) {
|
|
633
664
|
throw new Error("ServerModule must have a settingsManager. Create it with createServerModule.");
|
|
634
665
|
}
|
|
@@ -1367,10 +1398,11 @@ function wrapServerWithTracking(server2, createServerFn) {
|
|
|
1367
1398
|
newServer[reg.method](...reg.args);
|
|
1368
1399
|
}
|
|
1369
1400
|
}
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1401
|
+
const toolPolicy = typeof server2.getToolPolicy === "function" ? server2.getToolPolicy() : void 0;
|
|
1402
|
+
if (toolPolicy && typeof newServer.setToolPolicy === "function") {
|
|
1403
|
+
newServer.setToolPolicy(toolPolicy);
|
|
1404
|
+
if (typeof newServer.applyToolPolicy === "function") {
|
|
1405
|
+
newServer.applyToolPolicy();
|
|
1374
1406
|
}
|
|
1375
1407
|
}
|
|
1376
1408
|
return newServer;
|
|
@@ -1426,35 +1458,61 @@ var CPMcpServer = class extends McpServer {
|
|
|
1426
1458
|
console.error("[CPMcpServer] Setting tool policy callback");
|
|
1427
1459
|
this.toolPolicyCallback = callback;
|
|
1428
1460
|
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Get the tool policy callback, if one was set.
|
|
1463
|
+
*
|
|
1464
|
+
* Needed so the policy can be carried onto the per-session server instances
|
|
1465
|
+
* created for HTTP transport. A typed accessor keeps that transfer honest:
|
|
1466
|
+
* callers do not have to reach into the private field, where a misspelling
|
|
1467
|
+
* would go unnoticed by the compiler.
|
|
1468
|
+
*/
|
|
1469
|
+
getToolPolicy() {
|
|
1470
|
+
return this.toolPolicyCallback;
|
|
1471
|
+
}
|
|
1429
1472
|
/**
|
|
1430
1473
|
* Apply the tool policy by checking all registered tools
|
|
1431
1474
|
* This should be called after all tools are registered but before connecting
|
|
1475
|
+
*
|
|
1476
|
+
* Per-tool tracing is behind the debug flag. This used to run once per process
|
|
1477
|
+
* on the template server, where a line per tool was a cheap startup banner.
|
|
1478
|
+
* It now also runs per session under HTTP transport, so unconditional tracing
|
|
1479
|
+
* would scale stderr with sessions x tools and bury the summary. The summary
|
|
1480
|
+
* line always prints — it is the fact worth having for every session.
|
|
1432
1481
|
*/
|
|
1433
1482
|
applyToolPolicy() {
|
|
1483
|
+
const verbose = SettingsManager.globalDebugState === true || SettingsManager.globalDebugState === "true";
|
|
1434
1484
|
if (!this.toolPolicyCallback) {
|
|
1435
|
-
|
|
1485
|
+
if (verbose) {
|
|
1486
|
+
console.error("[CPMcpServer] No tool policy callback set, allowing all tools");
|
|
1487
|
+
}
|
|
1436
1488
|
return;
|
|
1437
1489
|
}
|
|
1438
|
-
console.error("[CPMcpServer] Applying tool policy");
|
|
1439
1490
|
const registeredTools = this._registeredTools;
|
|
1440
1491
|
if (!registeredTools || typeof registeredTools !== "object") {
|
|
1441
1492
|
console.error("[CPMcpServer] No tools registered yet");
|
|
1442
1493
|
return;
|
|
1443
1494
|
}
|
|
1444
1495
|
const toolNames = Object.keys(registeredTools);
|
|
1445
|
-
|
|
1496
|
+
if (verbose) {
|
|
1497
|
+
console.error(`[CPMcpServer] Applying tool policy`);
|
|
1498
|
+
console.error(`[CPMcpServer] Found ${toolNames.length} registered tools:`, toolNames);
|
|
1499
|
+
}
|
|
1446
1500
|
let enabledCount = 0;
|
|
1447
1501
|
let disabledCount = 0;
|
|
1448
1502
|
for (const [toolName, tool] of Object.entries(registeredTools)) {
|
|
1449
1503
|
const isAllowed = this.toolPolicyCallback(toolName);
|
|
1450
1504
|
if (!isAllowed) {
|
|
1451
|
-
|
|
1505
|
+
if (verbose) {
|
|
1506
|
+
console.error(`[CPMcpServer] Tool '${toolName}' is NOT allowed by policy - disabling`);
|
|
1507
|
+
}
|
|
1452
1508
|
if (typeof tool.disable === "function") {
|
|
1453
1509
|
tool.disable();
|
|
1454
1510
|
disabledCount++;
|
|
1455
1511
|
}
|
|
1456
1512
|
} else {
|
|
1457
|
-
|
|
1513
|
+
if (verbose) {
|
|
1514
|
+
console.error(`[CPMcpServer] Tool '${toolName}' is allowed by policy`);
|
|
1515
|
+
}
|
|
1458
1516
|
enabledCount++;
|
|
1459
1517
|
}
|
|
1460
1518
|
}
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
package/package.json.bak
CHANGED