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.mjs
CHANGED
|
@@ -3,8 +3,8 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/services/mcp-config-service.ts
|
|
5
5
|
import { platform } from "os";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import path3 from "path";
|
|
7
|
+
import fs3 from "fs/promises";
|
|
8
8
|
import util from "util";
|
|
9
9
|
|
|
10
10
|
// src/services/mcp-path-registry.ts
|
|
@@ -102,6 +102,52 @@ var MCPPathRegistry = class _MCPPathRegistry {
|
|
|
102
102
|
{ filePath: path.join(".gemini", "settings.json"), type: "local" }
|
|
103
103
|
]
|
|
104
104
|
};
|
|
105
|
+
static LINUX_PATHS = {
|
|
106
|
+
claude: [
|
|
107
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Claude", "claude_desktop_config.json"), type: "global" }
|
|
108
|
+
],
|
|
109
|
+
claude_code: [
|
|
110
|
+
{ filePath: ".mcp.json", type: "local" }
|
|
111
|
+
],
|
|
112
|
+
cursor: [
|
|
113
|
+
{ filePath: path.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
|
|
114
|
+
{ filePath: path.join(".cursor", "mcp.json"), type: "local" }
|
|
115
|
+
],
|
|
116
|
+
vscode: [
|
|
117
|
+
{ filePath: path.join(".vscode", "mcp.json"), type: "local" },
|
|
118
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "settings.json"), type: "global" },
|
|
119
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "settings.json"), type: "global" },
|
|
120
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "mcp.json"), type: "global" },
|
|
121
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "mcp.json"), type: "global" },
|
|
122
|
+
{ filePath: path.join(process.env.HOME || "", ".mcp.json"), type: "global" }
|
|
123
|
+
],
|
|
124
|
+
cline: [
|
|
125
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
126
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
127
|
+
],
|
|
128
|
+
windsurf: [
|
|
129
|
+
{ filePath: path.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
|
|
130
|
+
],
|
|
131
|
+
roo: [
|
|
132
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
133
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
134
|
+
],
|
|
135
|
+
"intellij-github-copilot": [
|
|
136
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
|
|
137
|
+
],
|
|
138
|
+
junie: [
|
|
139
|
+
{ filePath: path.join(process.env.HOME || "", ".junie", "mcp.json"), type: "global" },
|
|
140
|
+
{ filePath: path.join(".junie", "mcp", "mcp.json"), type: "local" }
|
|
141
|
+
],
|
|
142
|
+
zed: [
|
|
143
|
+
{ filePath: path.join(process.env.HOME || "", ".config", "zed", "settings.json"), type: "global" },
|
|
144
|
+
{ filePath: path.join(".zed", "settings.json"), type: "local" }
|
|
145
|
+
],
|
|
146
|
+
gemini: [
|
|
147
|
+
{ filePath: path.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
|
|
148
|
+
{ filePath: path.join(".gemini", "settings.json"), type: "local" }
|
|
149
|
+
]
|
|
150
|
+
};
|
|
105
151
|
customApps = /* @__PURE__ */ new Map();
|
|
106
152
|
/**
|
|
107
153
|
* Get all MCP configuration file paths for a specific operating system
|
|
@@ -114,6 +160,8 @@ var MCPPathRegistry = class _MCPPathRegistry {
|
|
|
114
160
|
case "darwin":
|
|
115
161
|
case "macos":
|
|
116
162
|
return { ..._MCPPathRegistry.DARWIN_PATHS };
|
|
163
|
+
case "linux":
|
|
164
|
+
return { ..._MCPPathRegistry.LINUX_PATHS };
|
|
117
165
|
default:
|
|
118
166
|
throw new Error(`Unsupported operating system: ${os}`);
|
|
119
167
|
}
|
|
@@ -140,7 +188,7 @@ var MCPPathRegistry = class _MCPPathRegistry {
|
|
|
140
188
|
* Get all supported operating systems
|
|
141
189
|
*/
|
|
142
190
|
getSupportedOperatingSystems() {
|
|
143
|
-
return ["win32", "darwin"];
|
|
191
|
+
return ["win32", "darwin", "linux"];
|
|
144
192
|
}
|
|
145
193
|
/**
|
|
146
194
|
* Register a custom app with custom paths for a specific OS
|
|
@@ -251,6 +299,7 @@ var MCPConfigParser = class {
|
|
|
251
299
|
command: serverConfig.command || "",
|
|
252
300
|
args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
|
|
253
301
|
type: this.validateType(serverConfig.type) ? serverConfig.type : this.inferTransportType(serverConfig),
|
|
302
|
+
url: serverConfig.url,
|
|
254
303
|
env
|
|
255
304
|
};
|
|
256
305
|
}
|
|
@@ -356,45 +405,17 @@ var CredentialDetectionService = class {
|
|
|
356
405
|
*/
|
|
357
406
|
static CREDENTIAL_PATTERNS = {
|
|
358
407
|
high: [
|
|
359
|
-
//
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
/access[_-]?token/i,
|
|
363
|
-
/secret[_-]?key/i,
|
|
364
|
-
/private[_-]?key/i,
|
|
365
|
-
// Authentication Tokens
|
|
366
|
-
/auth[_-]?token/i,
|
|
367
|
-
/bearer[_-]?token/i,
|
|
368
|
-
/jwt[_-]?token/i,
|
|
369
|
-
/oauth[_-]?token/i,
|
|
408
|
+
// Generic Key and Token patterns (broad matching)
|
|
409
|
+
/.*key.*/i,
|
|
410
|
+
/.*token.*/i,
|
|
370
411
|
// Passwords
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
// Credentials
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
/openai[_-]?api[_-]?key/i,
|
|
379
|
-
/anthropic[_-]?api[_-]?key/i,
|
|
380
|
-
/firecrawl[_-]?api[_-]?key/i,
|
|
381
|
-
/github[_-]?token/i,
|
|
382
|
-
/gitlab[_-]?token/i,
|
|
383
|
-
/bitbucket[_-]?token/i,
|
|
384
|
-
// Database passwords
|
|
385
|
-
/db[_-]?password/i,
|
|
386
|
-
/database[_-]?password/i,
|
|
387
|
-
/redis[_-]?password/i,
|
|
388
|
-
/postgres[_-]?password/i,
|
|
389
|
-
/mysql[_-]?password/i,
|
|
390
|
-
// Cloud services
|
|
391
|
-
/aws[_-]?secret[_-]?access[_-]?key/i,
|
|
392
|
-
/aws[_-]?access[_-]?key[_-]?id/i,
|
|
393
|
-
/azure[_-]?key/i,
|
|
394
|
-
/gcp[_-]?key/i,
|
|
395
|
-
/google[_-]?api[_-]?key/i,
|
|
396
|
-
/gemini[_-]?api[_-]?key/i,
|
|
397
|
-
/claude[_-]?api[_-]?key/i
|
|
412
|
+
/.*password.*/i,
|
|
413
|
+
/.*passwd.*/i,
|
|
414
|
+
/.*pwd.*/i,
|
|
415
|
+
// Credentials and Secrets
|
|
416
|
+
/.*credential.*/i,
|
|
417
|
+
/.*creds.*/i,
|
|
418
|
+
/.*secret.*/i
|
|
398
419
|
],
|
|
399
420
|
low: [
|
|
400
421
|
// Organization and Account IDs
|
|
@@ -405,6 +426,178 @@ var CredentialDetectionService = class {
|
|
|
405
426
|
/openai[_-]?org[_-]?id/i
|
|
406
427
|
]
|
|
407
428
|
};
|
|
429
|
+
/**
|
|
430
|
+
* Argument patterns for detecting credentials in command-line arguments
|
|
431
|
+
*/
|
|
432
|
+
static ARGUMENT_PATTERNS = {
|
|
433
|
+
high: [
|
|
434
|
+
// API key arguments
|
|
435
|
+
/--api-key/i,
|
|
436
|
+
/--apikey/i,
|
|
437
|
+
/--key/i,
|
|
438
|
+
// Token arguments
|
|
439
|
+
/--token/i,
|
|
440
|
+
/--access-token/i,
|
|
441
|
+
/--auth-token/i,
|
|
442
|
+
/--bearer-token/i,
|
|
443
|
+
// Password arguments
|
|
444
|
+
/--password/i,
|
|
445
|
+
/--passwd/i,
|
|
446
|
+
/--pwd/i,
|
|
447
|
+
// Secret arguments
|
|
448
|
+
/--secret/i,
|
|
449
|
+
/--client-secret/i,
|
|
450
|
+
// Authentication arguments
|
|
451
|
+
/--auth/i,
|
|
452
|
+
/--authorization/i,
|
|
453
|
+
/--credentials/i,
|
|
454
|
+
/--creds/i
|
|
455
|
+
],
|
|
456
|
+
low: [
|
|
457
|
+
// Organization and account IDs
|
|
458
|
+
/--org-id/i,
|
|
459
|
+
/--organization-id/i,
|
|
460
|
+
/--account-id/i,
|
|
461
|
+
/--user-id/i
|
|
462
|
+
]
|
|
463
|
+
};
|
|
464
|
+
/**
|
|
465
|
+
* Header patterns for detecting credentials in HTTP headers
|
|
466
|
+
*/
|
|
467
|
+
static HEADER_PATTERNS = {
|
|
468
|
+
high: [
|
|
469
|
+
// Authorization headers
|
|
470
|
+
/authorization/i,
|
|
471
|
+
/auth/i,
|
|
472
|
+
// API key headers
|
|
473
|
+
/x-api-key/i,
|
|
474
|
+
/api-key/i,
|
|
475
|
+
/apikey/i,
|
|
476
|
+
// Token headers
|
|
477
|
+
/x-access-token/i,
|
|
478
|
+
/access-token/i,
|
|
479
|
+
/bearer-token/i,
|
|
480
|
+
/x-auth-token/i,
|
|
481
|
+
/auth-token/i,
|
|
482
|
+
// Custom authentication headers
|
|
483
|
+
/x-.*-key/i,
|
|
484
|
+
/x-.*-token/i,
|
|
485
|
+
/x-.*-secret/i,
|
|
486
|
+
// Service-specific patterns
|
|
487
|
+
/x-github-token/i,
|
|
488
|
+
/x-openai-key/i,
|
|
489
|
+
/x-anthropic-key/i
|
|
490
|
+
],
|
|
491
|
+
low: [
|
|
492
|
+
// User identification headers
|
|
493
|
+
/x-user-id/i,
|
|
494
|
+
/x-org-id/i,
|
|
495
|
+
/x-organization-id/i,
|
|
496
|
+
/x-account-id/i
|
|
497
|
+
]
|
|
498
|
+
};
|
|
499
|
+
/**
|
|
500
|
+
* Variable substitution pattern to detect safe variable references
|
|
501
|
+
*/
|
|
502
|
+
static VARIABLE_SUBSTITUTION_PATTERN = /^\$\{[^}]+\}$/;
|
|
503
|
+
/**
|
|
504
|
+
* Check if a value is a variable substitution pattern (e.g., ${input:token})
|
|
505
|
+
*/
|
|
506
|
+
static isVariableSubstitution(value) {
|
|
507
|
+
return this.VARIABLE_SUBSTITUTION_PATTERN.test(value);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Analyze command-line arguments for potential credentials
|
|
511
|
+
*/
|
|
512
|
+
static analyzeArguments(args) {
|
|
513
|
+
if (!args || !Array.isArray(args) || args.length === 0) {
|
|
514
|
+
return {
|
|
515
|
+
hasCredentials: false,
|
|
516
|
+
credentialVars: [],
|
|
517
|
+
riskLevel: "none"
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
const credentialVars = [];
|
|
521
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
522
|
+
const arg = args[i];
|
|
523
|
+
const nextArg = args[i + 1];
|
|
524
|
+
const isHighRiskArg = this.ARGUMENT_PATTERNS.high.some((pattern) => pattern.test(arg));
|
|
525
|
+
const isLowRiskArg = this.ARGUMENT_PATTERNS.low.some((pattern) => pattern.test(arg));
|
|
526
|
+
if (isHighRiskArg || isLowRiskArg) {
|
|
527
|
+
if (nextArg && !nextArg.startsWith("-")) {
|
|
528
|
+
credentialVars.push({
|
|
529
|
+
name: arg,
|
|
530
|
+
value: this.maskValue(nextArg),
|
|
531
|
+
riskLevel: isHighRiskArg ? "high" : "low",
|
|
532
|
+
source: "args"
|
|
533
|
+
});
|
|
534
|
+
i++;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
const hasCredentials = credentialVars.length > 0;
|
|
539
|
+
const riskLevel = this.calculateOverallRiskLevel(credentialVars);
|
|
540
|
+
return {
|
|
541
|
+
hasCredentials,
|
|
542
|
+
credentialVars,
|
|
543
|
+
riskLevel
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Analyze HTTP headers for potential credentials
|
|
548
|
+
*/
|
|
549
|
+
static analyzeHeaders(headers) {
|
|
550
|
+
if (!headers || typeof headers !== "object") {
|
|
551
|
+
return {
|
|
552
|
+
hasCredentials: false,
|
|
553
|
+
credentialVars: [],
|
|
554
|
+
riskLevel: "none"
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
const credentialVars = [];
|
|
558
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
559
|
+
if (this.isVariableSubstitution(value)) {
|
|
560
|
+
continue;
|
|
561
|
+
}
|
|
562
|
+
const isHighRiskHeader = this.HEADER_PATTERNS.high.some((pattern) => pattern.test(name));
|
|
563
|
+
const isLowRiskHeader = this.HEADER_PATTERNS.low.some((pattern) => pattern.test(name));
|
|
564
|
+
if (isHighRiskHeader || isLowRiskHeader) {
|
|
565
|
+
credentialVars.push({
|
|
566
|
+
name,
|
|
567
|
+
value: this.maskValue(value),
|
|
568
|
+
riskLevel: isHighRiskHeader ? "high" : "low",
|
|
569
|
+
source: "headers"
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
const hasCredentials = credentialVars.length > 0;
|
|
574
|
+
const riskLevel = this.calculateOverallRiskLevel(credentialVars);
|
|
575
|
+
return {
|
|
576
|
+
hasCredentials,
|
|
577
|
+
credentialVars,
|
|
578
|
+
riskLevel
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Comprehensive analysis of server configuration for credentials
|
|
583
|
+
*/
|
|
584
|
+
static analyzeServerConfig(config) {
|
|
585
|
+
const envResult = this.analyzeEnvironmentVariables(config.env);
|
|
586
|
+
const argsResult = this.analyzeArguments(config.args);
|
|
587
|
+
const headersResult = this.analyzeHeaders(config.headers);
|
|
588
|
+
const allCredentialVars = [
|
|
589
|
+
...envResult.credentialVars,
|
|
590
|
+
...argsResult.credentialVars,
|
|
591
|
+
...headersResult.credentialVars
|
|
592
|
+
];
|
|
593
|
+
const hasCredentials = allCredentialVars.length > 0;
|
|
594
|
+
const riskLevel = this.calculateOverallRiskLevel(allCredentialVars);
|
|
595
|
+
return {
|
|
596
|
+
hasCredentials,
|
|
597
|
+
credentialVars: allCredentialVars,
|
|
598
|
+
riskLevel
|
|
599
|
+
};
|
|
600
|
+
}
|
|
408
601
|
/**
|
|
409
602
|
* Check if an environment variable name suggests it might contain credentials
|
|
410
603
|
*/
|
|
@@ -424,11 +617,15 @@ var CredentialDetectionService = class {
|
|
|
424
617
|
}
|
|
425
618
|
const credentialVars = [];
|
|
426
619
|
for (const [name, value] of Object.entries(env)) {
|
|
620
|
+
if (this.isVariableSubstitution(value)) {
|
|
621
|
+
continue;
|
|
622
|
+
}
|
|
427
623
|
if (this.isPotentialCredential(name)) {
|
|
428
624
|
credentialVars.push({
|
|
429
625
|
name,
|
|
430
626
|
value: this.maskValue(value),
|
|
431
|
-
riskLevel: this.assessRiskLevel(name)
|
|
627
|
+
riskLevel: this.assessRiskLevel(name),
|
|
628
|
+
source: "env"
|
|
432
629
|
});
|
|
433
630
|
}
|
|
434
631
|
}
|
|
@@ -479,6 +676,92 @@ var CredentialDetectionService = class {
|
|
|
479
676
|
}
|
|
480
677
|
};
|
|
481
678
|
|
|
679
|
+
// src/services/directory-bubble-service.ts
|
|
680
|
+
import path2 from "path";
|
|
681
|
+
import fs2 from "fs/promises";
|
|
682
|
+
import { homedir } from "os";
|
|
683
|
+
var DirectoryBubbleService = class {
|
|
684
|
+
static {
|
|
685
|
+
__name(this, "DirectoryBubbleService");
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Find a local MCP config file by bubbling up the directory tree
|
|
689
|
+
* @param localPath - The relative path to search for (e.g., '.vscode/mcp.json')
|
|
690
|
+
* @param startDir - The directory to start searching from
|
|
691
|
+
* @returns The absolute path to the found config file, or null if not found
|
|
692
|
+
*/
|
|
693
|
+
async findLocalConfigInParentDirectories(localPath, startDir) {
|
|
694
|
+
try {
|
|
695
|
+
let currentDir = path2.resolve(startDir);
|
|
696
|
+
const homeDir = homedir();
|
|
697
|
+
const rootDir = "/";
|
|
698
|
+
let iterationCount = 0;
|
|
699
|
+
const maxIterations = 100;
|
|
700
|
+
const startDirResult = await this.checkDirectoryForConfig(currentDir, localPath);
|
|
701
|
+
if (startDirResult) {
|
|
702
|
+
return path2.join(currentDir, localPath);
|
|
703
|
+
}
|
|
704
|
+
while (currentDir !== homeDir && currentDir !== rootDir && iterationCount < maxIterations) {
|
|
705
|
+
const parentDir = this.getParentDirectory(currentDir);
|
|
706
|
+
if (!parentDir || parentDir === currentDir) {
|
|
707
|
+
break;
|
|
708
|
+
}
|
|
709
|
+
if (parentDir === currentDir || parentDir.length >= currentDir.length) {
|
|
710
|
+
break;
|
|
711
|
+
}
|
|
712
|
+
currentDir = parentDir;
|
|
713
|
+
iterationCount++;
|
|
714
|
+
const found = await this.checkDirectoryForConfig(currentDir, localPath);
|
|
715
|
+
if (found) {
|
|
716
|
+
return path2.join(currentDir, localPath);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return null;
|
|
720
|
+
} catch (error) {
|
|
721
|
+
return null;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* Check if a config file exists in the specified directory
|
|
726
|
+
* @param dir - The directory to check
|
|
727
|
+
* @param configPath - The relative path to the config file
|
|
728
|
+
* @returns True if the config file exists and is accessible
|
|
729
|
+
*/
|
|
730
|
+
async checkDirectoryForConfig(dir, configPath) {
|
|
731
|
+
try {
|
|
732
|
+
const fullPath = path2.join(dir, configPath);
|
|
733
|
+
await fs2.access(fullPath);
|
|
734
|
+
return true;
|
|
735
|
+
} catch (error) {
|
|
736
|
+
return false;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Get the parent directory of the specified directory
|
|
741
|
+
* @param dir - The directory to get the parent of
|
|
742
|
+
* @returns The parent directory path, or null if already at root
|
|
743
|
+
*/
|
|
744
|
+
getParentDirectory(dir) {
|
|
745
|
+
const parent = path2.dirname(dir);
|
|
746
|
+
return parent === dir ? null : parent;
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
// src/utils/url-utils.ts
|
|
751
|
+
function extractHostname(urlString) {
|
|
752
|
+
try {
|
|
753
|
+
let urlToParse = urlString;
|
|
754
|
+
if (!urlToParse.includes("://")) {
|
|
755
|
+
urlToParse = `http://${urlToParse}`;
|
|
756
|
+
}
|
|
757
|
+
const url = new URL(urlToParse);
|
|
758
|
+
return url.hostname;
|
|
759
|
+
} catch (error) {
|
|
760
|
+
return urlString;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
__name(extractHostname, "extractHostname");
|
|
764
|
+
|
|
482
765
|
// src/services/mcp-config-service.ts
|
|
483
766
|
var MCPConfigService = class {
|
|
484
767
|
static {
|
|
@@ -487,10 +770,14 @@ var MCPConfigService = class {
|
|
|
487
770
|
pathRegistry;
|
|
488
771
|
currentOS;
|
|
489
772
|
debug;
|
|
490
|
-
|
|
773
|
+
directoryBubbleService;
|
|
774
|
+
enableDirectoryBubbling;
|
|
775
|
+
constructor(options = {}) {
|
|
491
776
|
this.pathRegistry = new MCPPathRegistry();
|
|
492
777
|
this.currentOS = platform();
|
|
493
778
|
this.debug = util.debuglog("ls-mcp");
|
|
779
|
+
this.directoryBubbleService = new DirectoryBubbleService();
|
|
780
|
+
this.enableDirectoryBubbling = options.enableDirectoryBubbling ?? false;
|
|
494
781
|
}
|
|
495
782
|
/**
|
|
496
783
|
* Get MCP configuration files for a specific AI application on the current OS
|
|
@@ -575,7 +862,7 @@ var MCPConfigService = class {
|
|
|
575
862
|
*/
|
|
576
863
|
async validateConfigFile(filePath) {
|
|
577
864
|
try {
|
|
578
|
-
await
|
|
865
|
+
await fs3.access(filePath);
|
|
579
866
|
const parser = this.createParser(filePath);
|
|
580
867
|
return await parser.isValidSyntax();
|
|
581
868
|
} catch (error) {
|
|
@@ -605,14 +892,28 @@ var MCPConfigService = class {
|
|
|
605
892
|
const uniqueFilePaths = /* @__PURE__ */ new Set();
|
|
606
893
|
let totalServersCount = 0;
|
|
607
894
|
for (const filePathData of paths) {
|
|
608
|
-
|
|
609
|
-
|
|
895
|
+
let resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
896
|
+
let absolutePath = path3.resolve(resolvedPath);
|
|
897
|
+
if (filePathData.type === "local" && this.enableDirectoryBubbling) {
|
|
898
|
+
try {
|
|
899
|
+
await fs3.access(resolvedPath);
|
|
900
|
+
} catch (error) {
|
|
901
|
+
const bubbledPath = await this.directoryBubbleService.findLocalConfigInParentDirectories(
|
|
902
|
+
filePathData.filePath,
|
|
903
|
+
process.cwd()
|
|
904
|
+
);
|
|
905
|
+
if (bubbledPath) {
|
|
906
|
+
resolvedPath = bubbledPath;
|
|
907
|
+
absolutePath = path3.resolve(resolvedPath);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
610
911
|
if (uniqueFilePaths.has(absolutePath)) {
|
|
611
912
|
continue;
|
|
612
913
|
}
|
|
613
914
|
uniqueFilePaths.add(absolutePath);
|
|
614
915
|
try {
|
|
615
|
-
await
|
|
916
|
+
await fs3.access(resolvedPath);
|
|
616
917
|
const parser = this.createParser(resolvedPath);
|
|
617
918
|
const parsable = await parser.isValidSyntax();
|
|
618
919
|
filePathData.parsable = parsable;
|
|
@@ -666,6 +967,12 @@ var MCPConfigService = class {
|
|
|
666
967
|
const serverInfos = [];
|
|
667
968
|
for (const [serverName, serverConfig] of Object.entries(servers)) {
|
|
668
969
|
if (serverConfig && typeof serverConfig === "object") {
|
|
970
|
+
let source;
|
|
971
|
+
if (serverConfig.url) {
|
|
972
|
+
source = extractHostname(serverConfig.url);
|
|
973
|
+
} else {
|
|
974
|
+
source = serverConfig.command || "";
|
|
975
|
+
}
|
|
669
976
|
serverInfos.push({
|
|
670
977
|
name: serverName,
|
|
671
978
|
command: serverConfig.command || "",
|
|
@@ -673,11 +980,16 @@ var MCPConfigService = class {
|
|
|
673
980
|
transport: serverConfig.type === "streamable-http" ? "http" : serverConfig.type,
|
|
674
981
|
// Map streamable-http to http
|
|
675
982
|
type: serverConfig.type,
|
|
676
|
-
source
|
|
983
|
+
source,
|
|
677
984
|
env: serverConfig.env,
|
|
985
|
+
headers: serverConfig.headers,
|
|
678
986
|
status: "stopped",
|
|
679
987
|
// Default status, will be updated by server manager
|
|
680
|
-
credentials: CredentialDetectionService.
|
|
988
|
+
credentials: CredentialDetectionService.analyzeServerConfig({
|
|
989
|
+
env: serverConfig.env,
|
|
990
|
+
args: serverConfig.args,
|
|
991
|
+
headers: serverConfig.headers
|
|
992
|
+
})
|
|
681
993
|
});
|
|
682
994
|
}
|
|
683
995
|
}
|
|
@@ -705,7 +1017,7 @@ var MCPConfigService = class {
|
|
|
705
1017
|
};
|
|
706
1018
|
|
|
707
1019
|
// src/services/mcp-server-manager-service.ts
|
|
708
|
-
import
|
|
1020
|
+
import path4 from "path";
|
|
709
1021
|
import { execSync } from "child_process";
|
|
710
1022
|
import { platform as platform2 } from "os";
|
|
711
1023
|
var MCPServerManagerService = class {
|
|
@@ -734,7 +1046,7 @@ var MCPServerManagerService = class {
|
|
|
734
1046
|
this.transport = "stdio";
|
|
735
1047
|
}
|
|
736
1048
|
if (serverConfig.url) {
|
|
737
|
-
this.source = serverConfig.url;
|
|
1049
|
+
this.source = extractHostname(serverConfig.url);
|
|
738
1050
|
this.transport = "http";
|
|
739
1051
|
} else {
|
|
740
1052
|
const fullCommand = [serverConfig.command, ...serverConfig.args || []].join(" ");
|
|
@@ -915,9 +1227,9 @@ var MCPServerManagerService = class {
|
|
|
915
1227
|
return true;
|
|
916
1228
|
}
|
|
917
1229
|
getBaseCommand(fullCommandPath) {
|
|
918
|
-
let baseCommand =
|
|
1230
|
+
let baseCommand = path4.basename(fullCommandPath);
|
|
919
1231
|
if (platform2() === "win32") {
|
|
920
|
-
baseCommand =
|
|
1232
|
+
baseCommand = path4.basename(fullCommandPath, ".exe");
|
|
921
1233
|
}
|
|
922
1234
|
baseCommand = baseCommand.toLowerCase();
|
|
923
1235
|
return baseCommand;
|
|
@@ -1105,7 +1417,7 @@ var MCPFiles = class {
|
|
|
1105
1417
|
}
|
|
1106
1418
|
mcpConfigService;
|
|
1107
1419
|
constructor() {
|
|
1108
|
-
this.mcpConfigService = new MCPConfigService();
|
|
1420
|
+
this.mcpConfigService = new MCPConfigService({ enableDirectoryBubbling: true });
|
|
1109
1421
|
}
|
|
1110
1422
|
/**
|
|
1111
1423
|
* Find and process all MCP configuration files
|
package/package.json
CHANGED
|
@@ -28,10 +28,40 @@ export default function CredentialWarningComponent (credentials: CredentialAnaly
|
|
|
28
28
|
|
|
29
29
|
const riskText = styleText([riskColor], `${riskIcon} ${riskLevel.toUpperCase()} RISK`)
|
|
30
30
|
|
|
31
|
-
//
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
// Group credentials by source for better organization
|
|
32
|
+
const credsBySource = credentialVars.reduce((acc, cv) => {
|
|
33
|
+
const source = cv.source || 'env' // Default to env for backward compatibility
|
|
34
|
+
if (!acc[source]) {
|
|
35
|
+
acc[source] = []
|
|
36
|
+
}
|
|
37
|
+
acc[source].push(cv)
|
|
38
|
+
return acc
|
|
39
|
+
}, {} as Record<string, typeof credentialVars>)
|
|
35
40
|
|
|
36
|
-
|
|
41
|
+
// Create summary with source grouping
|
|
42
|
+
const sourceSummaries = Object.entries(credsBySource).map(([source, creds]) => {
|
|
43
|
+
const sourceIcon = getSourceIcon(source)
|
|
44
|
+
const credList = creds.map(cv => `${cv.name}=${cv.value}`).join(', ')
|
|
45
|
+
return `${sourceIcon}${source}: ${credList}`
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const credentialSummary = sourceSummaries.join(' | ')
|
|
49
|
+
|
|
50
|
+
return `${riskText} ${styleText(['dim'], `(${credentialVars.length} creds: ${credentialSummary})`)}`
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Get an icon/symbol for different credential sources
|
|
55
|
+
*/
|
|
56
|
+
function getSourceIcon (source: string): string {
|
|
57
|
+
switch (source) {
|
|
58
|
+
case 'env':
|
|
59
|
+
return '🌱 ' // Environment variable
|
|
60
|
+
case 'args':
|
|
61
|
+
return '⚡ ' // Command argument
|
|
62
|
+
case 'headers':
|
|
63
|
+
return '🔗 ' // HTTP header
|
|
64
|
+
default:
|
|
65
|
+
return '📋 ' // Unknown/generic
|
|
66
|
+
}
|
|
37
67
|
}
|
package/src/main.ts
CHANGED
|
@@ -6,7 +6,8 @@ export class MCPFiles {
|
|
|
6
6
|
private mcpConfigService: MCPConfigService
|
|
7
7
|
|
|
8
8
|
constructor () {
|
|
9
|
-
|
|
9
|
+
// Enable directory bubbling for better DX when running from nested directories
|
|
10
|
+
this.mcpConfigService = new MCPConfigService({ enableDirectoryBubbling: true })
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
/**
|