@chkp/documentation-mcp 1.1.0 → 1.3.0
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/CHANGELOG.md +6 -0
- package/README.md +19 -6
- package/dist/index.js +542 -156
- package/dist/package.json +3 -3
- package/dist/server-config.json +18 -5
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -63,7 +63,8 @@ Set the following environment variables:
|
|
|
63
63
|
|
|
64
64
|
- `CLIENT_ID`: Client ID for authentication with Check Point Documentation Tool (required)
|
|
65
65
|
- `SECRET_KEY`: Secret Key for authentication with Check Point Documentation Tool (required)
|
|
66
|
-
- `
|
|
66
|
+
- `AUTH_URL`: Authentication URL copied from the API key creation dialog (e.g. `https://cloudinfra-gw.portal.checkpoint.com/auth/external`). Recommended — the path suffix is stripped automatically so you can paste it directly. When set, `REGION` is inferred and does not need to be set separately.
|
|
67
|
+
- `REGION`: Short region code — `EU`, `US`, `STG`, or `LOCAL` (default: `EU`). Use this instead of `AUTH_URL` for backwards-compatible configurations.
|
|
67
68
|
|
|
68
69
|
---
|
|
69
70
|
|
|
@@ -75,7 +76,7 @@ Set the following environment variables:
|
|
|
75
76
|
|
|
76
77
|
- `CLIENT_ID`: Your client ID for Documentation Tool authentication
|
|
77
78
|
- `SECRET_KEY`: Your secret key for Documentation Tool authentication
|
|
78
|
-
- `REGION`: Set to
|
|
79
|
+
- `REGION`: Set to `LOCAL` for on-premises deployment
|
|
79
80
|
|
|
80
81
|
---
|
|
81
82
|
|
|
@@ -107,13 +108,15 @@ It is expected to work with any MCP client that supports the Model Context Proto
|
|
|
107
108
|
"env": {
|
|
108
109
|
"CLIENT_ID": "YOUR_CLIENT_ID",
|
|
109
110
|
"SECRET_KEY": "YOUR_SECRET_KEY",
|
|
110
|
-
"
|
|
111
|
+
"AUTH_URL": "YOUR_AUTH_URL"
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
116
|
```
|
|
116
117
|
|
|
118
|
+
> **Tip:** Copy `AUTH_URL` directly from the Authentication URL shown in the API key creation dialog. The path suffix is stripped automatically — no manual editing needed.
|
|
119
|
+
|
|
117
120
|
### Configuring the Claude Desktop App
|
|
118
121
|
|
|
119
122
|
#### For macOS:
|
|
@@ -143,7 +146,7 @@ Add the server configuration:
|
|
|
143
146
|
"env": {
|
|
144
147
|
"CLIENT_ID": "YOUR_CLIENT_ID",
|
|
145
148
|
"SECRET_KEY": "YOUR_SECRET_KEY",
|
|
146
|
-
"
|
|
149
|
+
"AUTH_URL": "YOUR_AUTH_URL"
|
|
147
150
|
}
|
|
148
151
|
}
|
|
149
152
|
}
|
|
@@ -170,7 +173,7 @@ Add this configuration:
|
|
|
170
173
|
"env": {
|
|
171
174
|
"CLIENT_ID": "YOUR_CLIENT_ID",
|
|
172
175
|
"SECRET_KEY": "YOUR_SECRET_KEY",
|
|
173
|
-
"
|
|
176
|
+
"AUTH_URL": "YOUR_AUTH_URL"
|
|
174
177
|
}
|
|
175
178
|
}
|
|
176
179
|
}
|
|
@@ -219,7 +222,17 @@ npm run build
|
|
|
219
222
|
You can run the server locally for development using [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) or any compatible MCP client.
|
|
220
223
|
|
|
221
224
|
```bash
|
|
222
|
-
|
|
225
|
+
# Option A: use the Authentication URL from the API key creation dialog
|
|
226
|
+
node FULL_PATH_TO_SERVER/packages/documentation-tool/dist/index.js \
|
|
227
|
+
--client-id "YOUR_CLIENT_ID" \
|
|
228
|
+
--secret-key "YOUR_SECRET_KEY" \
|
|
229
|
+
--auth-url "YOUR_AUTH_URL"
|
|
230
|
+
|
|
231
|
+
# Option B: use a region code (EU / US / STG / LOCAL)
|
|
232
|
+
node FULL_PATH_TO_SERVER/packages/documentation-tool/dist/index.js \
|
|
233
|
+
--client-id "YOUR_CLIENT_ID" \
|
|
234
|
+
--secret-key "YOUR_SECRET_KEY" \
|
|
235
|
+
--region "EU"
|
|
223
236
|
```
|
|
224
237
|
|
|
225
238
|
---
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ __export(ui_dialog_exports, {
|
|
|
16
16
|
showLoginDialog: () => showLoginDialog
|
|
17
17
|
});
|
|
18
18
|
import { createServer } from "http";
|
|
19
|
-
import { URL } from "url";
|
|
19
|
+
import { URL as URL2 } from "url";
|
|
20
20
|
import { exec } from "child_process";
|
|
21
21
|
import { promisify } from "util";
|
|
22
22
|
import * as fs2 from "fs";
|
|
@@ -87,7 +87,7 @@ var init_ui_dialog = __esm({
|
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
handleRequest(req, res, config) {
|
|
90
|
-
const url = new
|
|
90
|
+
const url = new URL2(req.url, `http://localhost:${this.port}`);
|
|
91
91
|
if (req.method === "GET" && url.pathname === "/") {
|
|
92
92
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
93
93
|
res.end(this.generateHTML(config));
|
|
@@ -309,7 +309,7 @@ var init_ui_dialog = __esm({
|
|
|
309
309
|
try {
|
|
310
310
|
let url;
|
|
311
311
|
try {
|
|
312
|
-
url = new
|
|
312
|
+
url = new URL2(urlString);
|
|
313
313
|
if (!["http:", "https:"].includes(url.protocol) || url.hostname !== "localhost" && url.hostname !== "127.0.0.1") {
|
|
314
314
|
throw new Error("Invalid URL protocol or non-localhost hostname");
|
|
315
315
|
}
|
|
@@ -370,6 +370,165 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
|
|
|
370
370
|
import fs from "fs";
|
|
371
371
|
import http from "http";
|
|
372
372
|
import { randomUUID } from "crypto";
|
|
373
|
+
|
|
374
|
+
// ../mcp-utils/dist/settings-manager.js
|
|
375
|
+
var SettingsManager = class _SettingsManager {
|
|
376
|
+
/**
|
|
377
|
+
* Creates a new SettingsManager
|
|
378
|
+
* @param settingsClass The Settings class to use for creating settings instances
|
|
379
|
+
*/
|
|
380
|
+
constructor(settingsClass) {
|
|
381
|
+
this.settingsMap = /* @__PURE__ */ new Map();
|
|
382
|
+
this.defaultSessionId = "default";
|
|
383
|
+
this.settingsClass = settingsClass;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Get settings for a specific session
|
|
387
|
+
* @param sessionId The session ID (defaults to 'default' for stdio mode)
|
|
388
|
+
* @returns Settings instance for the session
|
|
389
|
+
*/
|
|
390
|
+
getSettings(sessionId) {
|
|
391
|
+
const sid = sessionId || this.defaultSessionId;
|
|
392
|
+
if (!this.settingsMap.has(sid)) {
|
|
393
|
+
this.settingsMap.set(sid, new this.settingsClass());
|
|
394
|
+
}
|
|
395
|
+
return this.settingsMap.get(sid);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Set settings for a specific session
|
|
399
|
+
* @param settings The settings object to set
|
|
400
|
+
* @param sessionId The session ID (defaults to 'default' for stdio mode)
|
|
401
|
+
*/
|
|
402
|
+
setSettings(settings, sessionId) {
|
|
403
|
+
const sid = sessionId || this.defaultSessionId;
|
|
404
|
+
this.settingsMap.set(sid, settings);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Injects debug settings from source into settings object
|
|
408
|
+
* @param settings The settings object to update
|
|
409
|
+
* @param source Source object containing debug information
|
|
410
|
+
* @private
|
|
411
|
+
*/
|
|
412
|
+
injectDebug(settings, source) {
|
|
413
|
+
const debug = source?.debug ?? _SettingsManager.globalDebugState ?? process.env.DEBUG;
|
|
414
|
+
if (typeof debug !== "undefined") {
|
|
415
|
+
if (source?.debug !== void 0) {
|
|
416
|
+
_SettingsManager.globalDebugState = source.debug;
|
|
417
|
+
}
|
|
418
|
+
if (typeof settings.set === "function") {
|
|
419
|
+
settings.set("debug", debug);
|
|
420
|
+
} else {
|
|
421
|
+
settings.debug = debug;
|
|
422
|
+
}
|
|
423
|
+
if (debug) {
|
|
424
|
+
console.error("Debug enabled. Source object contents:");
|
|
425
|
+
console.error(JSON.stringify(source, null, 2));
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Print settings object for debugging by dynamically discovering its properties
|
|
431
|
+
* @param settings The settings object to print
|
|
432
|
+
* @private
|
|
433
|
+
*/
|
|
434
|
+
printSettingsDebug(settings) {
|
|
435
|
+
if (typeof settings.get === "function") {
|
|
436
|
+
console.error("Settings (using get method):");
|
|
437
|
+
if (settings.data && typeof settings.data === "object") {
|
|
438
|
+
Object.entries(settings.data).forEach(([key, value]) => {
|
|
439
|
+
console.error(` ${key}: ${JSON.stringify(value)}`);
|
|
440
|
+
});
|
|
441
|
+
} else {
|
|
442
|
+
console.error(" Unable to enumerate settings properties - no accessible data structure");
|
|
443
|
+
}
|
|
444
|
+
} else {
|
|
445
|
+
console.error("Settings (plain object):");
|
|
446
|
+
Object.entries(settings).forEach(([key, value]) => {
|
|
447
|
+
console.error(` ${key}: ${JSON.stringify(value)}`);
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Create settings from command-line arguments
|
|
453
|
+
* @param args Command line arguments
|
|
454
|
+
* @param sessionId Optional session ID
|
|
455
|
+
* @returns Settings instance
|
|
456
|
+
*/
|
|
457
|
+
createFromArgs(args, sessionId) {
|
|
458
|
+
const settings = this.settingsClass.fromArgs(args);
|
|
459
|
+
this.injectDebug(settings, args);
|
|
460
|
+
this.setSettings(settings, sessionId);
|
|
461
|
+
return settings;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Create settings from HTTP headers
|
|
465
|
+
* @param headers HTTP headers
|
|
466
|
+
* @param sessionId Optional session ID
|
|
467
|
+
* @returns Settings instance
|
|
468
|
+
*/
|
|
469
|
+
createFromHeaders(headers, sessionId) {
|
|
470
|
+
const verbose = _SettingsManager.globalDebugState;
|
|
471
|
+
if (verbose) {
|
|
472
|
+
console.error("[SettingsManager.createFromHeaders] Verbose: Starting with sessionId:", sessionId || "(default)");
|
|
473
|
+
console.error("[SettingsManager.createFromHeaders] Verbose: Incoming headers count:", Object.keys(headers).length);
|
|
474
|
+
}
|
|
475
|
+
if (_SettingsManager.globalDebugState) {
|
|
476
|
+
console.error("=== createFromHeaders Debug Info ===");
|
|
477
|
+
console.error("Incoming headers:");
|
|
478
|
+
console.error(JSON.stringify(headers, null, 2));
|
|
479
|
+
}
|
|
480
|
+
if (verbose && (!headers || Object.keys(headers).length === 0)) {
|
|
481
|
+
console.error("[SettingsManager.createFromHeaders] Verbose: WARNING - Headers object is empty or undefined");
|
|
482
|
+
}
|
|
483
|
+
const normalizedHeaders = {};
|
|
484
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
485
|
+
const normalizedKey = key.includes("_") ? key.replace(/_/g, "-") : key;
|
|
486
|
+
normalizedHeaders[normalizedKey] = value;
|
|
487
|
+
if (verbose) {
|
|
488
|
+
console.error(`[SettingsManager.createFromHeaders] Verbose: Header normalized: "${key}" -> "${normalizedKey}"`);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
if (verbose) {
|
|
492
|
+
console.error("[SettingsManager.createFromHeaders] Verbose: Normalized headers count:", Object.keys(normalizedHeaders).length);
|
|
493
|
+
}
|
|
494
|
+
if (_SettingsManager.globalDebugState) {
|
|
495
|
+
console.error("Normalized headers:");
|
|
496
|
+
console.error(JSON.stringify(normalizedHeaders, null, 2));
|
|
497
|
+
}
|
|
498
|
+
const debugHeader = normalizedHeaders["debug"] || normalizedHeaders["Debug"] || normalizedHeaders["DEBUG"];
|
|
499
|
+
const debugSource = { debug: debugHeader !== void 0 ? debugHeader : _SettingsManager.globalDebugState };
|
|
500
|
+
if (verbose) {
|
|
501
|
+
console.error("[SettingsManager.createFromHeaders] Verbose: Calling settingsClass.fromHeaders");
|
|
502
|
+
}
|
|
503
|
+
const settings = this.settingsClass.fromHeaders(normalizedHeaders);
|
|
504
|
+
if (verbose) {
|
|
505
|
+
console.error("[SettingsManager.createFromHeaders] Verbose: Settings object created");
|
|
506
|
+
}
|
|
507
|
+
this.injectDebug(settings, debugSource);
|
|
508
|
+
if (_SettingsManager.globalDebugState) {
|
|
509
|
+
console.error("Final settings object for session:", sessionId || "(default)");
|
|
510
|
+
this.printSettingsDebug(settings);
|
|
511
|
+
console.error("=== End createFromHeaders Debug Info ===");
|
|
512
|
+
}
|
|
513
|
+
if (verbose) {
|
|
514
|
+
console.error("[SettingsManager.createFromHeaders] Verbose: Storing settings for session:", sessionId || "(default)");
|
|
515
|
+
}
|
|
516
|
+
this.setSettings(settings, sessionId);
|
|
517
|
+
return settings;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Clear settings for a session
|
|
521
|
+
* @param sessionId The session ID to clear
|
|
522
|
+
*/
|
|
523
|
+
clearSession(sessionId) {
|
|
524
|
+
if (sessionId !== this.defaultSessionId) {
|
|
525
|
+
this.settingsMap.delete(sessionId);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
SettingsManager.globalDebugState = void 0;
|
|
530
|
+
|
|
531
|
+
// ../mcp-utils/dist/launcher.js
|
|
373
532
|
async function launchMCPServer(configPath, serverModule2) {
|
|
374
533
|
const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
|
|
375
534
|
const program = new Command();
|
|
@@ -378,7 +537,7 @@ async function launchMCPServer(configPath, serverModule2) {
|
|
|
378
537
|
}
|
|
379
538
|
config.options.forEach((option) => {
|
|
380
539
|
const envValue = option.env ? process.env[option.env] : void 0;
|
|
381
|
-
const defaultValue = option.default
|
|
540
|
+
const defaultValue = envValue || option.default;
|
|
382
541
|
if (option.type === "boolean") {
|
|
383
542
|
const boolDefault = envValue === "true" || option.default === "true";
|
|
384
543
|
program.option(option.flag, option.description, boolDefault);
|
|
@@ -437,6 +596,7 @@ async function launchMCPServer(configPath, serverModule2) {
|
|
|
437
596
|
}
|
|
438
597
|
async function launchHTTPServer(config, serverModule2, port) {
|
|
439
598
|
const transports = {};
|
|
599
|
+
const serverInstances = {};
|
|
440
600
|
const server2 = http.createServer(async (req, res) => {
|
|
441
601
|
if (req.url === "/" || req.url === "/mcp") {
|
|
442
602
|
const sessionId = req.headers["mcp-session-id"];
|
|
@@ -458,31 +618,65 @@ async function launchHTTPServer(config, serverModule2, port) {
|
|
|
458
618
|
}
|
|
459
619
|
let transport;
|
|
460
620
|
if (sessionId && transports[sessionId]) {
|
|
621
|
+
const verbose = SettingsManager.globalDebugState;
|
|
622
|
+
if (verbose) {
|
|
623
|
+
console.error("[launchHTTPServer] Verbose: Reusing existing transport for session:", sessionId);
|
|
624
|
+
}
|
|
461
625
|
transport = transports[sessionId];
|
|
462
626
|
if (!serverModule2.settingsManager) {
|
|
463
627
|
throw new Error("ServerModule must have a settingsManager. Create it with createServerModule.");
|
|
464
628
|
}
|
|
465
|
-
|
|
629
|
+
if (verbose) {
|
|
630
|
+
console.error("[launchHTTPServer] Verbose: Converting headers for existing session");
|
|
631
|
+
}
|
|
632
|
+
const envHeaders = headersToEnvVars(req.headers, config);
|
|
633
|
+
if (verbose) {
|
|
634
|
+
console.error("[launchHTTPServer] Verbose: Creating settings from headers for existing session");
|
|
635
|
+
}
|
|
636
|
+
serverModule2.settingsManager.createFromHeaders(envHeaders, sessionId);
|
|
466
637
|
} else if (!sessionId && body && body.method === "initialize") {
|
|
467
638
|
transport = new StreamableHTTPServerTransport({
|
|
468
639
|
sessionIdGenerator: () => randomUUID(),
|
|
469
640
|
onsessioninitialized: (sid) => {
|
|
641
|
+
const verbose = SettingsManager.globalDebugState;
|
|
642
|
+
if (verbose) {
|
|
643
|
+
console.error("[launchHTTPServer] Verbose: New session initialized:", sid);
|
|
644
|
+
}
|
|
470
645
|
transports[sid] = transport;
|
|
646
|
+
if (verbose) {
|
|
647
|
+
console.error("[launchHTTPServer] Verbose: Converting headers for new session");
|
|
648
|
+
console.error("[launchHTTPServer] Verbose: Raw request headers:", Object.keys(req.headers));
|
|
649
|
+
}
|
|
471
650
|
const headers = headersToEnvVars(req.headers, config);
|
|
651
|
+
if (verbose) {
|
|
652
|
+
console.error("[launchHTTPServer] Verbose: Converted headers count:", Object.keys(headers).length);
|
|
653
|
+
}
|
|
472
654
|
const metadata = {
|
|
473
655
|
userAgent: req.headers["user-agent"],
|
|
474
656
|
origin: req.headers.origin || req.headers.referer,
|
|
475
657
|
remoteAddress: req.socket.remoteAddress,
|
|
476
658
|
initialPath: req.url
|
|
477
659
|
};
|
|
660
|
+
if (verbose) {
|
|
661
|
+
console.error("[launchHTTPServer] Verbose: Creating session in session manager");
|
|
662
|
+
}
|
|
478
663
|
serverModule2.sessionManager.createSession(sid, metadata);
|
|
664
|
+
if (verbose) {
|
|
665
|
+
console.error("[launchHTTPServer] Verbose: Creating settings from headers for new session");
|
|
666
|
+
}
|
|
479
667
|
serverModule2.settingsManager.createFromHeaders(headers, sid);
|
|
668
|
+
if (verbose) {
|
|
669
|
+
console.error("[launchHTTPServer] Verbose: Session initialization complete");
|
|
670
|
+
}
|
|
480
671
|
}
|
|
481
672
|
});
|
|
482
673
|
transport.onclose = () => {
|
|
483
674
|
const sid = transport.sessionId;
|
|
484
675
|
if (sid) {
|
|
485
676
|
delete transports[sid];
|
|
677
|
+
if (serverInstances[sid]) {
|
|
678
|
+
delete serverInstances[sid];
|
|
679
|
+
}
|
|
486
680
|
serverModule2.settingsManager.clearSession(sid);
|
|
487
681
|
serverModule2.apiManagerFactory.clearSession(sid);
|
|
488
682
|
serverModule2.sessionManager.removeSession(sid);
|
|
@@ -498,7 +692,22 @@ async function launchHTTPServer(config, serverModule2, port) {
|
|
|
498
692
|
transport
|
|
499
693
|
};
|
|
500
694
|
};
|
|
501
|
-
|
|
695
|
+
let serverToConnect;
|
|
696
|
+
if (serverModule2.createServerInstance) {
|
|
697
|
+
const sessionServer = serverModule2.createServerInstance();
|
|
698
|
+
serverToConnect = sessionServer;
|
|
699
|
+
const originalOnSessionInit = transport.onsessioninitialized;
|
|
700
|
+
transport.onsessioninitialized = (sid) => {
|
|
701
|
+
serverInstances[sid] = sessionServer;
|
|
702
|
+
if (originalOnSessionInit) {
|
|
703
|
+
originalOnSessionInit(sid);
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
} else {
|
|
707
|
+
serverToConnect = serverModule2.server;
|
|
708
|
+
console.error("Warning: Using shared server instance. Consider providing createServerInstance for better multi-user support.");
|
|
709
|
+
}
|
|
710
|
+
await serverToConnect.connect(transport).catch((error) => {
|
|
502
711
|
console.error("Error connecting to HTTP transport:", error);
|
|
503
712
|
});
|
|
504
713
|
} else {
|
|
@@ -576,168 +785,75 @@ async function launchHTTPServer(config, serverModule2, port) {
|
|
|
576
785
|
});
|
|
577
786
|
}
|
|
578
787
|
function headersToEnvVars(headers, config) {
|
|
788
|
+
const verbose = SettingsManager.globalDebugState;
|
|
789
|
+
if (verbose) {
|
|
790
|
+
console.error("[headersToEnvVars] Verbose: Converting headers to env vars");
|
|
791
|
+
console.error("[headersToEnvVars] Verbose: Input headers count:", Object.keys(headers).length);
|
|
792
|
+
console.error("[headersToEnvVars] Verbose: Input header keys:", Object.keys(headers));
|
|
793
|
+
if (!headers || Object.keys(headers).length === 0) {
|
|
794
|
+
console.error("[headersToEnvVars] Verbose: WARNING - Headers object is empty");
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
if (!headers || Object.keys(headers).length === 0) {
|
|
798
|
+
return {};
|
|
799
|
+
}
|
|
579
800
|
const result = {};
|
|
580
801
|
for (const [name, value] of Object.entries(headers)) {
|
|
581
802
|
if (value !== void 0) {
|
|
582
803
|
const envName = name.toUpperCase().replace(/-/g, "_");
|
|
583
804
|
result[envName] = value;
|
|
805
|
+
if (verbose) {
|
|
806
|
+
console.error(`[headersToEnvVars] Verbose: Basic mapping: "${name}" -> "${envName}"`);
|
|
807
|
+
}
|
|
584
808
|
}
|
|
585
809
|
}
|
|
810
|
+
if (verbose) {
|
|
811
|
+
console.error("[headersToEnvVars] Verbose: After basic mapping, result keys:", Object.keys(result));
|
|
812
|
+
}
|
|
586
813
|
if (config && config.options) {
|
|
814
|
+
if (verbose) {
|
|
815
|
+
console.error("[headersToEnvVars] Verbose: Config provided, building header-to-env mapping");
|
|
816
|
+
}
|
|
587
817
|
const headerToEnvMap = {};
|
|
588
818
|
for (const option of config.options) {
|
|
589
819
|
if (option.env) {
|
|
590
820
|
const flagName = option.flag.split(" ")[0].replace(/^--?/, "").replace(/-/g, "_");
|
|
591
821
|
headerToEnvMap[flagName.toLowerCase()] = option.env;
|
|
822
|
+
if (verbose) {
|
|
823
|
+
console.error(`[headersToEnvVars] Verbose: Mapping: "${flagName.toLowerCase()}" -> "${option.env}"`);
|
|
824
|
+
}
|
|
592
825
|
headerToEnvMap[option.env.toLowerCase()] = option.env;
|
|
593
826
|
}
|
|
594
827
|
}
|
|
828
|
+
if (verbose) {
|
|
829
|
+
console.error("[headersToEnvVars] Verbose: headerToEnvMap:", headerToEnvMap);
|
|
830
|
+
}
|
|
831
|
+
let mappedCount = 0;
|
|
595
832
|
for (const [headerName, headerValue] of Object.entries(headers)) {
|
|
596
833
|
if (headerValue !== void 0) {
|
|
597
834
|
const normalizedHeaderName = headerName.toLowerCase().replace(/-/g, "_");
|
|
598
835
|
const envVarName = headerToEnvMap[normalizedHeaderName];
|
|
599
836
|
if (envVarName) {
|
|
600
837
|
result[envVarName] = headerValue;
|
|
838
|
+
mappedCount++;
|
|
839
|
+
if (verbose) {
|
|
840
|
+
console.error(`[headersToEnvVars] Verbose: Config mapping: "${headerName}" -> "${envVarName}"`);
|
|
841
|
+
}
|
|
601
842
|
}
|
|
602
843
|
}
|
|
603
844
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
// ../mcp-utils/dist/settings-manager.js
|
|
609
|
-
var SettingsManager = class _SettingsManager {
|
|
610
|
-
/**
|
|
611
|
-
* Creates a new SettingsManager
|
|
612
|
-
* @param settingsClass The Settings class to use for creating settings instances
|
|
613
|
-
*/
|
|
614
|
-
constructor(settingsClass) {
|
|
615
|
-
this.settingsMap = /* @__PURE__ */ new Map();
|
|
616
|
-
this.defaultSessionId = "default";
|
|
617
|
-
this.settingsClass = settingsClass;
|
|
618
|
-
}
|
|
619
|
-
/**
|
|
620
|
-
* Get settings for a specific session
|
|
621
|
-
* @param sessionId The session ID (defaults to 'default' for stdio mode)
|
|
622
|
-
* @returns Settings instance for the session
|
|
623
|
-
*/
|
|
624
|
-
getSettings(sessionId) {
|
|
625
|
-
const sid = sessionId || this.defaultSessionId;
|
|
626
|
-
if (!this.settingsMap.has(sid)) {
|
|
627
|
-
this.settingsMap.set(sid, new this.settingsClass());
|
|
628
|
-
}
|
|
629
|
-
return this.settingsMap.get(sid);
|
|
630
|
-
}
|
|
631
|
-
/**
|
|
632
|
-
* Set settings for a specific session
|
|
633
|
-
* @param settings The settings object to set
|
|
634
|
-
* @param sessionId The session ID (defaults to 'default' for stdio mode)
|
|
635
|
-
*/
|
|
636
|
-
setSettings(settings, sessionId) {
|
|
637
|
-
const sid = sessionId || this.defaultSessionId;
|
|
638
|
-
this.settingsMap.set(sid, settings);
|
|
639
|
-
}
|
|
640
|
-
/**
|
|
641
|
-
* Injects debug settings from source into settings object
|
|
642
|
-
* @param settings The settings object to update
|
|
643
|
-
* @param source Source object containing debug information
|
|
644
|
-
* @private
|
|
645
|
-
*/
|
|
646
|
-
injectDebug(settings, source) {
|
|
647
|
-
const debug = source?.debug ?? _SettingsManager.globalDebugState ?? process.env.DEBUG;
|
|
648
|
-
if (typeof debug !== "undefined") {
|
|
649
|
-
if (source?.debug !== void 0) {
|
|
650
|
-
_SettingsManager.globalDebugState = source.debug;
|
|
651
|
-
}
|
|
652
|
-
if (typeof settings.set === "function") {
|
|
653
|
-
settings.set("debug", debug);
|
|
654
|
-
} else {
|
|
655
|
-
settings.debug = debug;
|
|
656
|
-
}
|
|
657
|
-
if (debug) {
|
|
658
|
-
console.error("Debug enabled. Source object contents:");
|
|
659
|
-
console.error(JSON.stringify(source, null, 2));
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
/**
|
|
664
|
-
* Print settings object for debugging by dynamically discovering its properties
|
|
665
|
-
* @param settings The settings object to print
|
|
666
|
-
* @private
|
|
667
|
-
*/
|
|
668
|
-
printSettingsDebug(settings) {
|
|
669
|
-
if (typeof settings.get === "function") {
|
|
670
|
-
console.error("Settings (using get method):");
|
|
671
|
-
if (settings.data && typeof settings.data === "object") {
|
|
672
|
-
Object.entries(settings.data).forEach(([key, value]) => {
|
|
673
|
-
console.error(` ${key}: ${JSON.stringify(value)}`);
|
|
674
|
-
});
|
|
675
|
-
} else {
|
|
676
|
-
console.error(" Unable to enumerate settings properties - no accessible data structure");
|
|
677
|
-
}
|
|
678
|
-
} else {
|
|
679
|
-
console.error("Settings (plain object):");
|
|
680
|
-
Object.entries(settings).forEach(([key, value]) => {
|
|
681
|
-
console.error(` ${key}: ${JSON.stringify(value)}`);
|
|
682
|
-
});
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* Create settings from command-line arguments
|
|
687
|
-
* @param args Command line arguments
|
|
688
|
-
* @param sessionId Optional session ID
|
|
689
|
-
* @returns Settings instance
|
|
690
|
-
*/
|
|
691
|
-
createFromArgs(args, sessionId) {
|
|
692
|
-
const settings = this.settingsClass.fromArgs(args);
|
|
693
|
-
this.injectDebug(settings, args);
|
|
694
|
-
this.setSettings(settings, sessionId);
|
|
695
|
-
return settings;
|
|
696
|
-
}
|
|
697
|
-
/**
|
|
698
|
-
* Create settings from HTTP headers
|
|
699
|
-
* @param headers HTTP headers
|
|
700
|
-
* @param sessionId Optional session ID
|
|
701
|
-
* @returns Settings instance
|
|
702
|
-
*/
|
|
703
|
-
createFromHeaders(headers, sessionId) {
|
|
704
|
-
if (_SettingsManager.globalDebugState) {
|
|
705
|
-
console.error("=== createFromHeaders Debug Info ===");
|
|
706
|
-
console.error("Incoming headers:");
|
|
707
|
-
console.error(JSON.stringify(headers, null, 2));
|
|
708
|
-
}
|
|
709
|
-
const normalizedHeaders = {};
|
|
710
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
711
|
-
const normalizedKey = key.includes("_") ? key.replace(/_/g, "-") : key;
|
|
712
|
-
normalizedHeaders[normalizedKey] = value;
|
|
713
|
-
}
|
|
714
|
-
if (_SettingsManager.globalDebugState) {
|
|
715
|
-
console.error("Normalized headers:");
|
|
716
|
-
console.error(JSON.stringify(normalizedHeaders, null, 2));
|
|
717
|
-
}
|
|
718
|
-
const debugHeader = normalizedHeaders["debug"] || normalizedHeaders["Debug"] || normalizedHeaders["DEBUG"];
|
|
719
|
-
const debugSource = { debug: debugHeader !== void 0 ? debugHeader : _SettingsManager.globalDebugState };
|
|
720
|
-
const settings = this.settingsClass.fromHeaders(normalizedHeaders);
|
|
721
|
-
this.injectDebug(settings, debugSource);
|
|
722
|
-
if (_SettingsManager.globalDebugState) {
|
|
723
|
-
console.error("Final settings object:");
|
|
724
|
-
this.printSettingsDebug(settings);
|
|
725
|
-
console.error("=== End createFromHeaders Debug Info ===");
|
|
845
|
+
if (verbose) {
|
|
846
|
+
console.error(`[headersToEnvVars] Verbose: Mapped ${mappedCount} headers using config`);
|
|
726
847
|
}
|
|
727
|
-
|
|
728
|
-
|
|
848
|
+
} else if (verbose) {
|
|
849
|
+
console.error("[headersToEnvVars] Verbose: No config provided, skipping config-based mapping");
|
|
729
850
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
*/
|
|
734
|
-
clearSession(sessionId) {
|
|
735
|
-
if (sessionId !== this.defaultSessionId) {
|
|
736
|
-
this.settingsMap.delete(sessionId);
|
|
737
|
-
}
|
|
851
|
+
if (verbose) {
|
|
852
|
+
console.error("[headersToEnvVars] Verbose: Final result keys:", Object.keys(result));
|
|
853
|
+
console.error("[headersToEnvVars] Verbose: Final result (sanitized):", Object.fromEntries(Object.entries(result).map(([k, v]) => [k, k.toLowerCase().includes("key") || k.toLowerCase().includes("token") || k.toLowerCase().includes("password") ? "***" : v])));
|
|
738
854
|
}
|
|
739
|
-
|
|
740
|
-
|
|
855
|
+
return result;
|
|
856
|
+
}
|
|
741
857
|
|
|
742
858
|
// ../mcp-utils/dist/api-manager-factory.js
|
|
743
859
|
var APIManagerFactory = class {
|
|
@@ -758,11 +874,27 @@ var APIManagerFactory = class {
|
|
|
758
874
|
* @returns API Manager instance for the session
|
|
759
875
|
*/
|
|
760
876
|
getAPIManager(sessionId) {
|
|
877
|
+
const verbose = SettingsManager.globalDebugState;
|
|
761
878
|
const sid = sessionId || this.defaultSessionId;
|
|
879
|
+
if (verbose) {
|
|
880
|
+
console.error("[APIManagerFactory.getAPIManager] Verbose: Getting API manager for session:", sid);
|
|
881
|
+
}
|
|
762
882
|
if (!this.apiManagerMap.has(sid)) {
|
|
883
|
+
if (verbose) {
|
|
884
|
+
console.error("[APIManagerFactory.getAPIManager] Verbose: API manager not in cache, creating new one");
|
|
885
|
+
}
|
|
763
886
|
const settings2 = this.settingsManager.getSettings(sid);
|
|
887
|
+
if (verbose) {
|
|
888
|
+
console.error("[APIManagerFactory.getAPIManager] Verbose: Retrieved settings from settings manager");
|
|
889
|
+
console.error("[APIManagerFactory.getAPIManager] Verbose: Creating API manager from settings");
|
|
890
|
+
}
|
|
764
891
|
const apiManager2 = this.createAPIManagerFromSettings(settings2);
|
|
892
|
+
if (verbose) {
|
|
893
|
+
console.error("[APIManagerFactory.getAPIManager] Verbose: API manager created successfully");
|
|
894
|
+
}
|
|
765
895
|
this.apiManagerMap.set(sid, apiManager2);
|
|
896
|
+
} else if (verbose) {
|
|
897
|
+
console.error("[APIManagerFactory.getAPIManager] Verbose: Using cached API manager");
|
|
766
898
|
}
|
|
767
899
|
const apiManager = this.apiManagerMap.get(sid);
|
|
768
900
|
const settings = this.settingsManager.getSettings(sid);
|
|
@@ -777,7 +909,17 @@ var APIManagerFactory = class {
|
|
|
777
909
|
* @returns API Manager instance
|
|
778
910
|
*/
|
|
779
911
|
createAPIManagerFromSettings(settings) {
|
|
780
|
-
|
|
912
|
+
const verbose = SettingsManager.globalDebugState;
|
|
913
|
+
if (verbose) {
|
|
914
|
+
console.error("[APIManagerFactory.createAPIManagerFromSettings] Verbose: Creating API manager from settings");
|
|
915
|
+
console.error("[APIManagerFactory.createAPIManagerFromSettings] Verbose: Settings type:", typeof settings);
|
|
916
|
+
console.error("[APIManagerFactory.createAPIManagerFromSettings] Verbose: Settings keys:", settings ? Object.keys(settings) : "null");
|
|
917
|
+
}
|
|
918
|
+
const apiManager = this.apiManagerClass.create(settings);
|
|
919
|
+
if (verbose) {
|
|
920
|
+
console.error("[APIManagerFactory.createAPIManagerFromSettings] Verbose: API manager created");
|
|
921
|
+
}
|
|
922
|
+
return apiManager;
|
|
781
923
|
}
|
|
782
924
|
/**
|
|
783
925
|
* Clear API manager for a session
|
|
@@ -1130,7 +1272,8 @@ var SessionManager = class {
|
|
|
1130
1272
|
|
|
1131
1273
|
// ../mcp-utils/dist/server-utils.js
|
|
1132
1274
|
function getHeaderValue(headers, key) {
|
|
1133
|
-
const
|
|
1275
|
+
const normalizedKey = key.replace(/_/g, "-");
|
|
1276
|
+
const value = headers[normalizedKey] || headers[normalizedKey.toUpperCase()] || headers[normalizedKey.toLowerCase()];
|
|
1134
1277
|
return typeof value === "string" ? value : Array.isArray(value) ? value[0] : void 0;
|
|
1135
1278
|
}
|
|
1136
1279
|
function createApiRunner(serverModule2) {
|
|
@@ -1139,7 +1282,47 @@ function createApiRunner(serverModule2) {
|
|
|
1139
1282
|
return await apiManager.callApi(method, uri, data, domain);
|
|
1140
1283
|
};
|
|
1141
1284
|
}
|
|
1142
|
-
function
|
|
1285
|
+
function wrapServerWithTracking(server2, createServerFn) {
|
|
1286
|
+
const registrations = [];
|
|
1287
|
+
const originalTool = server2.tool?.bind(server2);
|
|
1288
|
+
const originalPrompt = server2.prompt?.bind(server2);
|
|
1289
|
+
const originalResource = server2.resource?.bind(server2);
|
|
1290
|
+
if (originalTool) {
|
|
1291
|
+
server2.tool = function(...args) {
|
|
1292
|
+
registrations.push({ type: "tool", method: "tool", args: [...args] });
|
|
1293
|
+
return originalTool(...args);
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
if (originalPrompt) {
|
|
1297
|
+
server2.prompt = function(...args) {
|
|
1298
|
+
registrations.push({ type: "prompt", method: "prompt", args: [...args] });
|
|
1299
|
+
return originalPrompt(...args);
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
if (originalResource) {
|
|
1303
|
+
server2.resource = function(...args) {
|
|
1304
|
+
registrations.push({ type: "resource", method: "resource", args: [...args] });
|
|
1305
|
+
return originalResource(...args);
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
const createInstance = () => {
|
|
1309
|
+
const newServer = createServerFn();
|
|
1310
|
+
for (const reg of registrations) {
|
|
1311
|
+
if (newServer[reg.method]) {
|
|
1312
|
+
newServer[reg.method](...reg.args);
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
if (typeof server2.setToolPolicy === "function" && typeof newServer.setToolPolicy === "function") {
|
|
1316
|
+
const toolPolicy = server2._toolPolicyCallback;
|
|
1317
|
+
if (toolPolicy) {
|
|
1318
|
+
newServer.setToolPolicy(toolPolicy);
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
return newServer;
|
|
1322
|
+
};
|
|
1323
|
+
return { wrappedServer: server2, createInstance };
|
|
1324
|
+
}
|
|
1325
|
+
function createServerModule(server2, Settings2, pkg2, apiManagerClass, toolPolicyCallback, createServerFn) {
|
|
1143
1326
|
const settingsManager = new SettingsManager(Settings2);
|
|
1144
1327
|
const apiManagerFactory = new APIManagerFactory(apiManagerClass, settingsManager);
|
|
1145
1328
|
const sessionManager = new SessionManager();
|
|
@@ -1147,6 +1330,15 @@ function createServerModule(server2, Settings2, pkg2, apiManagerClass, toolPolic
|
|
|
1147
1330
|
console.error("[createServerModule] Setting tool policy callback on server");
|
|
1148
1331
|
server2.setToolPolicy(toolPolicyCallback);
|
|
1149
1332
|
}
|
|
1333
|
+
const serverFactory = createServerFn || server2._createServerFn;
|
|
1334
|
+
let createServerInstance;
|
|
1335
|
+
if (serverFactory) {
|
|
1336
|
+
const { wrappedServer, createInstance } = wrapServerWithTracking(server2, serverFactory);
|
|
1337
|
+
createServerInstance = createInstance;
|
|
1338
|
+
console.error("[createServerModule] Server factory enabled - HTTP multi-user support active");
|
|
1339
|
+
} else {
|
|
1340
|
+
console.error("[createServerModule] Warning: No server factory provided - HTTP multi-user may have issues");
|
|
1341
|
+
}
|
|
1150
1342
|
return {
|
|
1151
1343
|
server: server2,
|
|
1152
1344
|
Settings: Settings2,
|
|
@@ -1154,7 +1346,8 @@ function createServerModule(server2, Settings2, pkg2, apiManagerClass, toolPolic
|
|
|
1154
1346
|
apiManagerFactory,
|
|
1155
1347
|
sessionManager,
|
|
1156
1348
|
pkg: pkg2,
|
|
1157
|
-
toolPolicyCallback
|
|
1349
|
+
toolPolicyCallback,
|
|
1350
|
+
createServerInstance
|
|
1158
1351
|
};
|
|
1159
1352
|
}
|
|
1160
1353
|
|
|
@@ -1277,9 +1470,15 @@ var CPMcpServer = class extends McpServer {
|
|
|
1277
1470
|
if (typeof callback === "function") {
|
|
1278
1471
|
const toolName = args[0];
|
|
1279
1472
|
const wrappedCallback = async (...callbackArgs) => {
|
|
1280
|
-
|
|
1473
|
+
let extra = callbackArgs[1];
|
|
1474
|
+
if (!extra && callbackArgs[0]?.sessionId) {
|
|
1475
|
+
extra = callbackArgs[0];
|
|
1476
|
+
}
|
|
1281
1477
|
trackToolCall(this.mcpName, toolName, this.mcpVersion, extra).catch(() => {
|
|
1282
1478
|
});
|
|
1479
|
+
if (callbackArgs.length === 1 && callbackArgs[0]?.sessionId) {
|
|
1480
|
+
return callback({}, callbackArgs[0]);
|
|
1481
|
+
}
|
|
1283
1482
|
return callback(...callbackArgs);
|
|
1284
1483
|
};
|
|
1285
1484
|
args[args.length - 1] = wrappedCallback;
|
|
@@ -1304,7 +1503,11 @@ function createMcpServer(importMetaUrl, serverInfo, options) {
|
|
|
1304
1503
|
name: serverInfo.name || pkg2.name,
|
|
1305
1504
|
version: serverInfo.version || pkg2.version
|
|
1306
1505
|
};
|
|
1506
|
+
const createServerFn = () => {
|
|
1507
|
+
return new CPMcpServer(fullServerInfo, options);
|
|
1508
|
+
};
|
|
1307
1509
|
const server2 = new CPMcpServer(fullServerInfo, options);
|
|
1510
|
+
server2._createServerFn = createServerFn;
|
|
1308
1511
|
return { server: server2, pkg: pkg2 };
|
|
1309
1512
|
}
|
|
1310
1513
|
|
|
@@ -1331,9 +1534,59 @@ function nullOrEmpty(val) {
|
|
|
1331
1534
|
|
|
1332
1535
|
// ../infra/dist/settings.js
|
|
1333
1536
|
var Settings = class _Settings {
|
|
1334
|
-
|
|
1537
|
+
normalizeRegion(region) {
|
|
1538
|
+
if (!region) {
|
|
1539
|
+
return void 0;
|
|
1540
|
+
}
|
|
1541
|
+
const normalized = region.trim().toUpperCase();
|
|
1542
|
+
return this.isValidRegion(normalized) ? normalized : void 0;
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Extract the base gateway URL (scheme + host) from a full URL.
|
|
1546
|
+
* Allows users to copy-paste any URL from the API key creation dialog
|
|
1547
|
+
* without having to strip the path manually.
|
|
1548
|
+
* Falls back to the original string if URL parsing fails.
|
|
1549
|
+
*/
|
|
1550
|
+
static stripGatewayPath(url) {
|
|
1551
|
+
try {
|
|
1552
|
+
const parsed = new URL(url);
|
|
1553
|
+
return `${parsed.protocol}//${parsed.host}`;
|
|
1554
|
+
} catch {
|
|
1555
|
+
return url;
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* Detect the region from a gateway base URL
|
|
1560
|
+
*/
|
|
1561
|
+
static detectRegionFromUrl(url) {
|
|
1562
|
+
if (url.includes("cloudinfra-gw-us.portal.checkpoint.com"))
|
|
1563
|
+
return "US";
|
|
1564
|
+
if (url.includes("cloudinfra-gw.portal.checkpoint.com"))
|
|
1565
|
+
return "EU";
|
|
1566
|
+
if (url.includes("dev-cloudinfra-gw"))
|
|
1567
|
+
return "STG";
|
|
1568
|
+
return void 0;
|
|
1569
|
+
}
|
|
1570
|
+
constructor({ apiKey = process.env.API_KEY, username = process.env.USERNAME, password = process.env.PASSWORD, s1cUrl = process.env.S1C_URL, managementHost = process.env.MANAGEMENT_HOST, managementPort = process.env.MANAGEMENT_PORT || "443", cloudInfraToken = process.env.CLOUD_INFRA_TOKEN, clientId = process.env.CLIENT_ID, secretKey = process.env.SECRET_KEY, region = process.env.REGION || "EU", devPort = process.env.DEV_PORT || "8006", gatewayUrl } = {}) {
|
|
1335
1571
|
this.region = "EU";
|
|
1336
1572
|
this.devPort = "8006";
|
|
1573
|
+
this.gatewayUrl = "";
|
|
1574
|
+
const verbose = SettingsManager.globalDebugState;
|
|
1575
|
+
if (verbose) {
|
|
1576
|
+
console.error("[Settings] Verbose: Constructor called with params:", {
|
|
1577
|
+
apiKey: apiKey ? "***" : void 0,
|
|
1578
|
+
username: username ? "***" : void 0,
|
|
1579
|
+
password: password ? "***" : void 0,
|
|
1580
|
+
s1cUrl,
|
|
1581
|
+
managementHost,
|
|
1582
|
+
managementPort,
|
|
1583
|
+
cloudInfraToken: cloudInfraToken ? "***" : void 0,
|
|
1584
|
+
clientId,
|
|
1585
|
+
secretKey: secretKey ? "***" : void 0,
|
|
1586
|
+
region,
|
|
1587
|
+
devPort
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1337
1590
|
this.apiKey = apiKey;
|
|
1338
1591
|
this.username = username;
|
|
1339
1592
|
this.password = password;
|
|
@@ -1343,8 +1596,21 @@ var Settings = class _Settings {
|
|
|
1343
1596
|
this.cloudInfraToken = cloudInfraToken;
|
|
1344
1597
|
this.clientId = clientId;
|
|
1345
1598
|
this.secretKey = secretKey;
|
|
1346
|
-
this.region = this.
|
|
1599
|
+
this.region = this.normalizeRegion(region) || "EU";
|
|
1347
1600
|
this.devPort = devPort;
|
|
1601
|
+
this.gatewayUrl = this.resolveGatewayUrl(this.region, gatewayUrl);
|
|
1602
|
+
if (verbose) {
|
|
1603
|
+
console.error("[Settings] Verbose: After assignment:", {
|
|
1604
|
+
apiKey: this.apiKey ? "***" : void 0,
|
|
1605
|
+
username: this.username ? "***" : void 0,
|
|
1606
|
+
password: this.password ? "***" : void 0,
|
|
1607
|
+
s1cUrl: this.s1cUrl,
|
|
1608
|
+
managementHost: this.managementHost,
|
|
1609
|
+
managementPort: this.managementPort,
|
|
1610
|
+
cloudInfraToken: this.cloudInfraToken ? "***" : void 0,
|
|
1611
|
+
region: this.region
|
|
1612
|
+
});
|
|
1613
|
+
}
|
|
1348
1614
|
this.validate();
|
|
1349
1615
|
}
|
|
1350
1616
|
/**
|
|
@@ -1354,10 +1620,10 @@ var Settings = class _Settings {
|
|
|
1354
1620
|
return ["EU", "US", "STG", "LOCAL"].includes(region.toUpperCase());
|
|
1355
1621
|
}
|
|
1356
1622
|
/**
|
|
1357
|
-
* Get
|
|
1623
|
+
* Get the base gateway URL for a given region
|
|
1358
1624
|
*/
|
|
1359
|
-
|
|
1360
|
-
switch (
|
|
1625
|
+
getRegionGatewayUrl(region) {
|
|
1626
|
+
switch (region) {
|
|
1361
1627
|
case "EU":
|
|
1362
1628
|
return "https://cloudinfra-gw.portal.checkpoint.com";
|
|
1363
1629
|
case "US":
|
|
@@ -1369,23 +1635,88 @@ var Settings = class _Settings {
|
|
|
1369
1635
|
return "";
|
|
1370
1636
|
}
|
|
1371
1637
|
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Resolve the base gateway URL from either a provided URL or the configured region.
|
|
1640
|
+
* If a URL is provided, its path suffix is stripped so users can paste the full
|
|
1641
|
+
* auth URL from the API key creation dialog (e.g. ending in /auth/external).
|
|
1642
|
+
* When the URL implies a different region, this.region is updated to match.
|
|
1643
|
+
*/
|
|
1644
|
+
resolveGatewayUrl(region, providedUrl) {
|
|
1645
|
+
if (!providedUrl) {
|
|
1646
|
+
return this.getRegionGatewayUrl(region);
|
|
1647
|
+
}
|
|
1648
|
+
const base = _Settings.stripGatewayPath(providedUrl);
|
|
1649
|
+
const detectedRegion = _Settings.detectRegionFromUrl(base);
|
|
1650
|
+
if (detectedRegion && detectedRegion !== this.region) {
|
|
1651
|
+
this.region = detectedRegion;
|
|
1652
|
+
}
|
|
1653
|
+
return base;
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* Get the base Cloud Infra Gateway URL.
|
|
1657
|
+
* Returns the precomputed gatewayUrl (derived from region or a provided URL).
|
|
1658
|
+
*/
|
|
1659
|
+
getCloudInfraGateway() {
|
|
1660
|
+
return this.gatewayUrl;
|
|
1661
|
+
}
|
|
1372
1662
|
/**
|
|
1373
1663
|
* Validate the settings
|
|
1374
1664
|
*/
|
|
1375
1665
|
validate() {
|
|
1666
|
+
const verbose = SettingsManager.globalDebugState;
|
|
1667
|
+
if (verbose) {
|
|
1668
|
+
console.error("[Settings] Verbose: Validating settings...");
|
|
1669
|
+
console.error("[Settings] Verbose: s1cUrl:", this.s1cUrl || "(empty)");
|
|
1670
|
+
console.error("[Settings] Verbose: managementHost:", this.managementHost || "(empty)");
|
|
1671
|
+
console.error("[Settings] Verbose: apiKey:", this.apiKey ? "***" : "(empty)");
|
|
1672
|
+
console.error("[Settings] Verbose: cloudInfraToken:", this.cloudInfraToken ? "***" : "(empty)");
|
|
1673
|
+
console.error("[Settings] Verbose: username:", this.username ? "***" : "(empty)");
|
|
1674
|
+
console.error("[Settings] Verbose: password:", this.password ? "***" : "(empty)");
|
|
1675
|
+
}
|
|
1376
1676
|
if (!nullOrEmpty(this.s1cUrl) && nullOrEmpty(this.apiKey) && nullOrEmpty(this.cloudInfraToken)) {
|
|
1677
|
+
if (verbose) {
|
|
1678
|
+
console.error("[Settings] Verbose: Validation FAILED - S1C URL provided but no API key or CI token");
|
|
1679
|
+
}
|
|
1377
1680
|
throw new Error("API key or CI Token is required for S1C (via --api-key or API_KEY env var)");
|
|
1378
1681
|
}
|
|
1379
1682
|
if (!nullOrEmpty(this.managementHost) && nullOrEmpty(this.apiKey) && (nullOrEmpty(this.username) || nullOrEmpty(this.password))) {
|
|
1683
|
+
if (verbose) {
|
|
1684
|
+
console.error("[Settings] Verbose: Validation FAILED - Management host provided but no API key or credentials");
|
|
1685
|
+
}
|
|
1380
1686
|
throw new Error("Either API key or username/password are required for on-prem management (via CLI args or env vars)");
|
|
1381
1687
|
}
|
|
1382
1688
|
if (nullOrEmpty(this.s1cUrl) && nullOrEmpty(this.managementHost)) {
|
|
1689
|
+
if (verbose) {
|
|
1690
|
+
console.error("[Settings] Verbose: WARNING - Neither s1cUrl nor managementHost provided");
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
if (verbose) {
|
|
1694
|
+
console.error("[Settings] Verbose: Validation PASSED");
|
|
1383
1695
|
}
|
|
1384
1696
|
}
|
|
1385
1697
|
/**
|
|
1386
1698
|
* Create settings from command-line arguments
|
|
1387
1699
|
*/
|
|
1388
1700
|
static fromArgs(args) {
|
|
1701
|
+
const verbose = SettingsManager.globalDebugState;
|
|
1702
|
+
if (verbose) {
|
|
1703
|
+
console.error("[Settings.fromArgs] Verbose: Creating settings from args");
|
|
1704
|
+
console.error("[Settings.fromArgs] Verbose: Raw args:", {
|
|
1705
|
+
apiKey: args.apiKey ? "***" : void 0,
|
|
1706
|
+
username: args.username ? "***" : void 0,
|
|
1707
|
+
password: args.password ? "***" : void 0,
|
|
1708
|
+
s1cUrl: args.s1cUrl,
|
|
1709
|
+
managementHost: args.managementHost,
|
|
1710
|
+
managementPort: args.managementPort,
|
|
1711
|
+
cloudInfraToken: args.cloudInfraToken ? "***" : void 0,
|
|
1712
|
+
region: args.region,
|
|
1713
|
+
hasOtherKeys: Object.keys(args).length > 10
|
|
1714
|
+
});
|
|
1715
|
+
const hasAnyValue = args.apiKey || args.username || args.password || args.s1cUrl || args.managementHost || args.cloudInfraToken;
|
|
1716
|
+
if (!hasAnyValue) {
|
|
1717
|
+
console.error("[Settings.fromArgs] Verbose: WARNING - Args object appears empty, no authentication values found");
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1389
1720
|
return new _Settings({
|
|
1390
1721
|
apiKey: args.apiKey,
|
|
1391
1722
|
username: args.username,
|
|
@@ -1396,8 +1727,9 @@ var Settings = class _Settings {
|
|
|
1396
1727
|
cloudInfraToken: args.cloudInfraToken,
|
|
1397
1728
|
clientId: args.clientId,
|
|
1398
1729
|
secretKey: args.secretKey,
|
|
1399
|
-
region: typeof args.region === "string" ? args.region.toUpperCase() : void 0,
|
|
1400
|
-
devPort: args.devPort
|
|
1730
|
+
region: typeof args.region === "string" ? args.region.trim().toUpperCase() : void 0,
|
|
1731
|
+
devPort: args.devPort,
|
|
1732
|
+
gatewayUrl: args.gatewayUrl
|
|
1401
1733
|
});
|
|
1402
1734
|
}
|
|
1403
1735
|
/**
|
|
@@ -1405,7 +1737,12 @@ var Settings = class _Settings {
|
|
|
1405
1737
|
* Maps headers to environment variable format based on server config
|
|
1406
1738
|
*/
|
|
1407
1739
|
static fromHeaders(headers) {
|
|
1408
|
-
|
|
1740
|
+
const verbose = SettingsManager.globalDebugState;
|
|
1741
|
+
if (verbose) {
|
|
1742
|
+
console.error("[Settings.fromHeaders] Verbose: Creating settings from headers");
|
|
1743
|
+
console.error("[Settings.fromHeaders] Verbose: Available header keys:", Object.keys(headers));
|
|
1744
|
+
}
|
|
1745
|
+
const extractedValues = {
|
|
1409
1746
|
apiKey: getHeaderValue(headers, "API-KEY"),
|
|
1410
1747
|
username: getHeaderValue(headers, "USERNAME"),
|
|
1411
1748
|
password: getHeaderValue(headers, "PASSWORD"),
|
|
@@ -1415,8 +1752,41 @@ var Settings = class _Settings {
|
|
|
1415
1752
|
cloudInfraToken: getHeaderValue(headers, "CLOUD-INFRA-TOKEN"),
|
|
1416
1753
|
clientId: getHeaderValue(headers, "CLIENT-ID"),
|
|
1417
1754
|
secretKey: getHeaderValue(headers, "SECRET-KEY"),
|
|
1418
|
-
region: getHeaderValue(headers, "REGION")
|
|
1419
|
-
devPort: getHeaderValue(headers, "DEV-PORT")
|
|
1755
|
+
region: getHeaderValue(headers, "REGION"),
|
|
1756
|
+
devPort: getHeaderValue(headers, "DEV-PORT"),
|
|
1757
|
+
gatewayUrl: getHeaderValue(headers, "GATEWAY-URL")
|
|
1758
|
+
};
|
|
1759
|
+
if (verbose) {
|
|
1760
|
+
console.error("[Settings.fromHeaders] Verbose: Extracted values:", {
|
|
1761
|
+
apiKey: extractedValues.apiKey ? "***" : void 0,
|
|
1762
|
+
username: extractedValues.username ? "***" : void 0,
|
|
1763
|
+
password: extractedValues.password ? "***" : void 0,
|
|
1764
|
+
s1cUrl: extractedValues.s1cUrl,
|
|
1765
|
+
managementHost: extractedValues.managementHost,
|
|
1766
|
+
managementPort: extractedValues.managementPort,
|
|
1767
|
+
cloudInfraToken: extractedValues.cloudInfraToken ? "***" : void 0,
|
|
1768
|
+
region: extractedValues.region,
|
|
1769
|
+
devPort: extractedValues.devPort
|
|
1770
|
+
});
|
|
1771
|
+
const hasAnyValue = extractedValues.apiKey || extractedValues.username || extractedValues.password || extractedValues.s1cUrl || extractedValues.managementHost || extractedValues.cloudInfraToken;
|
|
1772
|
+
if (!hasAnyValue) {
|
|
1773
|
+
console.error("[Settings.fromHeaders] Verbose: WARNING - No authentication values found in headers");
|
|
1774
|
+
console.error("[Settings.fromHeaders] Verbose: Full headers object (sanitized):", Object.fromEntries(Object.entries(headers).map(([k, v]) => [k, k.toLowerCase().includes("key") || k.toLowerCase().includes("token") || k.toLowerCase().includes("password") ? "***" : v])));
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
return new _Settings({
|
|
1778
|
+
apiKey: extractedValues.apiKey,
|
|
1779
|
+
username: extractedValues.username,
|
|
1780
|
+
password: extractedValues.password,
|
|
1781
|
+
s1cUrl: extractedValues.s1cUrl,
|
|
1782
|
+
managementHost: extractedValues.managementHost,
|
|
1783
|
+
managementPort: extractedValues.managementPort,
|
|
1784
|
+
cloudInfraToken: extractedValues.cloudInfraToken,
|
|
1785
|
+
clientId: extractedValues.clientId,
|
|
1786
|
+
secretKey: extractedValues.secretKey,
|
|
1787
|
+
region: extractedValues.region?.toUpperCase(),
|
|
1788
|
+
devPort: extractedValues.devPort,
|
|
1789
|
+
gatewayUrl: extractedValues.gatewayUrl
|
|
1420
1790
|
});
|
|
1421
1791
|
}
|
|
1422
1792
|
};
|
|
@@ -1579,16 +1949,32 @@ var DocumentationToolAPIManager = class _DocumentationToolAPIManager {
|
|
|
1579
1949
|
// src/settings.ts
|
|
1580
1950
|
var DocumentationToolSettings = class _DocumentationToolSettings extends Settings {
|
|
1581
1951
|
constructor(args = {}) {
|
|
1582
|
-
super(
|
|
1952
|
+
super({
|
|
1953
|
+
...args,
|
|
1954
|
+
gatewayUrl: args.authUrl || args.gatewayUrl
|
|
1955
|
+
});
|
|
1583
1956
|
}
|
|
1584
1957
|
/**
|
|
1585
1958
|
* Create DocumentationToolSettings from command-line arguments for Documentation Tool
|
|
1586
1959
|
*/
|
|
1587
1960
|
static fromArgs(args) {
|
|
1961
|
+
if (!args.authUrl && !args.region) {
|
|
1962
|
+
throw new Error(
|
|
1963
|
+
"Provide either --auth-url (Authentication URL from the API key creation dialog) or --region (EU, US, STG, or LOCAL)"
|
|
1964
|
+
);
|
|
1965
|
+
}
|
|
1588
1966
|
return new _DocumentationToolSettings({
|
|
1589
1967
|
...args
|
|
1590
1968
|
});
|
|
1591
1969
|
}
|
|
1970
|
+
static fromHeaders(headers) {
|
|
1971
|
+
return new _DocumentationToolSettings({
|
|
1972
|
+
clientId: getHeaderValue(headers, "CLIENT-ID"),
|
|
1973
|
+
secretKey: getHeaderValue(headers, "SECRET-KEY"),
|
|
1974
|
+
region: getHeaderValue(headers, "REGION"),
|
|
1975
|
+
authUrl: getHeaderValue(headers, "AUTH-URL")
|
|
1976
|
+
});
|
|
1977
|
+
}
|
|
1592
1978
|
};
|
|
1593
1979
|
|
|
1594
1980
|
// src/index.ts
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chkp/documentation-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Check Point Documentation Tool Service - API integration with Check Point Documentation Tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"start": "node dist/index.js"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
30
|
-
"axios": "^1.
|
|
29
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
30
|
+
"axios": "^1.13.5",
|
|
31
31
|
"commander": "^13.1.0",
|
|
32
32
|
"node-machine-id": "^1.1.12",
|
|
33
33
|
"zod": "^3.22.4"
|
package/dist/server-config.json
CHANGED
|
@@ -7,20 +7,33 @@
|
|
|
7
7
|
"description": "Client ID for authentication with Documentation Tool",
|
|
8
8
|
"env": "CLIENT_ID",
|
|
9
9
|
"required": true,
|
|
10
|
-
"type": "string"
|
|
10
|
+
"type": "string",
|
|
11
|
+
"help": "Client ID for Check Point Documentation Tool authentication. To obtain: log in to the Infinity Portal → API Keys → New → New User API Key → copy the generated Client ID"
|
|
11
12
|
},
|
|
12
13
|
{
|
|
13
14
|
"flag": "--secret-key <secret-key>",
|
|
14
15
|
"description": "Secret Key for authentication with Documentation Tool",
|
|
15
16
|
"env": "SECRET_KEY",
|
|
16
17
|
"required": true,
|
|
17
|
-
"type": "string"
|
|
18
|
+
"type": "string",
|
|
19
|
+
"help": "Secret Key for Check Point Documentation Tool authentication. Generated alongside the Client ID — copy and store it securely at creation time as it will not be shown again"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"flag": "--auth-url <url>",
|
|
23
|
+
"description": "Authentication URL from the API key creation dialog",
|
|
24
|
+
"env": "AUTH_URL",
|
|
25
|
+
"required": true,
|
|
26
|
+
"type": "string",
|
|
27
|
+
"help": "Paste the Authentication URL shown when creating your API key (e.g. https://cloudinfra-gw.portal.checkpoint.com/auth/external). The path suffix is stripped automatically so you can copy it directly from the portal"
|
|
18
28
|
},
|
|
19
29
|
{
|
|
20
30
|
"flag": "--region <region>",
|
|
21
|
-
"description": "Documentation Tool region: EU, US, STG, or
|
|
31
|
+
"description": "Documentation Tool region: EU, US, STG, or LOCAL",
|
|
22
32
|
"env": "REGION",
|
|
23
|
-
"
|
|
33
|
+
"required": false,
|
|
34
|
+
"hidden": true,
|
|
35
|
+
"type": "string",
|
|
36
|
+
"help": "Alternative to --auth-url. Region code for your deployment: EU, US, STG, or LOCAL. Use this if you know your region and prefer not to copy the full authentication URL"
|
|
24
37
|
}
|
|
25
38
|
]
|
|
26
|
-
}
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chkp/documentation-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Check Point Documentation Tool Service - API integration with Check Point Documentation Tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"start": "node dist/index.js"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@modelcontextprotocol/sdk": "^1.0
|
|
29
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
30
30
|
"commander": "^13.1.0",
|
|
31
|
-
"axios": "^1.
|
|
31
|
+
"axios": "^1.13.5",
|
|
32
32
|
"node-machine-id": "^1.1.12",
|
|
33
33
|
"zod": "^3.24.4"
|
|
34
34
|
},
|