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/bin/cli.mjs
CHANGED
|
@@ -7,8 +7,8 @@ import { styleText as styleText11 } from "util";
|
|
|
7
7
|
|
|
8
8
|
// src/services/mcp-config-service.ts
|
|
9
9
|
import { platform } from "os";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
10
|
+
import path3 from "path";
|
|
11
|
+
import fs3 from "fs/promises";
|
|
12
12
|
import util from "util";
|
|
13
13
|
|
|
14
14
|
// src/services/mcp-path-registry.ts
|
|
@@ -106,6 +106,52 @@ var MCPPathRegistry = class _MCPPathRegistry {
|
|
|
106
106
|
{ filePath: path.join(".gemini", "settings.json"), type: "local" }
|
|
107
107
|
]
|
|
108
108
|
};
|
|
109
|
+
static LINUX_PATHS = {
|
|
110
|
+
claude: [
|
|
111
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Claude", "claude_desktop_config.json"), type: "global" }
|
|
112
|
+
],
|
|
113
|
+
claude_code: [
|
|
114
|
+
{ filePath: ".mcp.json", type: "local" }
|
|
115
|
+
],
|
|
116
|
+
cursor: [
|
|
117
|
+
{ filePath: path.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
|
|
118
|
+
{ filePath: path.join(".cursor", "mcp.json"), type: "local" }
|
|
119
|
+
],
|
|
120
|
+
vscode: [
|
|
121
|
+
{ filePath: path.join(".vscode", "mcp.json"), type: "local" },
|
|
122
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "settings.json"), type: "global" },
|
|
123
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "settings.json"), type: "global" },
|
|
124
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "mcp.json"), type: "global" },
|
|
125
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "mcp.json"), type: "global" },
|
|
126
|
+
{ filePath: path.join(process.env.HOME || "", ".mcp.json"), type: "global" }
|
|
127
|
+
],
|
|
128
|
+
cline: [
|
|
129
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
130
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
131
|
+
],
|
|
132
|
+
windsurf: [
|
|
133
|
+
{ filePath: path.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
|
|
134
|
+
],
|
|
135
|
+
roo: [
|
|
136
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
137
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
138
|
+
],
|
|
139
|
+
"intellij-github-copilot": [
|
|
140
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
|
|
141
|
+
],
|
|
142
|
+
junie: [
|
|
143
|
+
{ filePath: path.join(process.env.HOME || "", ".junie", "mcp.json"), type: "global" },
|
|
144
|
+
{ filePath: path.join(".junie", "mcp", "mcp.json"), type: "local" }
|
|
145
|
+
],
|
|
146
|
+
zed: [
|
|
147
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "zed", "settings.json"), type: "global" },
|
|
148
|
+
{ filePath: path.join(".zed", "settings.json"), type: "local" }
|
|
149
|
+
],
|
|
150
|
+
gemini: [
|
|
151
|
+
{ filePath: path.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
|
|
152
|
+
{ filePath: path.join(".gemini", "settings.json"), type: "local" }
|
|
153
|
+
]
|
|
154
|
+
};
|
|
109
155
|
customApps = /* @__PURE__ */ new Map();
|
|
110
156
|
/**
|
|
111
157
|
* Get all MCP configuration file paths for a specific operating system
|
|
@@ -118,6 +164,8 @@ var MCPPathRegistry = class _MCPPathRegistry {
|
|
|
118
164
|
case "darwin":
|
|
119
165
|
case "macos":
|
|
120
166
|
return { ..._MCPPathRegistry.DARWIN_PATHS };
|
|
167
|
+
case "linux":
|
|
168
|
+
return { ..._MCPPathRegistry.LINUX_PATHS };
|
|
121
169
|
default:
|
|
122
170
|
throw new Error(`Unsupported operating system: ${os}`);
|
|
123
171
|
}
|
|
@@ -144,7 +192,7 @@ var MCPPathRegistry = class _MCPPathRegistry {
|
|
|
144
192
|
* Get all supported operating systems
|
|
145
193
|
*/
|
|
146
194
|
getSupportedOperatingSystems() {
|
|
147
|
-
return ["win32", "darwin"];
|
|
195
|
+
return ["win32", "darwin", "linux"];
|
|
148
196
|
}
|
|
149
197
|
/**
|
|
150
198
|
* Register a custom app with custom paths for a specific OS
|
|
@@ -255,6 +303,7 @@ var MCPConfigParser = class {
|
|
|
255
303
|
command: serverConfig.command || "",
|
|
256
304
|
args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
|
|
257
305
|
type: this.validateType(serverConfig.type) ? serverConfig.type : this.inferTransportType(serverConfig),
|
|
306
|
+
url: serverConfig.url,
|
|
258
307
|
env
|
|
259
308
|
};
|
|
260
309
|
}
|
|
@@ -360,45 +409,17 @@ var CredentialDetectionService = class {
|
|
|
360
409
|
*/
|
|
361
410
|
static CREDENTIAL_PATTERNS = {
|
|
362
411
|
high: [
|
|
363
|
-
//
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
/access[_-]?token/i,
|
|
367
|
-
/secret[_-]?key/i,
|
|
368
|
-
/private[_-]?key/i,
|
|
369
|
-
// Authentication Tokens
|
|
370
|
-
/auth[_-]?token/i,
|
|
371
|
-
/bearer[_-]?token/i,
|
|
372
|
-
/jwt[_-]?token/i,
|
|
373
|
-
/oauth[_-]?token/i,
|
|
412
|
+
// Generic Key and Token patterns (broad matching)
|
|
413
|
+
/.*key.*/i,
|
|
414
|
+
/.*token.*/i,
|
|
374
415
|
// Passwords
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
// Credentials
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
/openai[_-]?api[_-]?key/i,
|
|
383
|
-
/anthropic[_-]?api[_-]?key/i,
|
|
384
|
-
/firecrawl[_-]?api[_-]?key/i,
|
|
385
|
-
/github[_-]?token/i,
|
|
386
|
-
/gitlab[_-]?token/i,
|
|
387
|
-
/bitbucket[_-]?token/i,
|
|
388
|
-
// Database passwords
|
|
389
|
-
/db[_-]?password/i,
|
|
390
|
-
/database[_-]?password/i,
|
|
391
|
-
/redis[_-]?password/i,
|
|
392
|
-
/postgres[_-]?password/i,
|
|
393
|
-
/mysql[_-]?password/i,
|
|
394
|
-
// Cloud services
|
|
395
|
-
/aws[_-]?secret[_-]?access[_-]?key/i,
|
|
396
|
-
/aws[_-]?access[_-]?key[_-]?id/i,
|
|
397
|
-
/azure[_-]?key/i,
|
|
398
|
-
/gcp[_-]?key/i,
|
|
399
|
-
/google[_-]?api[_-]?key/i,
|
|
400
|
-
/gemini[_-]?api[_-]?key/i,
|
|
401
|
-
/claude[_-]?api[_-]?key/i
|
|
416
|
+
/.*password.*/i,
|
|
417
|
+
/.*passwd.*/i,
|
|
418
|
+
/.*pwd.*/i,
|
|
419
|
+
// Credentials and Secrets
|
|
420
|
+
/.*credential.*/i,
|
|
421
|
+
/.*creds.*/i,
|
|
422
|
+
/.*secret.*/i
|
|
402
423
|
],
|
|
403
424
|
low: [
|
|
404
425
|
// Organization and Account IDs
|
|
@@ -409,6 +430,178 @@ var CredentialDetectionService = class {
|
|
|
409
430
|
/openai[_-]?org[_-]?id/i
|
|
410
431
|
]
|
|
411
432
|
};
|
|
433
|
+
/**
|
|
434
|
+
* Argument patterns for detecting credentials in command-line arguments
|
|
435
|
+
*/
|
|
436
|
+
static ARGUMENT_PATTERNS = {
|
|
437
|
+
high: [
|
|
438
|
+
// API key arguments
|
|
439
|
+
/--api-key/i,
|
|
440
|
+
/--apikey/i,
|
|
441
|
+
/--key/i,
|
|
442
|
+
// Token arguments
|
|
443
|
+
/--token/i,
|
|
444
|
+
/--access-token/i,
|
|
445
|
+
/--auth-token/i,
|
|
446
|
+
/--bearer-token/i,
|
|
447
|
+
// Password arguments
|
|
448
|
+
/--password/i,
|
|
449
|
+
/--passwd/i,
|
|
450
|
+
/--pwd/i,
|
|
451
|
+
// Secret arguments
|
|
452
|
+
/--secret/i,
|
|
453
|
+
/--client-secret/i,
|
|
454
|
+
// Authentication arguments
|
|
455
|
+
/--auth/i,
|
|
456
|
+
/--authorization/i,
|
|
457
|
+
/--credentials/i,
|
|
458
|
+
/--creds/i
|
|
459
|
+
],
|
|
460
|
+
low: [
|
|
461
|
+
// Organization and account IDs
|
|
462
|
+
/--org-id/i,
|
|
463
|
+
/--organization-id/i,
|
|
464
|
+
/--account-id/i,
|
|
465
|
+
/--user-id/i
|
|
466
|
+
]
|
|
467
|
+
};
|
|
468
|
+
/**
|
|
469
|
+
* Header patterns for detecting credentials in HTTP headers
|
|
470
|
+
*/
|
|
471
|
+
static HEADER_PATTERNS = {
|
|
472
|
+
high: [
|
|
473
|
+
// Authorization headers
|
|
474
|
+
/authorization/i,
|
|
475
|
+
/auth/i,
|
|
476
|
+
// API key headers
|
|
477
|
+
/x-api-key/i,
|
|
478
|
+
/api-key/i,
|
|
479
|
+
/apikey/i,
|
|
480
|
+
// Token headers
|
|
481
|
+
/x-access-token/i,
|
|
482
|
+
/access-token/i,
|
|
483
|
+
/bearer-token/i,
|
|
484
|
+
/x-auth-token/i,
|
|
485
|
+
/auth-token/i,
|
|
486
|
+
// Custom authentication headers
|
|
487
|
+
/x-.*-key/i,
|
|
488
|
+
/x-.*-token/i,
|
|
489
|
+
/x-.*-secret/i,
|
|
490
|
+
// Service-specific patterns
|
|
491
|
+
/x-github-token/i,
|
|
492
|
+
/x-openai-key/i,
|
|
493
|
+
/x-anthropic-key/i
|
|
494
|
+
],
|
|
495
|
+
low: [
|
|
496
|
+
// User identification headers
|
|
497
|
+
/x-user-id/i,
|
|
498
|
+
/x-org-id/i,
|
|
499
|
+
/x-organization-id/i,
|
|
500
|
+
/x-account-id/i
|
|
501
|
+
]
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* Variable substitution pattern to detect safe variable references
|
|
505
|
+
*/
|
|
506
|
+
static VARIABLE_SUBSTITUTION_PATTERN = /^\$\{[^}]+\}$/;
|
|
507
|
+
/**
|
|
508
|
+
* Check if a value is a variable substitution pattern (e.g., ${input:token})
|
|
509
|
+
*/
|
|
510
|
+
static isVariableSubstitution(value) {
|
|
511
|
+
return this.VARIABLE_SUBSTITUTION_PATTERN.test(value);
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Analyze command-line arguments for potential credentials
|
|
515
|
+
*/
|
|
516
|
+
static analyzeArguments(args) {
|
|
517
|
+
if (!args || !Array.isArray(args) || args.length === 0) {
|
|
518
|
+
return {
|
|
519
|
+
hasCredentials: false,
|
|
520
|
+
credentialVars: [],
|
|
521
|
+
riskLevel: "none"
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
const credentialVars = [];
|
|
525
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
526
|
+
const arg = args[i];
|
|
527
|
+
const nextArg = args[i + 1];
|
|
528
|
+
const isHighRiskArg = this.ARGUMENT_PATTERNS.high.some((pattern) => pattern.test(arg));
|
|
529
|
+
const isLowRiskArg = this.ARGUMENT_PATTERNS.low.some((pattern) => pattern.test(arg));
|
|
530
|
+
if (isHighRiskArg || isLowRiskArg) {
|
|
531
|
+
if (nextArg && !nextArg.startsWith("-")) {
|
|
532
|
+
credentialVars.push({
|
|
533
|
+
name: arg,
|
|
534
|
+
value: this.maskValue(nextArg),
|
|
535
|
+
riskLevel: isHighRiskArg ? "high" : "low",
|
|
536
|
+
source: "args"
|
|
537
|
+
});
|
|
538
|
+
i++;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
const hasCredentials = credentialVars.length > 0;
|
|
543
|
+
const riskLevel = this.calculateOverallRiskLevel(credentialVars);
|
|
544
|
+
return {
|
|
545
|
+
hasCredentials,
|
|
546
|
+
credentialVars,
|
|
547
|
+
riskLevel
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Analyze HTTP headers for potential credentials
|
|
552
|
+
*/
|
|
553
|
+
static analyzeHeaders(headers) {
|
|
554
|
+
if (!headers || typeof headers !== "object") {
|
|
555
|
+
return {
|
|
556
|
+
hasCredentials: false,
|
|
557
|
+
credentialVars: [],
|
|
558
|
+
riskLevel: "none"
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
const credentialVars = [];
|
|
562
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
563
|
+
if (this.isVariableSubstitution(value)) {
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
const isHighRiskHeader = this.HEADER_PATTERNS.high.some((pattern) => pattern.test(name));
|
|
567
|
+
const isLowRiskHeader = this.HEADER_PATTERNS.low.some((pattern) => pattern.test(name));
|
|
568
|
+
if (isHighRiskHeader || isLowRiskHeader) {
|
|
569
|
+
credentialVars.push({
|
|
570
|
+
name,
|
|
571
|
+
value: this.maskValue(value),
|
|
572
|
+
riskLevel: isHighRiskHeader ? "high" : "low",
|
|
573
|
+
source: "headers"
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
const hasCredentials = credentialVars.length > 0;
|
|
578
|
+
const riskLevel = this.calculateOverallRiskLevel(credentialVars);
|
|
579
|
+
return {
|
|
580
|
+
hasCredentials,
|
|
581
|
+
credentialVars,
|
|
582
|
+
riskLevel
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Comprehensive analysis of server configuration for credentials
|
|
587
|
+
*/
|
|
588
|
+
static analyzeServerConfig(config) {
|
|
589
|
+
const envResult = this.analyzeEnvironmentVariables(config.env);
|
|
590
|
+
const argsResult = this.analyzeArguments(config.args);
|
|
591
|
+
const headersResult = this.analyzeHeaders(config.headers);
|
|
592
|
+
const allCredentialVars = [
|
|
593
|
+
...envResult.credentialVars,
|
|
594
|
+
...argsResult.credentialVars,
|
|
595
|
+
...headersResult.credentialVars
|
|
596
|
+
];
|
|
597
|
+
const hasCredentials = allCredentialVars.length > 0;
|
|
598
|
+
const riskLevel = this.calculateOverallRiskLevel(allCredentialVars);
|
|
599
|
+
return {
|
|
600
|
+
hasCredentials,
|
|
601
|
+
credentialVars: allCredentialVars,
|
|
602
|
+
riskLevel
|
|
603
|
+
};
|
|
604
|
+
}
|
|
412
605
|
/**
|
|
413
606
|
* Check if an environment variable name suggests it might contain credentials
|
|
414
607
|
*/
|
|
@@ -428,11 +621,15 @@ var CredentialDetectionService = class {
|
|
|
428
621
|
}
|
|
429
622
|
const credentialVars = [];
|
|
430
623
|
for (const [name, value] of Object.entries(env)) {
|
|
624
|
+
if (this.isVariableSubstitution(value)) {
|
|
625
|
+
continue;
|
|
626
|
+
}
|
|
431
627
|
if (this.isPotentialCredential(name)) {
|
|
432
628
|
credentialVars.push({
|
|
433
629
|
name,
|
|
434
630
|
value: this.maskValue(value),
|
|
435
|
-
riskLevel: this.assessRiskLevel(name)
|
|
631
|
+
riskLevel: this.assessRiskLevel(name),
|
|
632
|
+
source: "env"
|
|
436
633
|
});
|
|
437
634
|
}
|
|
438
635
|
}
|
|
@@ -483,6 +680,92 @@ var CredentialDetectionService = class {
|
|
|
483
680
|
}
|
|
484
681
|
};
|
|
485
682
|
|
|
683
|
+
// src/services/directory-bubble-service.ts
|
|
684
|
+
import path2 from "path";
|
|
685
|
+
import fs2 from "fs/promises";
|
|
686
|
+
import { homedir } from "os";
|
|
687
|
+
var DirectoryBubbleService = class {
|
|
688
|
+
static {
|
|
689
|
+
__name(this, "DirectoryBubbleService");
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Find a local MCP config file by bubbling up the directory tree
|
|
693
|
+
* @param localPath - The relative path to search for (e.g., '.vscode/mcp.json')
|
|
694
|
+
* @param startDir - The directory to start searching from
|
|
695
|
+
* @returns The absolute path to the found config file, or null if not found
|
|
696
|
+
*/
|
|
697
|
+
async findLocalConfigInParentDirectories(localPath, startDir) {
|
|
698
|
+
try {
|
|
699
|
+
let currentDir = path2.resolve(startDir);
|
|
700
|
+
const homeDir = homedir();
|
|
701
|
+
const rootDir = "/";
|
|
702
|
+
let iterationCount = 0;
|
|
703
|
+
const maxIterations = 100;
|
|
704
|
+
const startDirResult = await this.checkDirectoryForConfig(currentDir, localPath);
|
|
705
|
+
if (startDirResult) {
|
|
706
|
+
return path2.join(currentDir, localPath);
|
|
707
|
+
}
|
|
708
|
+
while (currentDir !== homeDir && currentDir !== rootDir && iterationCount < maxIterations) {
|
|
709
|
+
const parentDir = this.getParentDirectory(currentDir);
|
|
710
|
+
if (!parentDir || parentDir === currentDir) {
|
|
711
|
+
break;
|
|
712
|
+
}
|
|
713
|
+
if (parentDir === currentDir || parentDir.length >= currentDir.length) {
|
|
714
|
+
break;
|
|
715
|
+
}
|
|
716
|
+
currentDir = parentDir;
|
|
717
|
+
iterationCount++;
|
|
718
|
+
const found = await this.checkDirectoryForConfig(currentDir, localPath);
|
|
719
|
+
if (found) {
|
|
720
|
+
return path2.join(currentDir, localPath);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
return null;
|
|
724
|
+
} catch (error) {
|
|
725
|
+
return null;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Check if a config file exists in the specified directory
|
|
730
|
+
* @param dir - The directory to check
|
|
731
|
+
* @param configPath - The relative path to the config file
|
|
732
|
+
* @returns True if the config file exists and is accessible
|
|
733
|
+
*/
|
|
734
|
+
async checkDirectoryForConfig(dir, configPath) {
|
|
735
|
+
try {
|
|
736
|
+
const fullPath = path2.join(dir, configPath);
|
|
737
|
+
await fs2.access(fullPath);
|
|
738
|
+
return true;
|
|
739
|
+
} catch (error) {
|
|
740
|
+
return false;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Get the parent directory of the specified directory
|
|
745
|
+
* @param dir - The directory to get the parent of
|
|
746
|
+
* @returns The parent directory path, or null if already at root
|
|
747
|
+
*/
|
|
748
|
+
getParentDirectory(dir) {
|
|
749
|
+
const parent = path2.dirname(dir);
|
|
750
|
+
return parent === dir ? null : parent;
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
// src/utils/url-utils.ts
|
|
755
|
+
function extractHostname(urlString) {
|
|
756
|
+
try {
|
|
757
|
+
let urlToParse = urlString;
|
|
758
|
+
if (!urlToParse.includes("://")) {
|
|
759
|
+
urlToParse = `http://${urlToParse}`;
|
|
760
|
+
}
|
|
761
|
+
const url = new URL(urlToParse);
|
|
762
|
+
return url.hostname;
|
|
763
|
+
} catch (error) {
|
|
764
|
+
return urlString;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
__name(extractHostname, "extractHostname");
|
|
768
|
+
|
|
486
769
|
// src/services/mcp-config-service.ts
|
|
487
770
|
var MCPConfigService = class {
|
|
488
771
|
static {
|
|
@@ -491,10 +774,14 @@ var MCPConfigService = class {
|
|
|
491
774
|
pathRegistry;
|
|
492
775
|
currentOS;
|
|
493
776
|
debug;
|
|
494
|
-
|
|
777
|
+
directoryBubbleService;
|
|
778
|
+
enableDirectoryBubbling;
|
|
779
|
+
constructor(options = {}) {
|
|
495
780
|
this.pathRegistry = new MCPPathRegistry();
|
|
496
781
|
this.currentOS = platform();
|
|
497
782
|
this.debug = util.debuglog("ls-mcp");
|
|
783
|
+
this.directoryBubbleService = new DirectoryBubbleService();
|
|
784
|
+
this.enableDirectoryBubbling = options.enableDirectoryBubbling ?? false;
|
|
498
785
|
}
|
|
499
786
|
/**
|
|
500
787
|
* Get MCP configuration files for a specific AI application on the current OS
|
|
@@ -579,7 +866,7 @@ var MCPConfigService = class {
|
|
|
579
866
|
*/
|
|
580
867
|
async validateConfigFile(filePath) {
|
|
581
868
|
try {
|
|
582
|
-
await
|
|
869
|
+
await fs3.access(filePath);
|
|
583
870
|
const parser = this.createParser(filePath);
|
|
584
871
|
return await parser.isValidSyntax();
|
|
585
872
|
} catch (error) {
|
|
@@ -609,14 +896,28 @@ var MCPConfigService = class {
|
|
|
609
896
|
const uniqueFilePaths = /* @__PURE__ */ new Set();
|
|
610
897
|
let totalServersCount = 0;
|
|
611
898
|
for (const filePathData of paths) {
|
|
612
|
-
|
|
613
|
-
|
|
899
|
+
let resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
900
|
+
let absolutePath = path3.resolve(resolvedPath);
|
|
901
|
+
if (filePathData.type === "local" && this.enableDirectoryBubbling) {
|
|
902
|
+
try {
|
|
903
|
+
await fs3.access(resolvedPath);
|
|
904
|
+
} catch (error) {
|
|
905
|
+
const bubbledPath = await this.directoryBubbleService.findLocalConfigInParentDirectories(
|
|
906
|
+
filePathData.filePath,
|
|
907
|
+
process.cwd()
|
|
908
|
+
);
|
|
909
|
+
if (bubbledPath) {
|
|
910
|
+
resolvedPath = bubbledPath;
|
|
911
|
+
absolutePath = path3.resolve(resolvedPath);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
}
|
|
614
915
|
if (uniqueFilePaths.has(absolutePath)) {
|
|
615
916
|
continue;
|
|
616
917
|
}
|
|
617
918
|
uniqueFilePaths.add(absolutePath);
|
|
618
919
|
try {
|
|
619
|
-
await
|
|
920
|
+
await fs3.access(resolvedPath);
|
|
620
921
|
const parser = this.createParser(resolvedPath);
|
|
621
922
|
const parsable = await parser.isValidSyntax();
|
|
622
923
|
filePathData.parsable = parsable;
|
|
@@ -670,6 +971,12 @@ var MCPConfigService = class {
|
|
|
670
971
|
const serverInfos = [];
|
|
671
972
|
for (const [serverName, serverConfig] of Object.entries(servers)) {
|
|
672
973
|
if (serverConfig && typeof serverConfig === "object") {
|
|
974
|
+
let source;
|
|
975
|
+
if (serverConfig.url) {
|
|
976
|
+
source = extractHostname(serverConfig.url);
|
|
977
|
+
} else {
|
|
978
|
+
source = serverConfig.command || "";
|
|
979
|
+
}
|
|
673
980
|
serverInfos.push({
|
|
674
981
|
name: serverName,
|
|
675
982
|
command: serverConfig.command || "",
|
|
@@ -677,11 +984,16 @@ var MCPConfigService = class {
|
|
|
677
984
|
transport: serverConfig.type === "streamable-http" ? "http" : serverConfig.type,
|
|
678
985
|
// Map streamable-http to http
|
|
679
986
|
type: serverConfig.type,
|
|
680
|
-
source
|
|
987
|
+
source,
|
|
681
988
|
env: serverConfig.env,
|
|
989
|
+
headers: serverConfig.headers,
|
|
682
990
|
status: "stopped",
|
|
683
991
|
// Default status, will be updated by server manager
|
|
684
|
-
credentials: CredentialDetectionService.
|
|
992
|
+
credentials: CredentialDetectionService.analyzeServerConfig({
|
|
993
|
+
env: serverConfig.env,
|
|
994
|
+
args: serverConfig.args,
|
|
995
|
+
headers: serverConfig.headers
|
|
996
|
+
})
|
|
685
997
|
});
|
|
686
998
|
}
|
|
687
999
|
}
|
|
@@ -709,7 +1021,7 @@ var MCPConfigService = class {
|
|
|
709
1021
|
};
|
|
710
1022
|
|
|
711
1023
|
// src/services/mcp-server-manager-service.ts
|
|
712
|
-
import
|
|
1024
|
+
import path4 from "path";
|
|
713
1025
|
import { execSync } from "child_process";
|
|
714
1026
|
import { platform as platform2 } from "os";
|
|
715
1027
|
var MCPServerManagerService = class {
|
|
@@ -738,7 +1050,7 @@ var MCPServerManagerService = class {
|
|
|
738
1050
|
this.transport = "stdio";
|
|
739
1051
|
}
|
|
740
1052
|
if (serverConfig.url) {
|
|
741
|
-
this.source = serverConfig.url;
|
|
1053
|
+
this.source = extractHostname(serverConfig.url);
|
|
742
1054
|
this.transport = "http";
|
|
743
1055
|
} else {
|
|
744
1056
|
const fullCommand = [serverConfig.command, ...serverConfig.args || []].join(" ");
|
|
@@ -919,9 +1231,9 @@ var MCPServerManagerService = class {
|
|
|
919
1231
|
return true;
|
|
920
1232
|
}
|
|
921
1233
|
getBaseCommand(fullCommandPath) {
|
|
922
|
-
let baseCommand =
|
|
1234
|
+
let baseCommand = path4.basename(fullCommandPath);
|
|
923
1235
|
if (platform2() === "win32") {
|
|
924
|
-
baseCommand =
|
|
1236
|
+
baseCommand = path4.basename(fullCommandPath, ".exe");
|
|
925
1237
|
}
|
|
926
1238
|
baseCommand = baseCommand.toLowerCase();
|
|
927
1239
|
return baseCommand;
|
|
@@ -1109,7 +1421,7 @@ var MCPFiles = class {
|
|
|
1109
1421
|
}
|
|
1110
1422
|
mcpConfigService;
|
|
1111
1423
|
constructor() {
|
|
1112
|
-
this.mcpConfigService = new MCPConfigService();
|
|
1424
|
+
this.mcpConfigService = new MCPConfigService({ enableDirectoryBubbling: true });
|
|
1113
1425
|
}
|
|
1114
1426
|
/**
|
|
1115
1427
|
* Find and process all MCP configuration files
|
|
@@ -1264,10 +1576,39 @@ function CredentialWarningComponent(credentials) {
|
|
|
1264
1576
|
riskIcon = styleText8(["blue"], "\u25CF");
|
|
1265
1577
|
}
|
|
1266
1578
|
const riskText = styleText8([riskColor], `${riskIcon} ${riskLevel.toUpperCase()} RISK`);
|
|
1267
|
-
const
|
|
1268
|
-
|
|
1579
|
+
const credsBySource = credentialVars.reduce((acc, cv) => {
|
|
1580
|
+
const source = cv.source || "env";
|
|
1581
|
+
if (!acc[source]) {
|
|
1582
|
+
acc[source] = [];
|
|
1583
|
+
}
|
|
1584
|
+
acc[source].push(cv);
|
|
1585
|
+
return acc;
|
|
1586
|
+
}, {});
|
|
1587
|
+
const sourceSummaries = Object.entries(credsBySource).map(([source, creds]) => {
|
|
1588
|
+
const sourceIcon = getSourceIcon(source);
|
|
1589
|
+
const credList = creds.map((cv) => `${cv.name}=${cv.value}`).join(", ");
|
|
1590
|
+
return `${sourceIcon}${source}: ${credList}`;
|
|
1591
|
+
});
|
|
1592
|
+
const credentialSummary = sourceSummaries.join(" | ");
|
|
1593
|
+
return `${riskText} ${styleText8(["dim"], `(${credentialVars.length} creds: ${credentialSummary})`)}`;
|
|
1269
1594
|
}
|
|
1270
1595
|
__name(CredentialWarningComponent, "CredentialWarningComponent");
|
|
1596
|
+
function getSourceIcon(source) {
|
|
1597
|
+
switch (source) {
|
|
1598
|
+
case "env":
|
|
1599
|
+
return "\u{1F331} ";
|
|
1600
|
+
// Environment variable
|
|
1601
|
+
case "args":
|
|
1602
|
+
return "\u26A1 ";
|
|
1603
|
+
// Command argument
|
|
1604
|
+
case "headers":
|
|
1605
|
+
return "\u{1F517} ";
|
|
1606
|
+
// HTTP header
|
|
1607
|
+
default:
|
|
1608
|
+
return "\u{1F4CB} ";
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
__name(getSourceIcon, "getSourceIcon");
|
|
1271
1612
|
|
|
1272
1613
|
// src/components/summary.ts
|
|
1273
1614
|
import { styleText as styleText9 } from "util";
|