ls-mcp 1.10.0 → 1.12.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/README.md +17 -3
- package/dist/bin/cli.cjs +404 -63
- package/dist/bin/cli.mjs +397 -56
- package/dist/main.cjs +373 -61
- package/dist/main.d.cts +10 -1
- package/dist/main.d.ts +10 -1
- package/dist/main.mjs +366 -54
- package/package.json +1 -1
- package/src/components/credential-warning.ts +35 -5
- package/src/main.ts +2 -1
- package/src/services/credential-detection-service.ts +230 -44
- package/src/services/directory-bubble-service.ts +82 -0
- package/src/services/mcp-config-parser.ts +1 -0
- package/src/services/mcp-config-service.ts +47 -5
- package/src/services/mcp-path-registry.ts +50 -1
- package/src/services/mcp-server-manager-service.ts +2 -1
- package/src/types/mcp-config-service.types.ts +4 -0
- package/src/utils/url-utils.ts +24 -0
package/dist/main.cjs
CHANGED
|
@@ -36,9 +36,9 @@ __export(main_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(main_exports);
|
|
37
37
|
|
|
38
38
|
// src/services/mcp-config-service.ts
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
39
|
+
var import_node_os2 = require("os");
|
|
40
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
41
|
+
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
42
42
|
var import_node_util = __toESM(require("util"), 1);
|
|
43
43
|
|
|
44
44
|
// src/services/mcp-path-registry.ts
|
|
@@ -136,6 +136,52 @@ var MCPPathRegistry = class _MCPPathRegistry {
|
|
|
136
136
|
{ filePath: import_node_path.default.join(".gemini", "settings.json"), type: "local" }
|
|
137
137
|
]
|
|
138
138
|
};
|
|
139
|
+
static LINUX_PATHS = {
|
|
140
|
+
claude: [
|
|
141
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Claude", "claude_desktop_config.json"), type: "global" }
|
|
142
|
+
],
|
|
143
|
+
claude_code: [
|
|
144
|
+
{ filePath: ".mcp.json", type: "local" }
|
|
145
|
+
],
|
|
146
|
+
cursor: [
|
|
147
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
|
|
148
|
+
{ filePath: import_node_path.default.join(".cursor", "mcp.json"), type: "local" }
|
|
149
|
+
],
|
|
150
|
+
vscode: [
|
|
151
|
+
{ filePath: import_node_path.default.join(".vscode", "mcp.json"), type: "local" },
|
|
152
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code", "User", "settings.json"), type: "global" },
|
|
153
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "settings.json"), type: "global" },
|
|
154
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code", "User", "mcp.json"), type: "global" },
|
|
155
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "mcp.json"), type: "global" },
|
|
156
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".mcp.json"), type: "global" }
|
|
157
|
+
],
|
|
158
|
+
cline: [
|
|
159
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
160
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
161
|
+
],
|
|
162
|
+
windsurf: [
|
|
163
|
+
{ filePath: import_node_path.default.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
|
|
164
|
+
],
|
|
165
|
+
roo: [
|
|
166
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
167
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
168
|
+
],
|
|
169
|
+
"intellij-github-copilot": [
|
|
170
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
|
|
171
|
+
],
|
|
172
|
+
junie: [
|
|
173
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".junie", "mcp.json"), type: "global" },
|
|
174
|
+
{ filePath: import_node_path.default.join(".junie", "mcp", "mcp.json"), type: "local" }
|
|
175
|
+
],
|
|
176
|
+
zed: [
|
|
177
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "zed", "settings.json"), type: "global" },
|
|
178
|
+
{ filePath: import_node_path.default.join(".zed", "settings.json"), type: "local" }
|
|
179
|
+
],
|
|
180
|
+
gemini: [
|
|
181
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
|
|
182
|
+
{ filePath: import_node_path.default.join(".gemini", "settings.json"), type: "local" }
|
|
183
|
+
]
|
|
184
|
+
};
|
|
139
185
|
customApps = /* @__PURE__ */ new Map();
|
|
140
186
|
/**
|
|
141
187
|
* Get all MCP configuration file paths for a specific operating system
|
|
@@ -148,6 +194,8 @@ var MCPPathRegistry = class _MCPPathRegistry {
|
|
|
148
194
|
case "darwin":
|
|
149
195
|
case "macos":
|
|
150
196
|
return { ..._MCPPathRegistry.DARWIN_PATHS };
|
|
197
|
+
case "linux":
|
|
198
|
+
return { ..._MCPPathRegistry.LINUX_PATHS };
|
|
151
199
|
default:
|
|
152
200
|
throw new Error(`Unsupported operating system: ${os}`);
|
|
153
201
|
}
|
|
@@ -174,7 +222,7 @@ var MCPPathRegistry = class _MCPPathRegistry {
|
|
|
174
222
|
* Get all supported operating systems
|
|
175
223
|
*/
|
|
176
224
|
getSupportedOperatingSystems() {
|
|
177
|
-
return ["win32", "darwin"];
|
|
225
|
+
return ["win32", "darwin", "linux"];
|
|
178
226
|
}
|
|
179
227
|
/**
|
|
180
228
|
* Register a custom app with custom paths for a specific OS
|
|
@@ -285,6 +333,7 @@ var MCPConfigParser = class {
|
|
|
285
333
|
command: serverConfig.command || "",
|
|
286
334
|
args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
|
|
287
335
|
type: this.validateType(serverConfig.type) ? serverConfig.type : this.inferTransportType(serverConfig),
|
|
336
|
+
url: serverConfig.url,
|
|
288
337
|
env
|
|
289
338
|
};
|
|
290
339
|
}
|
|
@@ -390,45 +439,17 @@ var CredentialDetectionService = class {
|
|
|
390
439
|
*/
|
|
391
440
|
static CREDENTIAL_PATTERNS = {
|
|
392
441
|
high: [
|
|
393
|
-
//
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
/access[_-]?token/i,
|
|
397
|
-
/secret[_-]?key/i,
|
|
398
|
-
/private[_-]?key/i,
|
|
399
|
-
// Authentication Tokens
|
|
400
|
-
/auth[_-]?token/i,
|
|
401
|
-
/bearer[_-]?token/i,
|
|
402
|
-
/jwt[_-]?token/i,
|
|
403
|
-
/oauth[_-]?token/i,
|
|
442
|
+
// Generic Key and Token patterns (broad matching)
|
|
443
|
+
/.*key.*/i,
|
|
444
|
+
/.*token.*/i,
|
|
404
445
|
// Passwords
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
// Credentials
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
/openai[_-]?api[_-]?key/i,
|
|
413
|
-
/anthropic[_-]?api[_-]?key/i,
|
|
414
|
-
/firecrawl[_-]?api[_-]?key/i,
|
|
415
|
-
/github[_-]?token/i,
|
|
416
|
-
/gitlab[_-]?token/i,
|
|
417
|
-
/bitbucket[_-]?token/i,
|
|
418
|
-
// Database passwords
|
|
419
|
-
/db[_-]?password/i,
|
|
420
|
-
/database[_-]?password/i,
|
|
421
|
-
/redis[_-]?password/i,
|
|
422
|
-
/postgres[_-]?password/i,
|
|
423
|
-
/mysql[_-]?password/i,
|
|
424
|
-
// Cloud services
|
|
425
|
-
/aws[_-]?secret[_-]?access[_-]?key/i,
|
|
426
|
-
/aws[_-]?access[_-]?key[_-]?id/i,
|
|
427
|
-
/azure[_-]?key/i,
|
|
428
|
-
/gcp[_-]?key/i,
|
|
429
|
-
/google[_-]?api[_-]?key/i,
|
|
430
|
-
/gemini[_-]?api[_-]?key/i,
|
|
431
|
-
/claude[_-]?api[_-]?key/i
|
|
446
|
+
/.*password.*/i,
|
|
447
|
+
/.*passwd.*/i,
|
|
448
|
+
/.*pwd.*/i,
|
|
449
|
+
// Credentials and Secrets
|
|
450
|
+
/.*credential.*/i,
|
|
451
|
+
/.*creds.*/i,
|
|
452
|
+
/.*secret.*/i
|
|
432
453
|
],
|
|
433
454
|
low: [
|
|
434
455
|
// Organization and Account IDs
|
|
@@ -439,6 +460,178 @@ var CredentialDetectionService = class {
|
|
|
439
460
|
/openai[_-]?org[_-]?id/i
|
|
440
461
|
]
|
|
441
462
|
};
|
|
463
|
+
/**
|
|
464
|
+
* Argument patterns for detecting credentials in command-line arguments
|
|
465
|
+
*/
|
|
466
|
+
static ARGUMENT_PATTERNS = {
|
|
467
|
+
high: [
|
|
468
|
+
// API key arguments
|
|
469
|
+
/--api-key/i,
|
|
470
|
+
/--apikey/i,
|
|
471
|
+
/--key/i,
|
|
472
|
+
// Token arguments
|
|
473
|
+
/--token/i,
|
|
474
|
+
/--access-token/i,
|
|
475
|
+
/--auth-token/i,
|
|
476
|
+
/--bearer-token/i,
|
|
477
|
+
// Password arguments
|
|
478
|
+
/--password/i,
|
|
479
|
+
/--passwd/i,
|
|
480
|
+
/--pwd/i,
|
|
481
|
+
// Secret arguments
|
|
482
|
+
/--secret/i,
|
|
483
|
+
/--client-secret/i,
|
|
484
|
+
// Authentication arguments
|
|
485
|
+
/--auth/i,
|
|
486
|
+
/--authorization/i,
|
|
487
|
+
/--credentials/i,
|
|
488
|
+
/--creds/i
|
|
489
|
+
],
|
|
490
|
+
low: [
|
|
491
|
+
// Organization and account IDs
|
|
492
|
+
/--org-id/i,
|
|
493
|
+
/--organization-id/i,
|
|
494
|
+
/--account-id/i,
|
|
495
|
+
/--user-id/i
|
|
496
|
+
]
|
|
497
|
+
};
|
|
498
|
+
/**
|
|
499
|
+
* Header patterns for detecting credentials in HTTP headers
|
|
500
|
+
*/
|
|
501
|
+
static HEADER_PATTERNS = {
|
|
502
|
+
high: [
|
|
503
|
+
// Authorization headers
|
|
504
|
+
/authorization/i,
|
|
505
|
+
/auth/i,
|
|
506
|
+
// API key headers
|
|
507
|
+
/x-api-key/i,
|
|
508
|
+
/api-key/i,
|
|
509
|
+
/apikey/i,
|
|
510
|
+
// Token headers
|
|
511
|
+
/x-access-token/i,
|
|
512
|
+
/access-token/i,
|
|
513
|
+
/bearer-token/i,
|
|
514
|
+
/x-auth-token/i,
|
|
515
|
+
/auth-token/i,
|
|
516
|
+
// Custom authentication headers
|
|
517
|
+
/x-.*-key/i,
|
|
518
|
+
/x-.*-token/i,
|
|
519
|
+
/x-.*-secret/i,
|
|
520
|
+
// Service-specific patterns
|
|
521
|
+
/x-github-token/i,
|
|
522
|
+
/x-openai-key/i,
|
|
523
|
+
/x-anthropic-key/i
|
|
524
|
+
],
|
|
525
|
+
low: [
|
|
526
|
+
// User identification headers
|
|
527
|
+
/x-user-id/i,
|
|
528
|
+
/x-org-id/i,
|
|
529
|
+
/x-organization-id/i,
|
|
530
|
+
/x-account-id/i
|
|
531
|
+
]
|
|
532
|
+
};
|
|
533
|
+
/**
|
|
534
|
+
* Variable substitution pattern to detect safe variable references
|
|
535
|
+
*/
|
|
536
|
+
static VARIABLE_SUBSTITUTION_PATTERN = /^\$\{[^}]+\}$/;
|
|
537
|
+
/**
|
|
538
|
+
* Check if a value is a variable substitution pattern (e.g., ${input:token})
|
|
539
|
+
*/
|
|
540
|
+
static isVariableSubstitution(value) {
|
|
541
|
+
return this.VARIABLE_SUBSTITUTION_PATTERN.test(value);
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Analyze command-line arguments for potential credentials
|
|
545
|
+
*/
|
|
546
|
+
static analyzeArguments(args) {
|
|
547
|
+
if (!args || !Array.isArray(args) || args.length === 0) {
|
|
548
|
+
return {
|
|
549
|
+
hasCredentials: false,
|
|
550
|
+
credentialVars: [],
|
|
551
|
+
riskLevel: "none"
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
const credentialVars = [];
|
|
555
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
556
|
+
const arg = args[i];
|
|
557
|
+
const nextArg = args[i + 1];
|
|
558
|
+
const isHighRiskArg = this.ARGUMENT_PATTERNS.high.some((pattern) => pattern.test(arg));
|
|
559
|
+
const isLowRiskArg = this.ARGUMENT_PATTERNS.low.some((pattern) => pattern.test(arg));
|
|
560
|
+
if (isHighRiskArg || isLowRiskArg) {
|
|
561
|
+
if (nextArg && !nextArg.startsWith("-")) {
|
|
562
|
+
credentialVars.push({
|
|
563
|
+
name: arg,
|
|
564
|
+
value: this.maskValue(nextArg),
|
|
565
|
+
riskLevel: isHighRiskArg ? "high" : "low",
|
|
566
|
+
source: "args"
|
|
567
|
+
});
|
|
568
|
+
i++;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
const hasCredentials = credentialVars.length > 0;
|
|
573
|
+
const riskLevel = this.calculateOverallRiskLevel(credentialVars);
|
|
574
|
+
return {
|
|
575
|
+
hasCredentials,
|
|
576
|
+
credentialVars,
|
|
577
|
+
riskLevel
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Analyze HTTP headers for potential credentials
|
|
582
|
+
*/
|
|
583
|
+
static analyzeHeaders(headers) {
|
|
584
|
+
if (!headers || typeof headers !== "object") {
|
|
585
|
+
return {
|
|
586
|
+
hasCredentials: false,
|
|
587
|
+
credentialVars: [],
|
|
588
|
+
riskLevel: "none"
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
const credentialVars = [];
|
|
592
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
593
|
+
if (this.isVariableSubstitution(value)) {
|
|
594
|
+
continue;
|
|
595
|
+
}
|
|
596
|
+
const isHighRiskHeader = this.HEADER_PATTERNS.high.some((pattern) => pattern.test(name));
|
|
597
|
+
const isLowRiskHeader = this.HEADER_PATTERNS.low.some((pattern) => pattern.test(name));
|
|
598
|
+
if (isHighRiskHeader || isLowRiskHeader) {
|
|
599
|
+
credentialVars.push({
|
|
600
|
+
name,
|
|
601
|
+
value: this.maskValue(value),
|
|
602
|
+
riskLevel: isHighRiskHeader ? "high" : "low",
|
|
603
|
+
source: "headers"
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
const hasCredentials = credentialVars.length > 0;
|
|
608
|
+
const riskLevel = this.calculateOverallRiskLevel(credentialVars);
|
|
609
|
+
return {
|
|
610
|
+
hasCredentials,
|
|
611
|
+
credentialVars,
|
|
612
|
+
riskLevel
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Comprehensive analysis of server configuration for credentials
|
|
617
|
+
*/
|
|
618
|
+
static analyzeServerConfig(config) {
|
|
619
|
+
const envResult = this.analyzeEnvironmentVariables(config.env);
|
|
620
|
+
const argsResult = this.analyzeArguments(config.args);
|
|
621
|
+
const headersResult = this.analyzeHeaders(config.headers);
|
|
622
|
+
const allCredentialVars = [
|
|
623
|
+
...envResult.credentialVars,
|
|
624
|
+
...argsResult.credentialVars,
|
|
625
|
+
...headersResult.credentialVars
|
|
626
|
+
];
|
|
627
|
+
const hasCredentials = allCredentialVars.length > 0;
|
|
628
|
+
const riskLevel = this.calculateOverallRiskLevel(allCredentialVars);
|
|
629
|
+
return {
|
|
630
|
+
hasCredentials,
|
|
631
|
+
credentialVars: allCredentialVars,
|
|
632
|
+
riskLevel
|
|
633
|
+
};
|
|
634
|
+
}
|
|
442
635
|
/**
|
|
443
636
|
* Check if an environment variable name suggests it might contain credentials
|
|
444
637
|
*/
|
|
@@ -458,11 +651,15 @@ var CredentialDetectionService = class {
|
|
|
458
651
|
}
|
|
459
652
|
const credentialVars = [];
|
|
460
653
|
for (const [name, value] of Object.entries(env)) {
|
|
654
|
+
if (this.isVariableSubstitution(value)) {
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
461
657
|
if (this.isPotentialCredential(name)) {
|
|
462
658
|
credentialVars.push({
|
|
463
659
|
name,
|
|
464
660
|
value: this.maskValue(value),
|
|
465
|
-
riskLevel: this.assessRiskLevel(name)
|
|
661
|
+
riskLevel: this.assessRiskLevel(name),
|
|
662
|
+
source: "env"
|
|
466
663
|
});
|
|
467
664
|
}
|
|
468
665
|
}
|
|
@@ -513,6 +710,92 @@ var CredentialDetectionService = class {
|
|
|
513
710
|
}
|
|
514
711
|
};
|
|
515
712
|
|
|
713
|
+
// src/services/directory-bubble-service.ts
|
|
714
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
715
|
+
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
716
|
+
var import_node_os = require("os");
|
|
717
|
+
var DirectoryBubbleService = class {
|
|
718
|
+
static {
|
|
719
|
+
__name(this, "DirectoryBubbleService");
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Find a local MCP config file by bubbling up the directory tree
|
|
723
|
+
* @param localPath - The relative path to search for (e.g., '.vscode/mcp.json')
|
|
724
|
+
* @param startDir - The directory to start searching from
|
|
725
|
+
* @returns The absolute path to the found config file, or null if not found
|
|
726
|
+
*/
|
|
727
|
+
async findLocalConfigInParentDirectories(localPath, startDir) {
|
|
728
|
+
try {
|
|
729
|
+
let currentDir = import_node_path2.default.resolve(startDir);
|
|
730
|
+
const homeDir = (0, import_node_os.homedir)();
|
|
731
|
+
const rootDir = "/";
|
|
732
|
+
let iterationCount = 0;
|
|
733
|
+
const maxIterations = 100;
|
|
734
|
+
const startDirResult = await this.checkDirectoryForConfig(currentDir, localPath);
|
|
735
|
+
if (startDirResult) {
|
|
736
|
+
return import_node_path2.default.join(currentDir, localPath);
|
|
737
|
+
}
|
|
738
|
+
while (currentDir !== homeDir && currentDir !== rootDir && iterationCount < maxIterations) {
|
|
739
|
+
const parentDir = this.getParentDirectory(currentDir);
|
|
740
|
+
if (!parentDir || parentDir === currentDir) {
|
|
741
|
+
break;
|
|
742
|
+
}
|
|
743
|
+
if (parentDir === currentDir || parentDir.length >= currentDir.length) {
|
|
744
|
+
break;
|
|
745
|
+
}
|
|
746
|
+
currentDir = parentDir;
|
|
747
|
+
iterationCount++;
|
|
748
|
+
const found = await this.checkDirectoryForConfig(currentDir, localPath);
|
|
749
|
+
if (found) {
|
|
750
|
+
return import_node_path2.default.join(currentDir, localPath);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
return null;
|
|
754
|
+
} catch (error) {
|
|
755
|
+
return null;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Check if a config file exists in the specified directory
|
|
760
|
+
* @param dir - The directory to check
|
|
761
|
+
* @param configPath - The relative path to the config file
|
|
762
|
+
* @returns True if the config file exists and is accessible
|
|
763
|
+
*/
|
|
764
|
+
async checkDirectoryForConfig(dir, configPath) {
|
|
765
|
+
try {
|
|
766
|
+
const fullPath = import_node_path2.default.join(dir, configPath);
|
|
767
|
+
await import_promises2.default.access(fullPath);
|
|
768
|
+
return true;
|
|
769
|
+
} catch (error) {
|
|
770
|
+
return false;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Get the parent directory of the specified directory
|
|
775
|
+
* @param dir - The directory to get the parent of
|
|
776
|
+
* @returns The parent directory path, or null if already at root
|
|
777
|
+
*/
|
|
778
|
+
getParentDirectory(dir) {
|
|
779
|
+
const parent = import_node_path2.default.dirname(dir);
|
|
780
|
+
return parent === dir ? null : parent;
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
// src/utils/url-utils.ts
|
|
785
|
+
function extractHostname(urlString) {
|
|
786
|
+
try {
|
|
787
|
+
let urlToParse = urlString;
|
|
788
|
+
if (!urlToParse.includes("://")) {
|
|
789
|
+
urlToParse = `http://${urlToParse}`;
|
|
790
|
+
}
|
|
791
|
+
const url = new URL(urlToParse);
|
|
792
|
+
return url.hostname;
|
|
793
|
+
} catch (error) {
|
|
794
|
+
return urlString;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
__name(extractHostname, "extractHostname");
|
|
798
|
+
|
|
516
799
|
// src/services/mcp-config-service.ts
|
|
517
800
|
var MCPConfigService = class {
|
|
518
801
|
static {
|
|
@@ -521,10 +804,14 @@ var MCPConfigService = class {
|
|
|
521
804
|
pathRegistry;
|
|
522
805
|
currentOS;
|
|
523
806
|
debug;
|
|
524
|
-
|
|
807
|
+
directoryBubbleService;
|
|
808
|
+
enableDirectoryBubbling;
|
|
809
|
+
constructor(options = {}) {
|
|
525
810
|
this.pathRegistry = new MCPPathRegistry();
|
|
526
|
-
this.currentOS = (0,
|
|
811
|
+
this.currentOS = (0, import_node_os2.platform)();
|
|
527
812
|
this.debug = import_node_util.default.debuglog("ls-mcp");
|
|
813
|
+
this.directoryBubbleService = new DirectoryBubbleService();
|
|
814
|
+
this.enableDirectoryBubbling = options.enableDirectoryBubbling ?? false;
|
|
528
815
|
}
|
|
529
816
|
/**
|
|
530
817
|
* Get MCP configuration files for a specific AI application on the current OS
|
|
@@ -609,7 +896,7 @@ var MCPConfigService = class {
|
|
|
609
896
|
*/
|
|
610
897
|
async validateConfigFile(filePath) {
|
|
611
898
|
try {
|
|
612
|
-
await
|
|
899
|
+
await import_promises3.default.access(filePath);
|
|
613
900
|
const parser = this.createParser(filePath);
|
|
614
901
|
return await parser.isValidSyntax();
|
|
615
902
|
} catch (error) {
|
|
@@ -639,14 +926,28 @@ var MCPConfigService = class {
|
|
|
639
926
|
const uniqueFilePaths = /* @__PURE__ */ new Set();
|
|
640
927
|
let totalServersCount = 0;
|
|
641
928
|
for (const filePathData of paths) {
|
|
642
|
-
|
|
643
|
-
|
|
929
|
+
let resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
930
|
+
let absolutePath = import_node_path3.default.resolve(resolvedPath);
|
|
931
|
+
if (filePathData.type === "local" && this.enableDirectoryBubbling) {
|
|
932
|
+
try {
|
|
933
|
+
await import_promises3.default.access(resolvedPath);
|
|
934
|
+
} catch (error) {
|
|
935
|
+
const bubbledPath = await this.directoryBubbleService.findLocalConfigInParentDirectories(
|
|
936
|
+
filePathData.filePath,
|
|
937
|
+
process.cwd()
|
|
938
|
+
);
|
|
939
|
+
if (bubbledPath) {
|
|
940
|
+
resolvedPath = bubbledPath;
|
|
941
|
+
absolutePath = import_node_path3.default.resolve(resolvedPath);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
}
|
|
644
945
|
if (uniqueFilePaths.has(absolutePath)) {
|
|
645
946
|
continue;
|
|
646
947
|
}
|
|
647
948
|
uniqueFilePaths.add(absolutePath);
|
|
648
949
|
try {
|
|
649
|
-
await
|
|
950
|
+
await import_promises3.default.access(resolvedPath);
|
|
650
951
|
const parser = this.createParser(resolvedPath);
|
|
651
952
|
const parsable = await parser.isValidSyntax();
|
|
652
953
|
filePathData.parsable = parsable;
|
|
@@ -700,6 +1001,12 @@ var MCPConfigService = class {
|
|
|
700
1001
|
const serverInfos = [];
|
|
701
1002
|
for (const [serverName, serverConfig] of Object.entries(servers)) {
|
|
702
1003
|
if (serverConfig && typeof serverConfig === "object") {
|
|
1004
|
+
let source;
|
|
1005
|
+
if (serverConfig.url) {
|
|
1006
|
+
source = extractHostname(serverConfig.url);
|
|
1007
|
+
} else {
|
|
1008
|
+
source = serverConfig.command || "";
|
|
1009
|
+
}
|
|
703
1010
|
serverInfos.push({
|
|
704
1011
|
name: serverName,
|
|
705
1012
|
command: serverConfig.command || "",
|
|
@@ -707,11 +1014,16 @@ var MCPConfigService = class {
|
|
|
707
1014
|
transport: serverConfig.type === "streamable-http" ? "http" : serverConfig.type,
|
|
708
1015
|
// Map streamable-http to http
|
|
709
1016
|
type: serverConfig.type,
|
|
710
|
-
source
|
|
1017
|
+
source,
|
|
711
1018
|
env: serverConfig.env,
|
|
1019
|
+
headers: serverConfig.headers,
|
|
712
1020
|
status: "stopped",
|
|
713
1021
|
// Default status, will be updated by server manager
|
|
714
|
-
credentials: CredentialDetectionService.
|
|
1022
|
+
credentials: CredentialDetectionService.analyzeServerConfig({
|
|
1023
|
+
env: serverConfig.env,
|
|
1024
|
+
args: serverConfig.args,
|
|
1025
|
+
headers: serverConfig.headers
|
|
1026
|
+
})
|
|
715
1027
|
});
|
|
716
1028
|
}
|
|
717
1029
|
}
|
|
@@ -739,9 +1051,9 @@ var MCPConfigService = class {
|
|
|
739
1051
|
};
|
|
740
1052
|
|
|
741
1053
|
// src/services/mcp-server-manager-service.ts
|
|
742
|
-
var
|
|
1054
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
743
1055
|
var import_node_child_process = require("child_process");
|
|
744
|
-
var
|
|
1056
|
+
var import_node_os3 = require("os");
|
|
745
1057
|
var MCPServerManagerService = class {
|
|
746
1058
|
static {
|
|
747
1059
|
__name(this, "MCPServerManagerService");
|
|
@@ -768,7 +1080,7 @@ var MCPServerManagerService = class {
|
|
|
768
1080
|
this.transport = "stdio";
|
|
769
1081
|
}
|
|
770
1082
|
if (serverConfig.url) {
|
|
771
|
-
this.source = serverConfig.url;
|
|
1083
|
+
this.source = extractHostname(serverConfig.url);
|
|
772
1084
|
this.transport = "http";
|
|
773
1085
|
} else {
|
|
774
1086
|
const fullCommand = [serverConfig.command, ...serverConfig.args || []].join(" ");
|
|
@@ -797,7 +1109,7 @@ var MCPServerManagerService = class {
|
|
|
797
1109
|
isRunning() {
|
|
798
1110
|
try {
|
|
799
1111
|
let psOutput;
|
|
800
|
-
if ((0,
|
|
1112
|
+
if ((0, import_node_os3.platform)() === "win32") {
|
|
801
1113
|
psOutput = (0, import_node_child_process.execSync)('powershell -Command "Get-CimInstance -ClassName Win32_Process | Select-Object ProcessId,Name,CommandLine,ParentProcessId | ConvertTo-Csv -NoTypeInformation"', {
|
|
802
1114
|
encoding: "utf8",
|
|
803
1115
|
timeout: 5e3
|
|
@@ -815,7 +1127,7 @@ var MCPServerManagerService = class {
|
|
|
815
1127
|
let pid;
|
|
816
1128
|
let ppid;
|
|
817
1129
|
let commandLine;
|
|
818
|
-
if ((0,
|
|
1130
|
+
if ((0, import_node_os3.platform)() === "win32") {
|
|
819
1131
|
if (processLine.startsWith('"ProcessId"') || processLine.startsWith("ProcessId")) continue;
|
|
820
1132
|
const parts = this.parseCSVLine(processLine);
|
|
821
1133
|
if (parts.length < 4) continue;
|
|
@@ -838,7 +1150,7 @@ var MCPServerManagerService = class {
|
|
|
838
1150
|
for (const [pid, processData] of processMap) {
|
|
839
1151
|
const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid);
|
|
840
1152
|
let commandMatchWin32 = false;
|
|
841
|
-
if ((0,
|
|
1153
|
+
if ((0, import_node_os3.platform)() === "win32") {
|
|
842
1154
|
let commandTokensOnWin32 = processData.commandTokens;
|
|
843
1155
|
if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith("cmd")) {
|
|
844
1156
|
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
@@ -949,9 +1261,9 @@ var MCPServerManagerService = class {
|
|
|
949
1261
|
return true;
|
|
950
1262
|
}
|
|
951
1263
|
getBaseCommand(fullCommandPath) {
|
|
952
|
-
let baseCommand =
|
|
953
|
-
if ((0,
|
|
954
|
-
baseCommand =
|
|
1264
|
+
let baseCommand = import_node_path4.default.basename(fullCommandPath);
|
|
1265
|
+
if ((0, import_node_os3.platform)() === "win32") {
|
|
1266
|
+
baseCommand = import_node_path4.default.basename(fullCommandPath, ".exe");
|
|
955
1267
|
}
|
|
956
1268
|
baseCommand = baseCommand.toLowerCase();
|
|
957
1269
|
return baseCommand;
|
|
@@ -1139,7 +1451,7 @@ var MCPFiles = class {
|
|
|
1139
1451
|
}
|
|
1140
1452
|
mcpConfigService;
|
|
1141
1453
|
constructor() {
|
|
1142
|
-
this.mcpConfigService = new MCPConfigService();
|
|
1454
|
+
this.mcpConfigService = new MCPConfigService({ enableDirectoryBubbling: true });
|
|
1143
1455
|
}
|
|
1144
1456
|
/**
|
|
1145
1457
|
* Find and process all MCP configuration files
|
package/dist/main.d.cts
CHANGED
|
@@ -10,7 +10,9 @@ interface MCPServerConfig {
|
|
|
10
10
|
args?: string[];
|
|
11
11
|
transport?: 'stdio' | 'sse' | 'http';
|
|
12
12
|
type?: 'sse' | 'http' | 'stdio' | 'streamable-http';
|
|
13
|
+
url?: string;
|
|
13
14
|
env?: Record<string, string>;
|
|
15
|
+
headers?: Record<string, string>;
|
|
14
16
|
}
|
|
15
17
|
interface MCPAppMetadata {
|
|
16
18
|
name: string;
|
|
@@ -31,6 +33,7 @@ interface MCPServerInfo {
|
|
|
31
33
|
type?: 'sse' | 'http' | 'stdio' | 'streamable-http';
|
|
32
34
|
source?: string;
|
|
33
35
|
env?: Record<string, string>;
|
|
36
|
+
headers?: Record<string, string>;
|
|
34
37
|
status?: 'running' | 'stopped';
|
|
35
38
|
credentials?: CredentialAnalysisResult;
|
|
36
39
|
}
|
|
@@ -48,6 +51,7 @@ interface CredentialVariable {
|
|
|
48
51
|
name: string;
|
|
49
52
|
value: string;
|
|
50
53
|
riskLevel: 'low' | 'high';
|
|
54
|
+
source?: 'env' | 'args' | 'headers';
|
|
51
55
|
}
|
|
52
56
|
interface CredentialAnalysisResult {
|
|
53
57
|
hasCredentials: boolean;
|
|
@@ -74,11 +78,16 @@ declare class MCPConfigParser {
|
|
|
74
78
|
private getFileContent;
|
|
75
79
|
}
|
|
76
80
|
|
|
81
|
+
interface MCPConfigServiceOptions {
|
|
82
|
+
enableDirectoryBubbling?: boolean;
|
|
83
|
+
}
|
|
77
84
|
declare class MCPConfigService {
|
|
78
85
|
private pathRegistry;
|
|
79
86
|
private currentOS;
|
|
80
87
|
private debug;
|
|
81
|
-
|
|
88
|
+
private directoryBubbleService;
|
|
89
|
+
private enableDirectoryBubbling;
|
|
90
|
+
constructor(options?: MCPConfigServiceOptions);
|
|
82
91
|
getConfigFilesPerApp(appName: string): MCPFilePath[];
|
|
83
92
|
getAllConfigFiles(): MCPAppPathsRecord;
|
|
84
93
|
getMCPServersPerApp(appName: string): Promise<MCPServerInfo[]>;
|
package/dist/main.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ interface MCPServerConfig {
|
|
|
10
10
|
args?: string[];
|
|
11
11
|
transport?: 'stdio' | 'sse' | 'http';
|
|
12
12
|
type?: 'sse' | 'http' | 'stdio' | 'streamable-http';
|
|
13
|
+
url?: string;
|
|
13
14
|
env?: Record<string, string>;
|
|
15
|
+
headers?: Record<string, string>;
|
|
14
16
|
}
|
|
15
17
|
interface MCPAppMetadata {
|
|
16
18
|
name: string;
|
|
@@ -31,6 +33,7 @@ interface MCPServerInfo {
|
|
|
31
33
|
type?: 'sse' | 'http' | 'stdio' | 'streamable-http';
|
|
32
34
|
source?: string;
|
|
33
35
|
env?: Record<string, string>;
|
|
36
|
+
headers?: Record<string, string>;
|
|
34
37
|
status?: 'running' | 'stopped';
|
|
35
38
|
credentials?: CredentialAnalysisResult;
|
|
36
39
|
}
|
|
@@ -48,6 +51,7 @@ interface CredentialVariable {
|
|
|
48
51
|
name: string;
|
|
49
52
|
value: string;
|
|
50
53
|
riskLevel: 'low' | 'high';
|
|
54
|
+
source?: 'env' | 'args' | 'headers';
|
|
51
55
|
}
|
|
52
56
|
interface CredentialAnalysisResult {
|
|
53
57
|
hasCredentials: boolean;
|
|
@@ -74,11 +78,16 @@ declare class MCPConfigParser {
|
|
|
74
78
|
private getFileContent;
|
|
75
79
|
}
|
|
76
80
|
|
|
81
|
+
interface MCPConfigServiceOptions {
|
|
82
|
+
enableDirectoryBubbling?: boolean;
|
|
83
|
+
}
|
|
77
84
|
declare class MCPConfigService {
|
|
78
85
|
private pathRegistry;
|
|
79
86
|
private currentOS;
|
|
80
87
|
private debug;
|
|
81
|
-
|
|
88
|
+
private directoryBubbleService;
|
|
89
|
+
private enableDirectoryBubbling;
|
|
90
|
+
constructor(options?: MCPConfigServiceOptions);
|
|
82
91
|
getConfigFilesPerApp(appName: string): MCPFilePath[];
|
|
83
92
|
getAllConfigFiles(): MCPAppPathsRecord;
|
|
84
93
|
getMCPServersPerApp(appName: string): Promise<MCPServerInfo[]>;
|