@chkp/documentation-mcp 1.1.0 → 1.4.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @chkp/documentation-mcp
2
2
 
3
+ ## 1.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - b5fdd00: General improvements and updates (synced from internal repository)
8
+
9
+ ## 1.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 56cf1d2: Updated implementation and features, Modified 3 file(s) (synced from internal repository)
14
+
3
15
  ## 1.1.0
4
16
 
5
17
  ### Minor Changes
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
- - `REGION`: Documentation Tool region - EU, US, STG, or Local (default: EU)
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 "Local" for on-premises deployment
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
- "REGION": "EU"
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
- "REGION": "EU"
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
- "REGION": "EU"
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
- node FULL_PATH_TO_SERVER/packages/copilot/dist/index.js --client-id "YOUR_CLIENT_ID" --secret-key "YOUR_SECRET_KEY" --region "EU"
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 URL(req.url, `http://localhost:${this.port}`);
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 URL(urlString);
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 || envValue;
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
- serverModule2.settingsManager.createFromHeaders(headersToEnvVars(req.headers, config), sessionId);
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
- await serverModule2.server.connect(transport).catch((error) => {
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 {
@@ -549,18 +758,11 @@ async function launchHTTPServer(config, serverModule2, port) {
549
758
  } else if (req.url === "/health" || req.url === "/status") {
550
759
  res.writeHead(200, { "Content-Type": "application/json" });
551
760
  const sessionCount = serverModule2.sessionManager.getSessionCount();
552
- const sessions = serverModule2.sessionManager.getAllSessions().map((session) => ({
553
- id: session.sessionId,
554
- createdAt: session.createdAt,
555
- lastActive: session.lastActive
556
- // Don't include potentially sensitive metadata
557
- }));
558
761
  res.end(JSON.stringify({
559
762
  status: "ok",
560
763
  server: config.name,
561
764
  version: serverModule2.pkg.version,
562
- activeSessions: sessionCount,
563
- sessions
765
+ activeSessions: sessionCount
564
766
  }));
565
767
  } else {
566
768
  res.writeHead(404, { "Content-Type": "text/plain" });
@@ -576,168 +778,75 @@ async function launchHTTPServer(config, serverModule2, port) {
576
778
  });
577
779
  }
578
780
  function headersToEnvVars(headers, config) {
781
+ const verbose = SettingsManager.globalDebugState;
782
+ if (verbose) {
783
+ console.error("[headersToEnvVars] Verbose: Converting headers to env vars");
784
+ console.error("[headersToEnvVars] Verbose: Input headers count:", Object.keys(headers).length);
785
+ console.error("[headersToEnvVars] Verbose: Input header keys:", Object.keys(headers));
786
+ if (!headers || Object.keys(headers).length === 0) {
787
+ console.error("[headersToEnvVars] Verbose: WARNING - Headers object is empty");
788
+ }
789
+ }
790
+ if (!headers || Object.keys(headers).length === 0) {
791
+ return {};
792
+ }
579
793
  const result = {};
580
794
  for (const [name, value] of Object.entries(headers)) {
581
795
  if (value !== void 0) {
582
796
  const envName = name.toUpperCase().replace(/-/g, "_");
583
797
  result[envName] = value;
798
+ if (verbose) {
799
+ console.error(`[headersToEnvVars] Verbose: Basic mapping: "${name}" -> "${envName}"`);
800
+ }
584
801
  }
585
802
  }
803
+ if (verbose) {
804
+ console.error("[headersToEnvVars] Verbose: After basic mapping, result keys:", Object.keys(result));
805
+ }
586
806
  if (config && config.options) {
807
+ if (verbose) {
808
+ console.error("[headersToEnvVars] Verbose: Config provided, building header-to-env mapping");
809
+ }
587
810
  const headerToEnvMap = {};
588
811
  for (const option of config.options) {
589
812
  if (option.env) {
590
813
  const flagName = option.flag.split(" ")[0].replace(/^--?/, "").replace(/-/g, "_");
591
814
  headerToEnvMap[flagName.toLowerCase()] = option.env;
815
+ if (verbose) {
816
+ console.error(`[headersToEnvVars] Verbose: Mapping: "${flagName.toLowerCase()}" -> "${option.env}"`);
817
+ }
592
818
  headerToEnvMap[option.env.toLowerCase()] = option.env;
593
819
  }
594
820
  }
821
+ if (verbose) {
822
+ console.error("[headersToEnvVars] Verbose: headerToEnvMap:", headerToEnvMap);
823
+ }
824
+ let mappedCount = 0;
595
825
  for (const [headerName, headerValue] of Object.entries(headers)) {
596
826
  if (headerValue !== void 0) {
597
827
  const normalizedHeaderName = headerName.toLowerCase().replace(/-/g, "_");
598
828
  const envVarName = headerToEnvMap[normalizedHeaderName];
599
829
  if (envVarName) {
600
830
  result[envVarName] = headerValue;
831
+ mappedCount++;
832
+ if (verbose) {
833
+ console.error(`[headersToEnvVars] Verbose: Config mapping: "${headerName}" -> "${envVarName}"`);
834
+ }
601
835
  }
602
836
  }
603
837
  }
604
- }
605
- return result;
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 ===");
838
+ if (verbose) {
839
+ console.error(`[headersToEnvVars] Verbose: Mapped ${mappedCount} headers using config`);
726
840
  }
727
- this.setSettings(settings, sessionId);
728
- return settings;
841
+ } else if (verbose) {
842
+ console.error("[headersToEnvVars] Verbose: No config provided, skipping config-based mapping");
729
843
  }
730
- /**
731
- * Clear settings for a session
732
- * @param sessionId The session ID to clear
733
- */
734
- clearSession(sessionId) {
735
- if (sessionId !== this.defaultSessionId) {
736
- this.settingsMap.delete(sessionId);
737
- }
844
+ if (verbose) {
845
+ console.error("[headersToEnvVars] Verbose: Final result keys:", Object.keys(result));
846
+ 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
847
  }
739
- };
740
- SettingsManager.globalDebugState = void 0;
848
+ return result;
849
+ }
741
850
 
742
851
  // ../mcp-utils/dist/api-manager-factory.js
743
852
  var APIManagerFactory = class {
@@ -758,11 +867,27 @@ var APIManagerFactory = class {
758
867
  * @returns API Manager instance for the session
759
868
  */
760
869
  getAPIManager(sessionId) {
870
+ const verbose = SettingsManager.globalDebugState;
761
871
  const sid = sessionId || this.defaultSessionId;
872
+ if (verbose) {
873
+ console.error("[APIManagerFactory.getAPIManager] Verbose: Getting API manager for session:", sid);
874
+ }
762
875
  if (!this.apiManagerMap.has(sid)) {
876
+ if (verbose) {
877
+ console.error("[APIManagerFactory.getAPIManager] Verbose: API manager not in cache, creating new one");
878
+ }
763
879
  const settings2 = this.settingsManager.getSettings(sid);
880
+ if (verbose) {
881
+ console.error("[APIManagerFactory.getAPIManager] Verbose: Retrieved settings from settings manager");
882
+ console.error("[APIManagerFactory.getAPIManager] Verbose: Creating API manager from settings");
883
+ }
764
884
  const apiManager2 = this.createAPIManagerFromSettings(settings2);
885
+ if (verbose) {
886
+ console.error("[APIManagerFactory.getAPIManager] Verbose: API manager created successfully");
887
+ }
765
888
  this.apiManagerMap.set(sid, apiManager2);
889
+ } else if (verbose) {
890
+ console.error("[APIManagerFactory.getAPIManager] Verbose: Using cached API manager");
766
891
  }
767
892
  const apiManager = this.apiManagerMap.get(sid);
768
893
  const settings = this.settingsManager.getSettings(sid);
@@ -777,7 +902,17 @@ var APIManagerFactory = class {
777
902
  * @returns API Manager instance
778
903
  */
779
904
  createAPIManagerFromSettings(settings) {
780
- return this.apiManagerClass.create(settings);
905
+ const verbose = SettingsManager.globalDebugState;
906
+ if (verbose) {
907
+ console.error("[APIManagerFactory.createAPIManagerFromSettings] Verbose: Creating API manager from settings");
908
+ console.error("[APIManagerFactory.createAPIManagerFromSettings] Verbose: Settings type:", typeof settings);
909
+ console.error("[APIManagerFactory.createAPIManagerFromSettings] Verbose: Settings keys:", settings ? Object.keys(settings) : "null");
910
+ }
911
+ const apiManager = this.apiManagerClass.create(settings);
912
+ if (verbose) {
913
+ console.error("[APIManagerFactory.createAPIManagerFromSettings] Verbose: API manager created");
914
+ }
915
+ return apiManager;
781
916
  }
782
917
  /**
783
918
  * Clear API manager for a session
@@ -1130,7 +1265,8 @@ var SessionManager = class {
1130
1265
 
1131
1266
  // ../mcp-utils/dist/server-utils.js
1132
1267
  function getHeaderValue(headers, key) {
1133
- const value = headers[key] || headers[key.toUpperCase()] || headers[key.toLowerCase()];
1268
+ const normalizedKey = key.replace(/_/g, "-");
1269
+ const value = headers[normalizedKey] || headers[normalizedKey.toUpperCase()] || headers[normalizedKey.toLowerCase()];
1134
1270
  return typeof value === "string" ? value : Array.isArray(value) ? value[0] : void 0;
1135
1271
  }
1136
1272
  function createApiRunner(serverModule2) {
@@ -1139,7 +1275,47 @@ function createApiRunner(serverModule2) {
1139
1275
  return await apiManager.callApi(method, uri, data, domain);
1140
1276
  };
1141
1277
  }
1142
- function createServerModule(server2, Settings2, pkg2, apiManagerClass, toolPolicyCallback) {
1278
+ function wrapServerWithTracking(server2, createServerFn) {
1279
+ const registrations = [];
1280
+ const originalTool = server2.tool?.bind(server2);
1281
+ const originalPrompt = server2.prompt?.bind(server2);
1282
+ const originalResource = server2.resource?.bind(server2);
1283
+ if (originalTool) {
1284
+ server2.tool = function(...args) {
1285
+ registrations.push({ type: "tool", method: "tool", args: [...args] });
1286
+ return originalTool(...args);
1287
+ };
1288
+ }
1289
+ if (originalPrompt) {
1290
+ server2.prompt = function(...args) {
1291
+ registrations.push({ type: "prompt", method: "prompt", args: [...args] });
1292
+ return originalPrompt(...args);
1293
+ };
1294
+ }
1295
+ if (originalResource) {
1296
+ server2.resource = function(...args) {
1297
+ registrations.push({ type: "resource", method: "resource", args: [...args] });
1298
+ return originalResource(...args);
1299
+ };
1300
+ }
1301
+ const createInstance = () => {
1302
+ const newServer = createServerFn();
1303
+ for (const reg of registrations) {
1304
+ if (newServer[reg.method]) {
1305
+ newServer[reg.method](...reg.args);
1306
+ }
1307
+ }
1308
+ if (typeof server2.setToolPolicy === "function" && typeof newServer.setToolPolicy === "function") {
1309
+ const toolPolicy = server2._toolPolicyCallback;
1310
+ if (toolPolicy) {
1311
+ newServer.setToolPolicy(toolPolicy);
1312
+ }
1313
+ }
1314
+ return newServer;
1315
+ };
1316
+ return { wrappedServer: server2, createInstance };
1317
+ }
1318
+ function createServerModule(server2, Settings2, pkg2, apiManagerClass, toolPolicyCallback, createServerFn) {
1143
1319
  const settingsManager = new SettingsManager(Settings2);
1144
1320
  const apiManagerFactory = new APIManagerFactory(apiManagerClass, settingsManager);
1145
1321
  const sessionManager = new SessionManager();
@@ -1147,6 +1323,15 @@ function createServerModule(server2, Settings2, pkg2, apiManagerClass, toolPolic
1147
1323
  console.error("[createServerModule] Setting tool policy callback on server");
1148
1324
  server2.setToolPolicy(toolPolicyCallback);
1149
1325
  }
1326
+ const serverFactory = createServerFn || server2._createServerFn;
1327
+ let createServerInstance;
1328
+ if (serverFactory) {
1329
+ const { wrappedServer, createInstance } = wrapServerWithTracking(server2, serverFactory);
1330
+ createServerInstance = createInstance;
1331
+ console.error("[createServerModule] Server factory enabled - HTTP multi-user support active");
1332
+ } else {
1333
+ console.error("[createServerModule] Warning: No server factory provided - HTTP multi-user may have issues");
1334
+ }
1150
1335
  return {
1151
1336
  server: server2,
1152
1337
  Settings: Settings2,
@@ -1154,7 +1339,8 @@ function createServerModule(server2, Settings2, pkg2, apiManagerClass, toolPolic
1154
1339
  apiManagerFactory,
1155
1340
  sessionManager,
1156
1341
  pkg: pkg2,
1157
- toolPolicyCallback
1342
+ toolPolicyCallback,
1343
+ createServerInstance
1158
1344
  };
1159
1345
  }
1160
1346
 
@@ -1277,9 +1463,15 @@ var CPMcpServer = class extends McpServer {
1277
1463
  if (typeof callback === "function") {
1278
1464
  const toolName = args[0];
1279
1465
  const wrappedCallback = async (...callbackArgs) => {
1280
- const extra = callbackArgs[1];
1466
+ let extra = callbackArgs[1];
1467
+ if (!extra && callbackArgs[0]?.sessionId) {
1468
+ extra = callbackArgs[0];
1469
+ }
1281
1470
  trackToolCall(this.mcpName, toolName, this.mcpVersion, extra).catch(() => {
1282
1471
  });
1472
+ if (callbackArgs.length === 1 && callbackArgs[0]?.sessionId) {
1473
+ return callback({}, callbackArgs[0]);
1474
+ }
1283
1475
  return callback(...callbackArgs);
1284
1476
  };
1285
1477
  args[args.length - 1] = wrappedCallback;
@@ -1304,7 +1496,11 @@ function createMcpServer(importMetaUrl, serverInfo, options) {
1304
1496
  name: serverInfo.name || pkg2.name,
1305
1497
  version: serverInfo.version || pkg2.version
1306
1498
  };
1499
+ const createServerFn = () => {
1500
+ return new CPMcpServer(fullServerInfo, options);
1501
+ };
1307
1502
  const server2 = new CPMcpServer(fullServerInfo, options);
1503
+ server2._createServerFn = createServerFn;
1308
1504
  return { server: server2, pkg: pkg2 };
1309
1505
  }
1310
1506
 
@@ -1331,9 +1527,59 @@ function nullOrEmpty(val) {
1331
1527
 
1332
1528
  // ../infra/dist/settings.js
1333
1529
  var Settings = class _Settings {
1334
- 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" } = {}) {
1530
+ normalizeRegion(region) {
1531
+ if (!region) {
1532
+ return void 0;
1533
+ }
1534
+ const normalized = region.trim().toUpperCase();
1535
+ return this.isValidRegion(normalized) ? normalized : void 0;
1536
+ }
1537
+ /**
1538
+ * Extract the base gateway URL (scheme + host) from a full URL.
1539
+ * Allows users to copy-paste any URL from the API key creation dialog
1540
+ * without having to strip the path manually.
1541
+ * Falls back to the original string if URL parsing fails.
1542
+ */
1543
+ static stripGatewayPath(url) {
1544
+ try {
1545
+ const parsed = new URL(url);
1546
+ return `${parsed.protocol}//${parsed.host}`;
1547
+ } catch {
1548
+ return url;
1549
+ }
1550
+ }
1551
+ /**
1552
+ * Detect the region from a gateway base URL
1553
+ */
1554
+ static detectRegionFromUrl(url) {
1555
+ if (url.includes("cloudinfra-gw-us.portal.checkpoint.com"))
1556
+ return "US";
1557
+ if (url.includes("cloudinfra-gw.portal.checkpoint.com"))
1558
+ return "EU";
1559
+ if (url.includes("dev-cloudinfra-gw"))
1560
+ return "STG";
1561
+ return void 0;
1562
+ }
1563
+ 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
1564
  this.region = "EU";
1336
1565
  this.devPort = "8006";
1566
+ this.gatewayUrl = "";
1567
+ const verbose = SettingsManager.globalDebugState;
1568
+ if (verbose) {
1569
+ console.error("[Settings] Verbose: Constructor called with params:", {
1570
+ apiKey: apiKey ? "***" : void 0,
1571
+ username: username ? "***" : void 0,
1572
+ password: password ? "***" : void 0,
1573
+ s1cUrl,
1574
+ managementHost,
1575
+ managementPort,
1576
+ cloudInfraToken: cloudInfraToken ? "***" : void 0,
1577
+ clientId,
1578
+ secretKey: secretKey ? "***" : void 0,
1579
+ region,
1580
+ devPort
1581
+ });
1582
+ }
1337
1583
  this.apiKey = apiKey;
1338
1584
  this.username = username;
1339
1585
  this.password = password;
@@ -1343,8 +1589,21 @@ var Settings = class _Settings {
1343
1589
  this.cloudInfraToken = cloudInfraToken;
1344
1590
  this.clientId = clientId;
1345
1591
  this.secretKey = secretKey;
1346
- this.region = this.isValidRegion(region) ? region : "EU";
1592
+ this.region = this.normalizeRegion(region) || "EU";
1347
1593
  this.devPort = devPort;
1594
+ this.gatewayUrl = this.resolveGatewayUrl(this.region, gatewayUrl);
1595
+ if (verbose) {
1596
+ console.error("[Settings] Verbose: After assignment:", {
1597
+ apiKey: this.apiKey ? "***" : void 0,
1598
+ username: this.username ? "***" : void 0,
1599
+ password: this.password ? "***" : void 0,
1600
+ s1cUrl: this.s1cUrl,
1601
+ managementHost: this.managementHost,
1602
+ managementPort: this.managementPort,
1603
+ cloudInfraToken: this.cloudInfraToken ? "***" : void 0,
1604
+ region: this.region
1605
+ });
1606
+ }
1348
1607
  this.validate();
1349
1608
  }
1350
1609
  /**
@@ -1354,10 +1613,10 @@ var Settings = class _Settings {
1354
1613
  return ["EU", "US", "STG", "LOCAL"].includes(region.toUpperCase());
1355
1614
  }
1356
1615
  /**
1357
- * Get Cloud Infra Gateway based on region
1616
+ * Get the base gateway URL for a given region
1358
1617
  */
1359
- getCloudInfraGateway() {
1360
- switch (this.region) {
1618
+ getRegionGatewayUrl(region) {
1619
+ switch (region) {
1361
1620
  case "EU":
1362
1621
  return "https://cloudinfra-gw.portal.checkpoint.com";
1363
1622
  case "US":
@@ -1369,23 +1628,88 @@ var Settings = class _Settings {
1369
1628
  return "";
1370
1629
  }
1371
1630
  }
1631
+ /**
1632
+ * Resolve the base gateway URL from either a provided URL or the configured region.
1633
+ * If a URL is provided, its path suffix is stripped so users can paste the full
1634
+ * auth URL from the API key creation dialog (e.g. ending in /auth/external).
1635
+ * When the URL implies a different region, this.region is updated to match.
1636
+ */
1637
+ resolveGatewayUrl(region, providedUrl) {
1638
+ if (!providedUrl) {
1639
+ return this.getRegionGatewayUrl(region);
1640
+ }
1641
+ const base = _Settings.stripGatewayPath(providedUrl);
1642
+ const detectedRegion = _Settings.detectRegionFromUrl(base);
1643
+ if (detectedRegion && detectedRegion !== this.region) {
1644
+ this.region = detectedRegion;
1645
+ }
1646
+ return base;
1647
+ }
1648
+ /**
1649
+ * Get the base Cloud Infra Gateway URL.
1650
+ * Returns the precomputed gatewayUrl (derived from region or a provided URL).
1651
+ */
1652
+ getCloudInfraGateway() {
1653
+ return this.gatewayUrl;
1654
+ }
1372
1655
  /**
1373
1656
  * Validate the settings
1374
1657
  */
1375
1658
  validate() {
1659
+ const verbose = SettingsManager.globalDebugState;
1660
+ if (verbose) {
1661
+ console.error("[Settings] Verbose: Validating settings...");
1662
+ console.error("[Settings] Verbose: s1cUrl:", this.s1cUrl || "(empty)");
1663
+ console.error("[Settings] Verbose: managementHost:", this.managementHost || "(empty)");
1664
+ console.error("[Settings] Verbose: apiKey:", this.apiKey ? "***" : "(empty)");
1665
+ console.error("[Settings] Verbose: cloudInfraToken:", this.cloudInfraToken ? "***" : "(empty)");
1666
+ console.error("[Settings] Verbose: username:", this.username ? "***" : "(empty)");
1667
+ console.error("[Settings] Verbose: password:", this.password ? "***" : "(empty)");
1668
+ }
1376
1669
  if (!nullOrEmpty(this.s1cUrl) && nullOrEmpty(this.apiKey) && nullOrEmpty(this.cloudInfraToken)) {
1670
+ if (verbose) {
1671
+ console.error("[Settings] Verbose: Validation FAILED - S1C URL provided but no API key or CI token");
1672
+ }
1377
1673
  throw new Error("API key or CI Token is required for S1C (via --api-key or API_KEY env var)");
1378
1674
  }
1379
1675
  if (!nullOrEmpty(this.managementHost) && nullOrEmpty(this.apiKey) && (nullOrEmpty(this.username) || nullOrEmpty(this.password))) {
1676
+ if (verbose) {
1677
+ console.error("[Settings] Verbose: Validation FAILED - Management host provided but no API key or credentials");
1678
+ }
1380
1679
  throw new Error("Either API key or username/password are required for on-prem management (via CLI args or env vars)");
1381
1680
  }
1382
1681
  if (nullOrEmpty(this.s1cUrl) && nullOrEmpty(this.managementHost)) {
1682
+ if (verbose) {
1683
+ console.error("[Settings] Verbose: WARNING - Neither s1cUrl nor managementHost provided");
1684
+ }
1685
+ }
1686
+ if (verbose) {
1687
+ console.error("[Settings] Verbose: Validation PASSED");
1383
1688
  }
1384
1689
  }
1385
1690
  /**
1386
1691
  * Create settings from command-line arguments
1387
1692
  */
1388
1693
  static fromArgs(args) {
1694
+ const verbose = SettingsManager.globalDebugState;
1695
+ if (verbose) {
1696
+ console.error("[Settings.fromArgs] Verbose: Creating settings from args");
1697
+ console.error("[Settings.fromArgs] Verbose: Raw args:", {
1698
+ apiKey: args.apiKey ? "***" : void 0,
1699
+ username: args.username ? "***" : void 0,
1700
+ password: args.password ? "***" : void 0,
1701
+ s1cUrl: args.s1cUrl,
1702
+ managementHost: args.managementHost,
1703
+ managementPort: args.managementPort,
1704
+ cloudInfraToken: args.cloudInfraToken ? "***" : void 0,
1705
+ region: args.region,
1706
+ hasOtherKeys: Object.keys(args).length > 10
1707
+ });
1708
+ const hasAnyValue = args.apiKey || args.username || args.password || args.s1cUrl || args.managementHost || args.cloudInfraToken;
1709
+ if (!hasAnyValue) {
1710
+ console.error("[Settings.fromArgs] Verbose: WARNING - Args object appears empty, no authentication values found");
1711
+ }
1712
+ }
1389
1713
  return new _Settings({
1390
1714
  apiKey: args.apiKey,
1391
1715
  username: args.username,
@@ -1396,8 +1720,9 @@ var Settings = class _Settings {
1396
1720
  cloudInfraToken: args.cloudInfraToken,
1397
1721
  clientId: args.clientId,
1398
1722
  secretKey: args.secretKey,
1399
- region: typeof args.region === "string" ? args.region.toUpperCase() : void 0,
1400
- devPort: args.devPort
1723
+ region: typeof args.region === "string" ? args.region.trim().toUpperCase() : void 0,
1724
+ devPort: args.devPort,
1725
+ gatewayUrl: args.gatewayUrl
1401
1726
  });
1402
1727
  }
1403
1728
  /**
@@ -1405,7 +1730,12 @@ var Settings = class _Settings {
1405
1730
  * Maps headers to environment variable format based on server config
1406
1731
  */
1407
1732
  static fromHeaders(headers) {
1408
- return new _Settings({
1733
+ const verbose = SettingsManager.globalDebugState;
1734
+ if (verbose) {
1735
+ console.error("[Settings.fromHeaders] Verbose: Creating settings from headers");
1736
+ console.error("[Settings.fromHeaders] Verbose: Available header keys:", Object.keys(headers));
1737
+ }
1738
+ const extractedValues = {
1409
1739
  apiKey: getHeaderValue(headers, "API-KEY"),
1410
1740
  username: getHeaderValue(headers, "USERNAME"),
1411
1741
  password: getHeaderValue(headers, "PASSWORD"),
@@ -1415,8 +1745,41 @@ var Settings = class _Settings {
1415
1745
  cloudInfraToken: getHeaderValue(headers, "CLOUD-INFRA-TOKEN"),
1416
1746
  clientId: getHeaderValue(headers, "CLIENT-ID"),
1417
1747
  secretKey: getHeaderValue(headers, "SECRET-KEY"),
1418
- region: getHeaderValue(headers, "REGION")?.toUpperCase(),
1419
- devPort: getHeaderValue(headers, "DEV-PORT")
1748
+ region: getHeaderValue(headers, "REGION"),
1749
+ devPort: getHeaderValue(headers, "DEV-PORT"),
1750
+ gatewayUrl: getHeaderValue(headers, "GATEWAY-URL")
1751
+ };
1752
+ if (verbose) {
1753
+ console.error("[Settings.fromHeaders] Verbose: Extracted values:", {
1754
+ apiKey: extractedValues.apiKey ? "***" : void 0,
1755
+ username: extractedValues.username ? "***" : void 0,
1756
+ password: extractedValues.password ? "***" : void 0,
1757
+ s1cUrl: extractedValues.s1cUrl,
1758
+ managementHost: extractedValues.managementHost,
1759
+ managementPort: extractedValues.managementPort,
1760
+ cloudInfraToken: extractedValues.cloudInfraToken ? "***" : void 0,
1761
+ region: extractedValues.region,
1762
+ devPort: extractedValues.devPort
1763
+ });
1764
+ const hasAnyValue = extractedValues.apiKey || extractedValues.username || extractedValues.password || extractedValues.s1cUrl || extractedValues.managementHost || extractedValues.cloudInfraToken;
1765
+ if (!hasAnyValue) {
1766
+ console.error("[Settings.fromHeaders] Verbose: WARNING - No authentication values found in headers");
1767
+ 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])));
1768
+ }
1769
+ }
1770
+ return new _Settings({
1771
+ apiKey: extractedValues.apiKey,
1772
+ username: extractedValues.username,
1773
+ password: extractedValues.password,
1774
+ s1cUrl: extractedValues.s1cUrl,
1775
+ managementHost: extractedValues.managementHost,
1776
+ managementPort: extractedValues.managementPort,
1777
+ cloudInfraToken: extractedValues.cloudInfraToken,
1778
+ clientId: extractedValues.clientId,
1779
+ secretKey: extractedValues.secretKey,
1780
+ region: extractedValues.region?.toUpperCase(),
1781
+ devPort: extractedValues.devPort,
1782
+ gatewayUrl: extractedValues.gatewayUrl
1420
1783
  });
1421
1784
  }
1422
1785
  };
@@ -1579,16 +1942,32 @@ var DocumentationToolAPIManager = class _DocumentationToolAPIManager {
1579
1942
  // src/settings.ts
1580
1943
  var DocumentationToolSettings = class _DocumentationToolSettings extends Settings {
1581
1944
  constructor(args = {}) {
1582
- super(args);
1945
+ super({
1946
+ ...args,
1947
+ gatewayUrl: args.authUrl || args.gatewayUrl
1948
+ });
1583
1949
  }
1584
1950
  /**
1585
1951
  * Create DocumentationToolSettings from command-line arguments for Documentation Tool
1586
1952
  */
1587
1953
  static fromArgs(args) {
1954
+ if (!args.authUrl && !args.region) {
1955
+ throw new Error(
1956
+ "Provide either --auth-url (Authentication URL from the API key creation dialog) or --region (EU, US, STG, or LOCAL)"
1957
+ );
1958
+ }
1588
1959
  return new _DocumentationToolSettings({
1589
1960
  ...args
1590
1961
  });
1591
1962
  }
1963
+ static fromHeaders(headers) {
1964
+ return new _DocumentationToolSettings({
1965
+ clientId: getHeaderValue(headers, "CLIENT-ID"),
1966
+ secretKey: getHeaderValue(headers, "SECRET-KEY"),
1967
+ region: getHeaderValue(headers, "REGION"),
1968
+ authUrl: getHeaderValue(headers, "AUTH-URL")
1969
+ });
1970
+ }
1592
1971
  };
1593
1972
 
1594
1973
  // src/index.ts
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chkp/documentation-mcp",
3
- "version": "1.1.0",
3
+ "version": "1.4.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.11.1",
30
- "axios": "^1.12.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"
@@ -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 Local",
31
+ "description": "Documentation Tool region: EU, US, STG, or LOCAL",
22
32
  "env": "REGION",
23
- "type": "string"
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.1.0",
3
+ "version": "1.4.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.4",
29
+ "@modelcontextprotocol/sdk": "^1.26.0",
30
30
  "commander": "^13.1.0",
31
- "axios": "^1.12.1",
31
+ "axios": "^1.13.5",
32
32
  "node-machine-id": "^1.1.12",
33
33
  "zod": "^3.24.4"
34
34
  },