@chkp/documentation-mcp 1.4.12 → 1.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +296 -62
- package/dist/package.json +1 -1
- package/package.json +1 -1
- package/package.json.bak +1 -1
package/dist/index.js
CHANGED
|
@@ -372,6 +372,79 @@ import { z } from "zod";
|
|
|
372
372
|
function booleanOptionDefault(envValue, optionDefault) {
|
|
373
373
|
return envValue === "true" || optionDefault === "true";
|
|
374
374
|
}
|
|
375
|
+
function resolveTransportType(transportOption, env = process.env) {
|
|
376
|
+
return (transportOption || env.MCP_TRANSPORT_TYPE || "stdio").toLowerCase() === "http" ? "http" : "stdio";
|
|
377
|
+
}
|
|
378
|
+
function optionKey(flag) {
|
|
379
|
+
const long = flag.split(/[,\s]+/).find((part) => part.startsWith("--"));
|
|
380
|
+
if (!long)
|
|
381
|
+
return void 0;
|
|
382
|
+
const negated = long.startsWith("--no-");
|
|
383
|
+
return {
|
|
384
|
+
key: long.replace(/^--(no-)?/, "").replace(/-([a-z])/g, (_match, char) => char.toUpperCase()),
|
|
385
|
+
negated
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
function operatorValues(options, parsed, env = process.env) {
|
|
389
|
+
const values = { ...env };
|
|
390
|
+
for (const option of options) {
|
|
391
|
+
const derived = option.env ? optionKey(option.flag) : void 0;
|
|
392
|
+
if (!derived || derived.negated)
|
|
393
|
+
continue;
|
|
394
|
+
const value = parsed[derived.key];
|
|
395
|
+
if (value !== void 0)
|
|
396
|
+
values[option.env] = value;
|
|
397
|
+
}
|
|
398
|
+
return values;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// ../mcp-utils/dist/debug-view.js
|
|
402
|
+
import { createHash } from "node:crypto";
|
|
403
|
+
var BUILTIN_LOGGABLE_KEYS = [
|
|
404
|
+
"accept",
|
|
405
|
+
"accept-encoding",
|
|
406
|
+
"accept-language",
|
|
407
|
+
"connection",
|
|
408
|
+
"content-length",
|
|
409
|
+
"content-type",
|
|
410
|
+
"host",
|
|
411
|
+
"mcp-protocol-version",
|
|
412
|
+
"traceparent",
|
|
413
|
+
"user-agent",
|
|
414
|
+
"x-correlation-id",
|
|
415
|
+
"x-gw-auth-method",
|
|
416
|
+
"x-request-id",
|
|
417
|
+
// Launcher options
|
|
418
|
+
"debug",
|
|
419
|
+
"telemetry",
|
|
420
|
+
"telemetry-url",
|
|
421
|
+
"transport",
|
|
422
|
+
"transport-port"
|
|
423
|
+
];
|
|
424
|
+
function normalizeDebugKey(key) {
|
|
425
|
+
const split = /[-_]/.test(key) ? key : key.replace(/([a-z][0-9]*)([A-Z])/g, "$1-$2");
|
|
426
|
+
return split.replace(/_/g, "-").toLowerCase();
|
|
427
|
+
}
|
|
428
|
+
function debugLoggableKeys(extra = []) {
|
|
429
|
+
return new Set([...BUILTIN_LOGGABLE_KEYS, ...extra].map(normalizeDebugKey));
|
|
430
|
+
}
|
|
431
|
+
function describe(key, value, loggable) {
|
|
432
|
+
if (value === void 0 || value === null || value === "")
|
|
433
|
+
return "(unset)";
|
|
434
|
+
if (loggable.has(normalizeDebugKey(key))) {
|
|
435
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
436
|
+
}
|
|
437
|
+
const text = typeof value === "string" ? value : Array.isArray(value) ? value.join(", ") : void 0;
|
|
438
|
+
return text === void 0 ? "(hidden)" : `(hidden, ${text.length} chars)`;
|
|
439
|
+
}
|
|
440
|
+
function debugView(record, loggable = debugLoggableKeys()) {
|
|
441
|
+
return Object.fromEntries(Object.entries(record ?? {}).map(([key, value]) => [key, describe(key, value, loggable)]));
|
|
442
|
+
}
|
|
443
|
+
function sessionLogLabel(sessionId) {
|
|
444
|
+
if (!sessionId || sessionId === "default")
|
|
445
|
+
return "default";
|
|
446
|
+
return `session#${createHash("sha256").update(sessionId).digest("hex").slice(0, 8)}`;
|
|
447
|
+
}
|
|
375
448
|
|
|
376
449
|
// ../mcp-utils/dist/launcher.js
|
|
377
450
|
import { Command } from "commander";
|
|
@@ -381,6 +454,89 @@ import fs from "fs";
|
|
|
381
454
|
import http from "http";
|
|
382
455
|
import { randomUUID } from "crypto";
|
|
383
456
|
|
|
457
|
+
// ../mcp-utils/dist/connection-source.js
|
|
458
|
+
function hasValue(value) {
|
|
459
|
+
return value !== void 0 && value !== null && value !== "" && !(Array.isArray(value) && value.length === 0);
|
|
460
|
+
}
|
|
461
|
+
function headersRead(fromHeaders, headers) {
|
|
462
|
+
const read = /* @__PURE__ */ new Set();
|
|
463
|
+
const recording = new Proxy(headers, {
|
|
464
|
+
get(target, prop, receiver) {
|
|
465
|
+
const value = Reflect.get(target, prop, receiver);
|
|
466
|
+
if (typeof prop === "string" && hasValue(value))
|
|
467
|
+
read.add(prop);
|
|
468
|
+
return value;
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
try {
|
|
472
|
+
fromHeaders(recording);
|
|
473
|
+
} catch {
|
|
474
|
+
}
|
|
475
|
+
return read;
|
|
476
|
+
}
|
|
477
|
+
function keySet(keys = []) {
|
|
478
|
+
return new Set(keys.map(normalizeDebugKey));
|
|
479
|
+
}
|
|
480
|
+
function chooseConnectionSource(read, basicKeys) {
|
|
481
|
+
for (const key of read) {
|
|
482
|
+
if (!basicKeys.has(normalizeDebugKey(key)))
|
|
483
|
+
return "caller";
|
|
484
|
+
}
|
|
485
|
+
return "operator";
|
|
486
|
+
}
|
|
487
|
+
function basicOnly(headers, basicKeys) {
|
|
488
|
+
return Object.fromEntries(Object.entries(headers).filter(([key]) => basicKeys.has(normalizeDebugKey(key))));
|
|
489
|
+
}
|
|
490
|
+
function mergeHeaders(base, overrides) {
|
|
491
|
+
const merged = {};
|
|
492
|
+
const index = /* @__PURE__ */ new Map();
|
|
493
|
+
for (const [key, value] of [...Object.entries(base), ...Object.entries(overrides)]) {
|
|
494
|
+
const id = normalizeDebugKey(key);
|
|
495
|
+
const previous = index.get(id);
|
|
496
|
+
if (previous !== void 0)
|
|
497
|
+
delete merged[previous];
|
|
498
|
+
index.set(id, key);
|
|
499
|
+
merged[key] = value;
|
|
500
|
+
}
|
|
501
|
+
return merged;
|
|
502
|
+
}
|
|
503
|
+
function operatorHeaders(values) {
|
|
504
|
+
const headers = {};
|
|
505
|
+
for (const [name, value] of Object.entries(values)) {
|
|
506
|
+
if (!hasValue(value))
|
|
507
|
+
continue;
|
|
508
|
+
headers[name.replace(/_/g, "-")] = Array.isArray(value) ? value.map(String) : String(value);
|
|
509
|
+
}
|
|
510
|
+
return headers;
|
|
511
|
+
}
|
|
512
|
+
function canonicalizeAliases(headers, aliases) {
|
|
513
|
+
if (aliases.size === 0)
|
|
514
|
+
return headers;
|
|
515
|
+
const canonical = new Set([...aliases.values()].map(normalizeDebugKey));
|
|
516
|
+
const present = new Set(Object.keys(headers).map(normalizeDebugKey).filter((key) => canonical.has(key)));
|
|
517
|
+
const result = {};
|
|
518
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
519
|
+
const target = aliases.get(normalizeDebugKey(key));
|
|
520
|
+
if (target === void 0) {
|
|
521
|
+
result[key] = value;
|
|
522
|
+
} else if (!present.has(normalizeDebugKey(target))) {
|
|
523
|
+
result[target] = value;
|
|
524
|
+
present.add(normalizeDebugKey(target));
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return result;
|
|
528
|
+
}
|
|
529
|
+
function aliasMap(aliases = {}) {
|
|
530
|
+
return new Map(Object.entries(aliases).map(([alias, target]) => [normalizeDebugKey(alias), target]));
|
|
531
|
+
}
|
|
532
|
+
function sessionHeaders(source, callerHeaders, operator, basicKeys, operatorSettingsOverHttp) {
|
|
533
|
+
if (source === "caller") {
|
|
534
|
+
return mergeHeaders(basicOnly(operator, basicKeys), callerHeaders);
|
|
535
|
+
}
|
|
536
|
+
const base = operatorSettingsOverHttp ? operator : basicOnly(operator, basicKeys);
|
|
537
|
+
return mergeHeaders(base, basicOnly(callerHeaders, basicKeys));
|
|
538
|
+
}
|
|
539
|
+
|
|
384
540
|
// ../mcp-utils/dist/settings-manager.js
|
|
385
541
|
var SettingsManager = class _SettingsManager {
|
|
386
542
|
/**
|
|
@@ -390,7 +546,13 @@ var SettingsManager = class _SettingsManager {
|
|
|
390
546
|
constructor(settingsClass) {
|
|
391
547
|
this.settingsMap = /* @__PURE__ */ new Map();
|
|
392
548
|
this.defaultSessionId = "default";
|
|
549
|
+
this.operatorValues = {};
|
|
550
|
+
this.sessionSources = /* @__PURE__ */ new Map();
|
|
393
551
|
this.settingsClass = settingsClass;
|
|
552
|
+
this.loggableKeys = debugLoggableKeys(settingsClass?.debugLoggableKeys ?? []);
|
|
553
|
+
this.basicKeys = keySet(settingsClass?.basicKeys ?? []);
|
|
554
|
+
this.headerAliases = aliasMap(settingsClass?.headerAliases);
|
|
555
|
+
this.operatorSettingsOverHttp = settingsClass?.operatorSettingsOverHttp !== false;
|
|
394
556
|
}
|
|
395
557
|
/**
|
|
396
558
|
* Get settings for a specific session
|
|
@@ -417,12 +579,15 @@ var SettingsManager = class _SettingsManager {
|
|
|
417
579
|
* Injects debug settings from source into settings object
|
|
418
580
|
* @param settings The settings object to update
|
|
419
581
|
* @param source Source object containing debug information
|
|
582
|
+
* @param scope 'process' when the operator set debug (CLI/env), which also
|
|
583
|
+
* updates the process-wide state; 'session' when a caller set it through a
|
|
584
|
+
* header, which affects only that session's settings
|
|
420
585
|
* @private
|
|
421
586
|
*/
|
|
422
|
-
injectDebug(settings, source) {
|
|
587
|
+
injectDebug(settings, source, scope) {
|
|
423
588
|
const debug = source?.debug ?? _SettingsManager.globalDebugState ?? process.env.DEBUG;
|
|
424
589
|
if (typeof debug !== "undefined") {
|
|
425
|
-
if (source?.debug !== void 0) {
|
|
590
|
+
if (scope === "process" && source?.debug !== void 0) {
|
|
426
591
|
_SettingsManager.globalDebugState = source.debug;
|
|
427
592
|
}
|
|
428
593
|
if (typeof settings.set === "function") {
|
|
@@ -431,8 +596,8 @@ var SettingsManager = class _SettingsManager {
|
|
|
431
596
|
settings.debug = debug;
|
|
432
597
|
}
|
|
433
598
|
if (debug) {
|
|
434
|
-
console.error("Debug enabled. Source
|
|
435
|
-
|
|
599
|
+
console.error("Debug enabled. Source:");
|
|
600
|
+
this.printDebugView(source);
|
|
436
601
|
}
|
|
437
602
|
}
|
|
438
603
|
}
|
|
@@ -445,19 +610,21 @@ var SettingsManager = class _SettingsManager {
|
|
|
445
610
|
if (typeof settings.get === "function") {
|
|
446
611
|
console.error("Settings (using get method):");
|
|
447
612
|
if (settings.data && typeof settings.data === "object") {
|
|
448
|
-
|
|
449
|
-
console.error(` ${key}: ${JSON.stringify(value)}`);
|
|
450
|
-
});
|
|
613
|
+
this.printDebugView(settings.data);
|
|
451
614
|
} else {
|
|
452
615
|
console.error(" Unable to enumerate settings properties - no accessible data structure");
|
|
453
616
|
}
|
|
454
617
|
} else {
|
|
455
618
|
console.error("Settings (plain object):");
|
|
456
|
-
|
|
457
|
-
console.error(` ${key}: ${JSON.stringify(value)}`);
|
|
458
|
-
});
|
|
619
|
+
this.printDebugView(settings);
|
|
459
620
|
}
|
|
460
621
|
}
|
|
622
|
+
/** Print allowlisted values; everything else as "(hidden, N chars)". */
|
|
623
|
+
printDebugView(record) {
|
|
624
|
+
Object.entries(debugView(record, this.loggableKeys)).forEach(([key, value]) => {
|
|
625
|
+
console.error(` ${key}: ${value}`);
|
|
626
|
+
});
|
|
627
|
+
}
|
|
461
628
|
/**
|
|
462
629
|
* Create settings from command-line arguments
|
|
463
630
|
* @param args Command line arguments
|
|
@@ -466,10 +633,19 @@ var SettingsManager = class _SettingsManager {
|
|
|
466
633
|
*/
|
|
467
634
|
createFromArgs(args, sessionId) {
|
|
468
635
|
const settings = this.settingsClass.fromArgs(args);
|
|
469
|
-
this.injectDebug(settings, args);
|
|
636
|
+
this.injectDebug(settings, args, "process");
|
|
470
637
|
this.setSettings(settings, sessionId);
|
|
471
638
|
return settings;
|
|
472
639
|
}
|
|
640
|
+
/**
|
|
641
|
+
* Record the operator's values (environment variables and parsed CLI
|
|
642
|
+
* options, keyed by environment-variable name). HTTP sessions take basic
|
|
643
|
+
* keys from them when the caller doesn't send its own, and their whole
|
|
644
|
+
* connection set when the caller sends none of it.
|
|
645
|
+
*/
|
|
646
|
+
setOperatorValues(values) {
|
|
647
|
+
this.operatorValues = canonicalizeAliases(operatorHeaders(values), this.headerAliases);
|
|
648
|
+
}
|
|
473
649
|
/**
|
|
474
650
|
* Create settings from HTTP headers
|
|
475
651
|
* @param headers HTTP headers
|
|
@@ -479,13 +655,13 @@ var SettingsManager = class _SettingsManager {
|
|
|
479
655
|
createFromHeaders(headers, sessionId) {
|
|
480
656
|
const verbose = _SettingsManager.globalDebugState;
|
|
481
657
|
if (verbose) {
|
|
482
|
-
console.error("[SettingsManager.createFromHeaders] Verbose: Starting with
|
|
658
|
+
console.error("[SettingsManager.createFromHeaders] Verbose: Starting with session:", sessionLogLabel(sessionId));
|
|
483
659
|
console.error("[SettingsManager.createFromHeaders] Verbose: Incoming headers count:", Object.keys(headers).length);
|
|
484
660
|
}
|
|
485
661
|
if (_SettingsManager.globalDebugState) {
|
|
486
662
|
console.error("=== createFromHeaders Debug Info ===");
|
|
487
663
|
console.error("Incoming headers:");
|
|
488
|
-
|
|
664
|
+
this.printDebugView(headers);
|
|
489
665
|
}
|
|
490
666
|
if (verbose && (!headers || Object.keys(headers).length === 0)) {
|
|
491
667
|
console.error("[SettingsManager.createFromHeaders] Verbose: WARNING - Headers object is empty or undefined");
|
|
@@ -502,26 +678,32 @@ var SettingsManager = class _SettingsManager {
|
|
|
502
678
|
console.error("[SettingsManager.createFromHeaders] Verbose: Normalized headers count:", Object.keys(normalizedHeaders).length);
|
|
503
679
|
}
|
|
504
680
|
if (_SettingsManager.globalDebugState) {
|
|
505
|
-
console.error("Normalized
|
|
506
|
-
console.error(JSON.stringify(normalizedHeaders, null, 2));
|
|
681
|
+
console.error("Normalized header names:", Object.keys(normalizedHeaders));
|
|
507
682
|
}
|
|
508
683
|
const debugHeader = normalizedHeaders["debug"] || normalizedHeaders["Debug"] || normalizedHeaders["DEBUG"];
|
|
509
|
-
const
|
|
684
|
+
const requestedDebug = Array.isArray(debugHeader) ? debugHeader[0] : debugHeader;
|
|
685
|
+
const debugSource = {
|
|
686
|
+
debug: requestedDebug !== void 0 ? requestedDebug.toLowerCase() === "true" : _SettingsManager.globalDebugState
|
|
687
|
+
};
|
|
688
|
+
const callerHeaders = canonicalizeAliases(normalizedHeaders, this.headerAliases);
|
|
689
|
+
const source = this.connectionSource(callerHeaders, sessionId);
|
|
690
|
+
const inputHeaders = sessionHeaders(source, callerHeaders, this.operatorValues, this.basicKeys, this.operatorSettingsOverHttp);
|
|
510
691
|
if (verbose) {
|
|
692
|
+
console.error("[SettingsManager.createFromHeaders] Verbose: Connection settings source:", source);
|
|
511
693
|
console.error("[SettingsManager.createFromHeaders] Verbose: Calling settingsClass.fromHeaders");
|
|
512
694
|
}
|
|
513
|
-
const settings = this.settingsClass.fromHeaders(
|
|
695
|
+
const settings = this.settingsClass.fromHeaders(inputHeaders);
|
|
514
696
|
if (verbose) {
|
|
515
697
|
console.error("[SettingsManager.createFromHeaders] Verbose: Settings object created");
|
|
516
698
|
}
|
|
517
|
-
this.injectDebug(settings, debugSource);
|
|
699
|
+
this.injectDebug(settings, debugSource, "session");
|
|
518
700
|
if (_SettingsManager.globalDebugState) {
|
|
519
|
-
console.error("Final settings object for session:", sessionId
|
|
701
|
+
console.error("Final settings object for session:", sessionLogLabel(sessionId));
|
|
520
702
|
this.printSettingsDebug(settings);
|
|
521
703
|
console.error("=== End createFromHeaders Debug Info ===");
|
|
522
704
|
}
|
|
523
705
|
if (verbose) {
|
|
524
|
-
console.error("[SettingsManager.createFromHeaders] Verbose: Storing settings for session:", sessionId
|
|
706
|
+
console.error("[SettingsManager.createFromHeaders] Verbose: Storing settings for session:", sessionLogLabel(sessionId));
|
|
525
707
|
}
|
|
526
708
|
this.setSettings(settings, sessionId);
|
|
527
709
|
return settings;
|
|
@@ -533,14 +715,28 @@ var SettingsManager = class _SettingsManager {
|
|
|
533
715
|
clearSession(sessionId) {
|
|
534
716
|
if (sessionId !== this.defaultSessionId) {
|
|
535
717
|
this.settingsMap.delete(sessionId);
|
|
718
|
+
this.sessionSources.delete(sessionId);
|
|
536
719
|
}
|
|
537
720
|
}
|
|
721
|
+
/**
|
|
722
|
+
* The session's connection source: decided by the request that creates the
|
|
723
|
+
* session and kept for its lifetime, so a later request cannot switch it.
|
|
724
|
+
*/
|
|
725
|
+
connectionSource(headers, sessionId) {
|
|
726
|
+
const known = sessionId ? this.sessionSources.get(sessionId) : void 0;
|
|
727
|
+
if (known)
|
|
728
|
+
return known;
|
|
729
|
+
const source = chooseConnectionSource(headersRead((h) => this.settingsClass.fromHeaders(h), headers), this.basicKeys);
|
|
730
|
+
if (sessionId)
|
|
731
|
+
this.sessionSources.set(sessionId, source);
|
|
732
|
+
return source;
|
|
733
|
+
}
|
|
538
734
|
};
|
|
539
735
|
SettingsManager.globalDebugState = void 0;
|
|
540
736
|
|
|
541
737
|
// ../mcp-utils/dist/telemetry.js
|
|
542
738
|
import machineIdPkg from "node-machine-id";
|
|
543
|
-
import { createHash } from "crypto";
|
|
739
|
+
import { createHash as createHash2 } from "crypto";
|
|
544
740
|
var { machineIdSync } = machineIdPkg;
|
|
545
741
|
var machineId = null;
|
|
546
742
|
var hashedMachineId = null;
|
|
@@ -555,7 +751,7 @@ function getTelemetryUrl() {
|
|
|
555
751
|
return process.env.TELEMETRY_URL || "https://metrics.security.ai.checkpoint.com/api/v1/metrics/collect";
|
|
556
752
|
}
|
|
557
753
|
function hashString(input) {
|
|
558
|
-
return
|
|
754
|
+
return createHash2("sha256").update(input).digest("hex");
|
|
559
755
|
}
|
|
560
756
|
function getMachineId() {
|
|
561
757
|
if (!machineId) {
|
|
@@ -603,16 +799,6 @@ async function trackToolCall(mcpName, toolName, clientVersion, extra) {
|
|
|
603
799
|
}
|
|
604
800
|
|
|
605
801
|
// ../mcp-utils/dist/launcher.js
|
|
606
|
-
function optionKey(flag) {
|
|
607
|
-
const long = flag.split(/[,\s]+/).find((part) => part.startsWith("--"));
|
|
608
|
-
if (!long)
|
|
609
|
-
return void 0;
|
|
610
|
-
const negated = long.startsWith("--no-");
|
|
611
|
-
return {
|
|
612
|
-
key: long.replace(/^--(no-)?/, "").replace(/-([a-z])/g, (_match, char) => char.toUpperCase()),
|
|
613
|
-
negated
|
|
614
|
-
};
|
|
615
|
-
}
|
|
616
802
|
function mirrorBooleanFlagsToEnv(config, options) {
|
|
617
803
|
for (const option of config.options) {
|
|
618
804
|
if (option.type !== "boolean" || !option.env)
|
|
@@ -663,17 +849,23 @@ async function launchMCPServer(configPath, serverModule2) {
|
|
|
663
849
|
process.env.TELEMETRY_URL = options.telemetryUrl;
|
|
664
850
|
}
|
|
665
851
|
mirrorBooleanFlagsToEnv(config, options);
|
|
852
|
+
const transportType2 = resolveTransportType(options.transport);
|
|
853
|
+
process.env.MCP_TRANSPORT_TYPE = transportType2;
|
|
666
854
|
if (!serverModule2.settingsManager) {
|
|
667
855
|
throw new Error("ServerModule must have a settingsManager. Create it with createServerModule.");
|
|
668
856
|
}
|
|
669
857
|
const settings = serverModule2.settingsManager.createFromArgs(options);
|
|
858
|
+
serverModule2.settingsManager.setOperatorValues?.(operatorValues(config.options, options));
|
|
670
859
|
if (typeof serverModule2.server.applyToolPolicy === "function") {
|
|
671
860
|
console.error("[launchMCPServer] Applying tool policy before connecting");
|
|
672
861
|
serverModule2.server.applyToolPolicy();
|
|
673
862
|
}
|
|
674
|
-
const transportType2 = (options.transport || process.env.MCP_TRANSPORT_TYPE || "stdio").toLowerCase() === "http" ? "http" : "stdio";
|
|
675
863
|
const transportPort = options.transportPort ? parseInt(options.transportPort, 10) : process.env.MCP_TRANSPORT_PORT ? parseInt(process.env.MCP_TRANSPORT_PORT, 10) : 3e3;
|
|
676
864
|
if (transportType2 === "http") {
|
|
865
|
+
const refusal = serverModule2.httpStartupCheck?.();
|
|
866
|
+
if (refusal) {
|
|
867
|
+
throw new Error(refusal);
|
|
868
|
+
}
|
|
677
869
|
setTransportType("http");
|
|
678
870
|
await launchHTTPServer(config, serverModule2, transportPort);
|
|
679
871
|
} else {
|
|
@@ -722,7 +914,7 @@ async function launchHTTPServer(config, serverModule2, port) {
|
|
|
722
914
|
if (sessionId && transports[sessionId]) {
|
|
723
915
|
const verbose = SettingsManager.globalDebugState;
|
|
724
916
|
if (verbose) {
|
|
725
|
-
console.error("[launchHTTPServer] Verbose: Reusing existing transport for session:", sessionId);
|
|
917
|
+
console.error("[launchHTTPServer] Verbose: Reusing existing transport for session:", sessionLogLabel(sessionId));
|
|
726
918
|
}
|
|
727
919
|
transport = transports[sessionId];
|
|
728
920
|
if (!serverModule2.settingsManager) {
|
|
@@ -742,7 +934,7 @@ async function launchHTTPServer(config, serverModule2, port) {
|
|
|
742
934
|
onsessioninitialized: (sid) => {
|
|
743
935
|
const verbose = SettingsManager.globalDebugState;
|
|
744
936
|
if (verbose) {
|
|
745
|
-
console.error("[launchHTTPServer] Verbose: New session initialized:", sid);
|
|
937
|
+
console.error("[launchHTTPServer] Verbose: New session initialized:", sessionLogLabel(sid));
|
|
746
938
|
}
|
|
747
939
|
transports[sid] = transport;
|
|
748
940
|
if (verbose) {
|
|
@@ -945,7 +1137,6 @@ function headersToEnvVars(headers, config) {
|
|
|
945
1137
|
}
|
|
946
1138
|
if (verbose) {
|
|
947
1139
|
console.error("[headersToEnvVars] Verbose: Final result keys:", Object.keys(result));
|
|
948
|
-
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])));
|
|
949
1140
|
}
|
|
950
1141
|
return result;
|
|
951
1142
|
}
|
|
@@ -972,7 +1163,7 @@ var APIManagerFactory = class {
|
|
|
972
1163
|
const verbose = SettingsManager.globalDebugState;
|
|
973
1164
|
const sid = sessionId || this.defaultSessionId;
|
|
974
1165
|
if (verbose) {
|
|
975
|
-
console.error("[APIManagerFactory.getAPIManager] Verbose: Getting API manager for session:", sid);
|
|
1166
|
+
console.error("[APIManagerFactory.getAPIManager] Verbose: Getting API manager for session:", sessionLogLabel(sid));
|
|
976
1167
|
}
|
|
977
1168
|
if (!this.apiManagerMap.has(sid)) {
|
|
978
1169
|
if (verbose) {
|
|
@@ -1070,16 +1261,15 @@ var SessionContext = class {
|
|
|
1070
1261
|
/**
|
|
1071
1262
|
* Get the current session ID from the MCP extra context
|
|
1072
1263
|
* @param extra Extra context passed to MCP tool callbacks
|
|
1073
|
-
* @returns The session ID or DEFAULT_SESSION_ID
|
|
1264
|
+
* @returns The session ID, or DEFAULT_SESSION_ID under stdio
|
|
1265
|
+
* @throws Under HTTP transport when the context carries no session ID
|
|
1074
1266
|
*/
|
|
1075
1267
|
static getSessionId(extra) {
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
if (extra.sessionId) {
|
|
1082
|
-
return extra.sessionId;
|
|
1268
|
+
const sessionId = extra?.transport?.sessionId || extra?.sessionId;
|
|
1269
|
+
if (sessionId)
|
|
1270
|
+
return sessionId;
|
|
1271
|
+
if (process.env.MCP_TRANSPORT_TYPE === "http") {
|
|
1272
|
+
throw new Error("No MCP session in this request context; HTTP transport requires one");
|
|
1083
1273
|
}
|
|
1084
1274
|
return this.DEFAULT_SESSION_ID;
|
|
1085
1275
|
}
|
|
@@ -1196,10 +1386,10 @@ var SessionContext = class {
|
|
|
1196
1386
|
}
|
|
1197
1387
|
}
|
|
1198
1388
|
}
|
|
1199
|
-
console.error(`Using cached user data for
|
|
1389
|
+
console.error(`Using cached user data for ${sessionLogLabel(sessionId)}, key: ${options.cacheKey}`);
|
|
1200
1390
|
return { cancelled: false, data: dataToReturn2 };
|
|
1201
1391
|
}
|
|
1202
|
-
console.error(`Prompting user for data for
|
|
1392
|
+
console.error(`Prompting user for data for ${sessionLogLabel(sessionId)}, key: ${options.cacheKey}`);
|
|
1203
1393
|
let result;
|
|
1204
1394
|
if (options.showLoginDialog) {
|
|
1205
1395
|
const { showLoginDialog: showLoginDialog2 } = await Promise.resolve().then(() => (init_ui_dialog(), ui_dialog_exports));
|
|
@@ -1584,6 +1774,23 @@ import axios3 from "axios";
|
|
|
1584
1774
|
// ../infra/dist/api-client.js
|
|
1585
1775
|
import axios from "axios";
|
|
1586
1776
|
import https from "https";
|
|
1777
|
+
var DEBUG_LOGGABLE_REQUEST_KEYS = debugLoggableKeys([
|
|
1778
|
+
"details-level",
|
|
1779
|
+
"domain",
|
|
1780
|
+
"filter",
|
|
1781
|
+
"layer",
|
|
1782
|
+
"limit",
|
|
1783
|
+
"name",
|
|
1784
|
+
"offset",
|
|
1785
|
+
"order",
|
|
1786
|
+
"package",
|
|
1787
|
+
"show-membership",
|
|
1788
|
+
"targets",
|
|
1789
|
+
"task-id",
|
|
1790
|
+
"type",
|
|
1791
|
+
"uid",
|
|
1792
|
+
"use-object-dictionary"
|
|
1793
|
+
]);
|
|
1587
1794
|
var TokenType;
|
|
1588
1795
|
(function(TokenType2) {
|
|
1589
1796
|
TokenType2["API_KEY"] = "API_KEY";
|
|
@@ -1630,7 +1837,9 @@ var Settings = class _Settings {
|
|
|
1630
1837
|
return "STG";
|
|
1631
1838
|
return void 0;
|
|
1632
1839
|
}
|
|
1633
|
-
|
|
1840
|
+
// Takes only what it is given: the environment is read by fromArgs, so
|
|
1841
|
+
// settings built from request headers never pick up the process's values.
|
|
1842
|
+
constructor({ apiKey, username, password, s1cUrl, managementHost, managementPort = "443", cloudInfraToken, cloudConnected = false, sid, clientId, secretKey, region = "EU", devPort = "8006", gatewayUrl } = {}) {
|
|
1634
1843
|
this.region = "EU";
|
|
1635
1844
|
this.devPort = "8006";
|
|
1636
1845
|
this.gatewayUrl = "";
|
|
@@ -1810,19 +2019,20 @@ var Settings = class _Settings {
|
|
|
1810
2019
|
console.error("[Settings.fromArgs] Verbose: WARNING - Args object appears empty, no authentication values found");
|
|
1811
2020
|
}
|
|
1812
2021
|
}
|
|
2022
|
+
const env = process.env;
|
|
1813
2023
|
return new _Settings({
|
|
1814
|
-
apiKey: args.apiKey,
|
|
1815
|
-
username: args.username,
|
|
1816
|
-
password: args.password,
|
|
1817
|
-
s1cUrl: args.s1cUrl,
|
|
1818
|
-
managementHost: args.managementHost,
|
|
1819
|
-
managementPort: args.managementPort,
|
|
1820
|
-
cloudInfraToken: args.cloudInfraToken,
|
|
1821
|
-
cloudConnected: args.cloudConnected,
|
|
1822
|
-
clientId: args.clientId,
|
|
1823
|
-
secretKey: args.secretKey,
|
|
1824
|
-
region: typeof args.region === "string" ? args.region.trim().toUpperCase() : void 0,
|
|
1825
|
-
devPort: args.devPort,
|
|
2024
|
+
apiKey: args.apiKey ?? env.API_KEY,
|
|
2025
|
+
username: args.username ?? env.USERNAME,
|
|
2026
|
+
password: args.password ?? env.PASSWORD,
|
|
2027
|
+
s1cUrl: args.s1cUrl ?? env.S1C_URL,
|
|
2028
|
+
managementHost: args.managementHost ?? env.MANAGEMENT_HOST,
|
|
2029
|
+
managementPort: args.managementPort ?? (env.MANAGEMENT_PORT || void 0),
|
|
2030
|
+
cloudInfraToken: args.cloudInfraToken ?? env.CLOUD_INFRA_TOKEN,
|
|
2031
|
+
cloudConnected: args.cloudConnected ?? env.CLOUD_CONNECTED === "true",
|
|
2032
|
+
clientId: args.clientId ?? env.CLIENT_ID,
|
|
2033
|
+
secretKey: args.secretKey ?? env.SECRET_KEY,
|
|
2034
|
+
region: typeof args.region === "string" ? args.region.trim().toUpperCase() : env.REGION || void 0,
|
|
2035
|
+
devPort: args.devPort ?? (env.DEV_PORT || void 0),
|
|
1826
2036
|
gatewayUrl: args.gatewayUrl
|
|
1827
2037
|
});
|
|
1828
2038
|
}
|
|
@@ -1867,7 +2077,6 @@ var Settings = class _Settings {
|
|
|
1867
2077
|
const hasAnyValue = extractedValues.apiKey || extractedValues.username || extractedValues.password || extractedValues.s1cUrl || extractedValues.managementHost || extractedValues.cloudInfraToken;
|
|
1868
2078
|
if (!hasAnyValue) {
|
|
1869
2079
|
console.error("[Settings.fromHeaders] Verbose: WARNING - No authentication values found in headers");
|
|
1870
|
-
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])));
|
|
1871
2080
|
}
|
|
1872
2081
|
}
|
|
1873
2082
|
return new _Settings({
|
|
@@ -1888,6 +2097,17 @@ var Settings = class _Settings {
|
|
|
1888
2097
|
});
|
|
1889
2098
|
}
|
|
1890
2099
|
};
|
|
2100
|
+
Settings.debugLoggableKeys = [
|
|
2101
|
+
"management-host",
|
|
2102
|
+
"management-port",
|
|
2103
|
+
"s1c-url",
|
|
2104
|
+
"gateway-url",
|
|
2105
|
+
"region",
|
|
2106
|
+
"dev-port",
|
|
2107
|
+
"cloud-connected",
|
|
2108
|
+
"write-mode"
|
|
2109
|
+
];
|
|
2110
|
+
Settings.basicKeys = ["REGION"];
|
|
1891
2111
|
|
|
1892
2112
|
// ../infra/dist/external-user-token-manager.js
|
|
1893
2113
|
import axios2 from "axios";
|
|
@@ -2047,6 +2267,16 @@ var DocumentationToolAPIManager = class _DocumentationToolAPIManager {
|
|
|
2047
2267
|
|
|
2048
2268
|
// src/settings.ts
|
|
2049
2269
|
var DocumentationToolSettings = class _DocumentationToolSettings extends Settings {
|
|
2270
|
+
static {
|
|
2271
|
+
/**
|
|
2272
|
+
* Keys whose values debug output may print (see debugView in mcp-utils).
|
|
2273
|
+
* Anything not listed, including every credential, is shown hidden.
|
|
2274
|
+
*/
|
|
2275
|
+
this.debugLoggableKeys = [
|
|
2276
|
+
...Settings.debugLoggableKeys,
|
|
2277
|
+
"auth-url"
|
|
2278
|
+
];
|
|
2279
|
+
}
|
|
2050
2280
|
constructor(args = {}) {
|
|
2051
2281
|
super({
|
|
2052
2282
|
...args,
|
|
@@ -2062,8 +2292,12 @@ var DocumentationToolSettings = class _DocumentationToolSettings extends Setting
|
|
|
2062
2292
|
"Provide either --auth-url (Authentication URL from the API key creation dialog) or --region (EU, US, STG, or LOCAL)"
|
|
2063
2293
|
);
|
|
2064
2294
|
}
|
|
2295
|
+
const env = process.env;
|
|
2065
2296
|
return new _DocumentationToolSettings({
|
|
2066
|
-
...args
|
|
2297
|
+
...args,
|
|
2298
|
+
clientId: args.clientId ?? env.CLIENT_ID,
|
|
2299
|
+
secretKey: args.secretKey ?? env.SECRET_KEY,
|
|
2300
|
+
region: args.region ?? (env.REGION || void 0)
|
|
2067
2301
|
});
|
|
2068
2302
|
}
|
|
2069
2303
|
static fromHeaders(headers) {
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
package/package.json.bak
CHANGED