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/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
</h1>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
Detect
|
|
8
|
+
Detect Configured MCP (Model Context Protocol) in your local dev environment
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
@@ -22,6 +22,13 @@
|
|
|
22
22
|
<img src="https://github.com/lirantal/ls-mcp/blob/main/.github/ls-mcp-logo.png?raw=true" alt="ls-mcp logo"/>
|
|
23
23
|
</div>
|
|
24
24
|
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- **🔍 MCP Discovery**: Automatically detect MCP servers across various AI applications and agentic IDEs
|
|
28
|
+
- **📁 Directory Bubbling**: Intelligent discovery of project-scoped MCP configs from nested directories, supporting project-scoped MCP Server configuration and global configurations
|
|
29
|
+
- **🔄 Process Detection**: Real-time status of running MCP servers
|
|
30
|
+
- **🔒 Credential Analysis**: Security analysis of environment variables and API keys for potentially exposed credentials in MCP Servers
|
|
31
|
+
|
|
25
32
|
## Usage: CLI
|
|
26
33
|
|
|
27
34
|
```bash
|
|
@@ -40,9 +47,16 @@ NODE_DEBUG=ls-mcp npx ls-mcp
|
|
|
40
47
|
NODE_DEBUG=* npx ls-mcp
|
|
41
48
|
```
|
|
42
49
|
|
|
43
|
-
##
|
|
50
|
+
## Documentation
|
|
51
|
+
|
|
52
|
+
For detailed information about the project architecture and features:
|
|
44
53
|
|
|
45
|
-
|
|
54
|
+
- **[Project Overview](./docs/project.md)**: Comprehensive project analysis and architecture
|
|
55
|
+
- **[Design Documentation](./docs/design.md)**: Technical design decisions and implementation details
|
|
56
|
+
- **[Requirements](./docs/requirements.md)**: Functional and non-functional requirements
|
|
57
|
+
- **[Directory Bubbling](./docs/directory-bubbling.md)**: Intelligent directory traversal feature
|
|
58
|
+
- **[URL Hostname Extraction](./docs/url-hostname-extraction.md)**: Clean display of hostnames for URL-based servers
|
|
59
|
+
- **[Credential Detection](./docs/credential-detection.md)**: Security analysis features
|
|
46
60
|
|
|
47
61
|
## Author
|
|
48
62
|
|
package/dist/bin/cli.cjs
CHANGED
|
@@ -28,9 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var import_node_util12 = require("util");
|
|
29
29
|
|
|
30
30
|
// src/services/mcp-config-service.ts
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
31
|
+
var import_node_os2 = require("os");
|
|
32
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
33
|
+
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
34
34
|
var import_node_util = __toESM(require("util"), 1);
|
|
35
35
|
|
|
36
36
|
// src/services/mcp-path-registry.ts
|
|
@@ -128,6 +128,52 @@ var MCPPathRegistry = class _MCPPathRegistry {
|
|
|
128
128
|
{ filePath: import_node_path.default.join(".gemini", "settings.json"), type: "local" }
|
|
129
129
|
]
|
|
130
130
|
};
|
|
131
|
+
static LINUX_PATHS = {
|
|
132
|
+
claude: [
|
|
133
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Claude", "claude_desktop_config.json"), type: "global" }
|
|
134
|
+
],
|
|
135
|
+
claude_code: [
|
|
136
|
+
{ filePath: ".mcp.json", type: "local" }
|
|
137
|
+
],
|
|
138
|
+
cursor: [
|
|
139
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
|
|
140
|
+
{ filePath: import_node_path.default.join(".cursor", "mcp.json"), type: "local" }
|
|
141
|
+
],
|
|
142
|
+
vscode: [
|
|
143
|
+
{ filePath: import_node_path.default.join(".vscode", "mcp.json"), type: "local" },
|
|
144
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code", "User", "settings.json"), type: "global" },
|
|
145
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "settings.json"), type: "global" },
|
|
146
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code", "User", "mcp.json"), type: "global" },
|
|
147
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "mcp.json"), type: "global" },
|
|
148
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".mcp.json"), type: "global" }
|
|
149
|
+
],
|
|
150
|
+
cline: [
|
|
151
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
152
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
153
|
+
],
|
|
154
|
+
windsurf: [
|
|
155
|
+
{ filePath: import_node_path.default.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
|
|
156
|
+
],
|
|
157
|
+
roo: [
|
|
158
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
159
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
160
|
+
],
|
|
161
|
+
"intellij-github-copilot": [
|
|
162
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
|
|
163
|
+
],
|
|
164
|
+
junie: [
|
|
165
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".junie", "mcp.json"), type: "global" },
|
|
166
|
+
{ filePath: import_node_path.default.join(".junie", "mcp", "mcp.json"), type: "local" }
|
|
167
|
+
],
|
|
168
|
+
zed: [
|
|
169
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "zed", "settings.json"), type: "global" },
|
|
170
|
+
{ filePath: import_node_path.default.join(".zed", "settings.json"), type: "local" }
|
|
171
|
+
],
|
|
172
|
+
gemini: [
|
|
173
|
+
{ filePath: import_node_path.default.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
|
|
174
|
+
{ filePath: import_node_path.default.join(".gemini", "settings.json"), type: "local" }
|
|
175
|
+
]
|
|
176
|
+
};
|
|
131
177
|
customApps = /* @__PURE__ */ new Map();
|
|
132
178
|
/**
|
|
133
179
|
* Get all MCP configuration file paths for a specific operating system
|
|
@@ -140,6 +186,8 @@ var MCPPathRegistry = class _MCPPathRegistry {
|
|
|
140
186
|
case "darwin":
|
|
141
187
|
case "macos":
|
|
142
188
|
return { ..._MCPPathRegistry.DARWIN_PATHS };
|
|
189
|
+
case "linux":
|
|
190
|
+
return { ..._MCPPathRegistry.LINUX_PATHS };
|
|
143
191
|
default:
|
|
144
192
|
throw new Error(`Unsupported operating system: ${os}`);
|
|
145
193
|
}
|
|
@@ -166,7 +214,7 @@ var MCPPathRegistry = class _MCPPathRegistry {
|
|
|
166
214
|
* Get all supported operating systems
|
|
167
215
|
*/
|
|
168
216
|
getSupportedOperatingSystems() {
|
|
169
|
-
return ["win32", "darwin"];
|
|
217
|
+
return ["win32", "darwin", "linux"];
|
|
170
218
|
}
|
|
171
219
|
/**
|
|
172
220
|
* Register a custom app with custom paths for a specific OS
|
|
@@ -277,6 +325,7 @@ var MCPConfigParser = class {
|
|
|
277
325
|
command: serverConfig.command || "",
|
|
278
326
|
args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
|
|
279
327
|
type: this.validateType(serverConfig.type) ? serverConfig.type : this.inferTransportType(serverConfig),
|
|
328
|
+
url: serverConfig.url,
|
|
280
329
|
env
|
|
281
330
|
};
|
|
282
331
|
}
|
|
@@ -382,45 +431,17 @@ var CredentialDetectionService = class {
|
|
|
382
431
|
*/
|
|
383
432
|
static CREDENTIAL_PATTERNS = {
|
|
384
433
|
high: [
|
|
385
|
-
//
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
/access[_-]?token/i,
|
|
389
|
-
/secret[_-]?key/i,
|
|
390
|
-
/private[_-]?key/i,
|
|
391
|
-
// Authentication Tokens
|
|
392
|
-
/auth[_-]?token/i,
|
|
393
|
-
/bearer[_-]?token/i,
|
|
394
|
-
/jwt[_-]?token/i,
|
|
395
|
-
/oauth[_-]?token/i,
|
|
434
|
+
// Generic Key and Token patterns (broad matching)
|
|
435
|
+
/.*key.*/i,
|
|
436
|
+
/.*token.*/i,
|
|
396
437
|
// Passwords
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
// Credentials
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
/openai[_-]?api[_-]?key/i,
|
|
405
|
-
/anthropic[_-]?api[_-]?key/i,
|
|
406
|
-
/firecrawl[_-]?api[_-]?key/i,
|
|
407
|
-
/github[_-]?token/i,
|
|
408
|
-
/gitlab[_-]?token/i,
|
|
409
|
-
/bitbucket[_-]?token/i,
|
|
410
|
-
// Database passwords
|
|
411
|
-
/db[_-]?password/i,
|
|
412
|
-
/database[_-]?password/i,
|
|
413
|
-
/redis[_-]?password/i,
|
|
414
|
-
/postgres[_-]?password/i,
|
|
415
|
-
/mysql[_-]?password/i,
|
|
416
|
-
// Cloud services
|
|
417
|
-
/aws[_-]?secret[_-]?access[_-]?key/i,
|
|
418
|
-
/aws[_-]?access[_-]?key[_-]?id/i,
|
|
419
|
-
/azure[_-]?key/i,
|
|
420
|
-
/gcp[_-]?key/i,
|
|
421
|
-
/google[_-]?api[_-]?key/i,
|
|
422
|
-
/gemini[_-]?api[_-]?key/i,
|
|
423
|
-
/claude[_-]?api[_-]?key/i
|
|
438
|
+
/.*password.*/i,
|
|
439
|
+
/.*passwd.*/i,
|
|
440
|
+
/.*pwd.*/i,
|
|
441
|
+
// Credentials and Secrets
|
|
442
|
+
/.*credential.*/i,
|
|
443
|
+
/.*creds.*/i,
|
|
444
|
+
/.*secret.*/i
|
|
424
445
|
],
|
|
425
446
|
low: [
|
|
426
447
|
// Organization and Account IDs
|
|
@@ -431,6 +452,178 @@ var CredentialDetectionService = class {
|
|
|
431
452
|
/openai[_-]?org[_-]?id/i
|
|
432
453
|
]
|
|
433
454
|
};
|
|
455
|
+
/**
|
|
456
|
+
* Argument patterns for detecting credentials in command-line arguments
|
|
457
|
+
*/
|
|
458
|
+
static ARGUMENT_PATTERNS = {
|
|
459
|
+
high: [
|
|
460
|
+
// API key arguments
|
|
461
|
+
/--api-key/i,
|
|
462
|
+
/--apikey/i,
|
|
463
|
+
/--key/i,
|
|
464
|
+
// Token arguments
|
|
465
|
+
/--token/i,
|
|
466
|
+
/--access-token/i,
|
|
467
|
+
/--auth-token/i,
|
|
468
|
+
/--bearer-token/i,
|
|
469
|
+
// Password arguments
|
|
470
|
+
/--password/i,
|
|
471
|
+
/--passwd/i,
|
|
472
|
+
/--pwd/i,
|
|
473
|
+
// Secret arguments
|
|
474
|
+
/--secret/i,
|
|
475
|
+
/--client-secret/i,
|
|
476
|
+
// Authentication arguments
|
|
477
|
+
/--auth/i,
|
|
478
|
+
/--authorization/i,
|
|
479
|
+
/--credentials/i,
|
|
480
|
+
/--creds/i
|
|
481
|
+
],
|
|
482
|
+
low: [
|
|
483
|
+
// Organization and account IDs
|
|
484
|
+
/--org-id/i,
|
|
485
|
+
/--organization-id/i,
|
|
486
|
+
/--account-id/i,
|
|
487
|
+
/--user-id/i
|
|
488
|
+
]
|
|
489
|
+
};
|
|
490
|
+
/**
|
|
491
|
+
* Header patterns for detecting credentials in HTTP headers
|
|
492
|
+
*/
|
|
493
|
+
static HEADER_PATTERNS = {
|
|
494
|
+
high: [
|
|
495
|
+
// Authorization headers
|
|
496
|
+
/authorization/i,
|
|
497
|
+
/auth/i,
|
|
498
|
+
// API key headers
|
|
499
|
+
/x-api-key/i,
|
|
500
|
+
/api-key/i,
|
|
501
|
+
/apikey/i,
|
|
502
|
+
// Token headers
|
|
503
|
+
/x-access-token/i,
|
|
504
|
+
/access-token/i,
|
|
505
|
+
/bearer-token/i,
|
|
506
|
+
/x-auth-token/i,
|
|
507
|
+
/auth-token/i,
|
|
508
|
+
// Custom authentication headers
|
|
509
|
+
/x-.*-key/i,
|
|
510
|
+
/x-.*-token/i,
|
|
511
|
+
/x-.*-secret/i,
|
|
512
|
+
// Service-specific patterns
|
|
513
|
+
/x-github-token/i,
|
|
514
|
+
/x-openai-key/i,
|
|
515
|
+
/x-anthropic-key/i
|
|
516
|
+
],
|
|
517
|
+
low: [
|
|
518
|
+
// User identification headers
|
|
519
|
+
/x-user-id/i,
|
|
520
|
+
/x-org-id/i,
|
|
521
|
+
/x-organization-id/i,
|
|
522
|
+
/x-account-id/i
|
|
523
|
+
]
|
|
524
|
+
};
|
|
525
|
+
/**
|
|
526
|
+
* Variable substitution pattern to detect safe variable references
|
|
527
|
+
*/
|
|
528
|
+
static VARIABLE_SUBSTITUTION_PATTERN = /^\$\{[^}]+\}$/;
|
|
529
|
+
/**
|
|
530
|
+
* Check if a value is a variable substitution pattern (e.g., ${input:token})
|
|
531
|
+
*/
|
|
532
|
+
static isVariableSubstitution(value) {
|
|
533
|
+
return this.VARIABLE_SUBSTITUTION_PATTERN.test(value);
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Analyze command-line arguments for potential credentials
|
|
537
|
+
*/
|
|
538
|
+
static analyzeArguments(args) {
|
|
539
|
+
if (!args || !Array.isArray(args) || args.length === 0) {
|
|
540
|
+
return {
|
|
541
|
+
hasCredentials: false,
|
|
542
|
+
credentialVars: [],
|
|
543
|
+
riskLevel: "none"
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
const credentialVars = [];
|
|
547
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
548
|
+
const arg = args[i];
|
|
549
|
+
const nextArg = args[i + 1];
|
|
550
|
+
const isHighRiskArg = this.ARGUMENT_PATTERNS.high.some((pattern) => pattern.test(arg));
|
|
551
|
+
const isLowRiskArg = this.ARGUMENT_PATTERNS.low.some((pattern) => pattern.test(arg));
|
|
552
|
+
if (isHighRiskArg || isLowRiskArg) {
|
|
553
|
+
if (nextArg && !nextArg.startsWith("-")) {
|
|
554
|
+
credentialVars.push({
|
|
555
|
+
name: arg,
|
|
556
|
+
value: this.maskValue(nextArg),
|
|
557
|
+
riskLevel: isHighRiskArg ? "high" : "low",
|
|
558
|
+
source: "args"
|
|
559
|
+
});
|
|
560
|
+
i++;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
const hasCredentials = credentialVars.length > 0;
|
|
565
|
+
const riskLevel = this.calculateOverallRiskLevel(credentialVars);
|
|
566
|
+
return {
|
|
567
|
+
hasCredentials,
|
|
568
|
+
credentialVars,
|
|
569
|
+
riskLevel
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Analyze HTTP headers for potential credentials
|
|
574
|
+
*/
|
|
575
|
+
static analyzeHeaders(headers) {
|
|
576
|
+
if (!headers || typeof headers !== "object") {
|
|
577
|
+
return {
|
|
578
|
+
hasCredentials: false,
|
|
579
|
+
credentialVars: [],
|
|
580
|
+
riskLevel: "none"
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
const credentialVars = [];
|
|
584
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
585
|
+
if (this.isVariableSubstitution(value)) {
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
588
|
+
const isHighRiskHeader = this.HEADER_PATTERNS.high.some((pattern) => pattern.test(name));
|
|
589
|
+
const isLowRiskHeader = this.HEADER_PATTERNS.low.some((pattern) => pattern.test(name));
|
|
590
|
+
if (isHighRiskHeader || isLowRiskHeader) {
|
|
591
|
+
credentialVars.push({
|
|
592
|
+
name,
|
|
593
|
+
value: this.maskValue(value),
|
|
594
|
+
riskLevel: isHighRiskHeader ? "high" : "low",
|
|
595
|
+
source: "headers"
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
const hasCredentials = credentialVars.length > 0;
|
|
600
|
+
const riskLevel = this.calculateOverallRiskLevel(credentialVars);
|
|
601
|
+
return {
|
|
602
|
+
hasCredentials,
|
|
603
|
+
credentialVars,
|
|
604
|
+
riskLevel
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Comprehensive analysis of server configuration for credentials
|
|
609
|
+
*/
|
|
610
|
+
static analyzeServerConfig(config) {
|
|
611
|
+
const envResult = this.analyzeEnvironmentVariables(config.env);
|
|
612
|
+
const argsResult = this.analyzeArguments(config.args);
|
|
613
|
+
const headersResult = this.analyzeHeaders(config.headers);
|
|
614
|
+
const allCredentialVars = [
|
|
615
|
+
...envResult.credentialVars,
|
|
616
|
+
...argsResult.credentialVars,
|
|
617
|
+
...headersResult.credentialVars
|
|
618
|
+
];
|
|
619
|
+
const hasCredentials = allCredentialVars.length > 0;
|
|
620
|
+
const riskLevel = this.calculateOverallRiskLevel(allCredentialVars);
|
|
621
|
+
return {
|
|
622
|
+
hasCredentials,
|
|
623
|
+
credentialVars: allCredentialVars,
|
|
624
|
+
riskLevel
|
|
625
|
+
};
|
|
626
|
+
}
|
|
434
627
|
/**
|
|
435
628
|
* Check if an environment variable name suggests it might contain credentials
|
|
436
629
|
*/
|
|
@@ -450,11 +643,15 @@ var CredentialDetectionService = class {
|
|
|
450
643
|
}
|
|
451
644
|
const credentialVars = [];
|
|
452
645
|
for (const [name, value] of Object.entries(env)) {
|
|
646
|
+
if (this.isVariableSubstitution(value)) {
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
453
649
|
if (this.isPotentialCredential(name)) {
|
|
454
650
|
credentialVars.push({
|
|
455
651
|
name,
|
|
456
652
|
value: this.maskValue(value),
|
|
457
|
-
riskLevel: this.assessRiskLevel(name)
|
|
653
|
+
riskLevel: this.assessRiskLevel(name),
|
|
654
|
+
source: "env"
|
|
458
655
|
});
|
|
459
656
|
}
|
|
460
657
|
}
|
|
@@ -505,6 +702,92 @@ var CredentialDetectionService = class {
|
|
|
505
702
|
}
|
|
506
703
|
};
|
|
507
704
|
|
|
705
|
+
// src/services/directory-bubble-service.ts
|
|
706
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
707
|
+
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
708
|
+
var import_node_os = require("os");
|
|
709
|
+
var DirectoryBubbleService = class {
|
|
710
|
+
static {
|
|
711
|
+
__name(this, "DirectoryBubbleService");
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Find a local MCP config file by bubbling up the directory tree
|
|
715
|
+
* @param localPath - The relative path to search for (e.g., '.vscode/mcp.json')
|
|
716
|
+
* @param startDir - The directory to start searching from
|
|
717
|
+
* @returns The absolute path to the found config file, or null if not found
|
|
718
|
+
*/
|
|
719
|
+
async findLocalConfigInParentDirectories(localPath, startDir) {
|
|
720
|
+
try {
|
|
721
|
+
let currentDir = import_node_path2.default.resolve(startDir);
|
|
722
|
+
const homeDir = (0, import_node_os.homedir)();
|
|
723
|
+
const rootDir = "/";
|
|
724
|
+
let iterationCount = 0;
|
|
725
|
+
const maxIterations = 100;
|
|
726
|
+
const startDirResult = await this.checkDirectoryForConfig(currentDir, localPath);
|
|
727
|
+
if (startDirResult) {
|
|
728
|
+
return import_node_path2.default.join(currentDir, localPath);
|
|
729
|
+
}
|
|
730
|
+
while (currentDir !== homeDir && currentDir !== rootDir && iterationCount < maxIterations) {
|
|
731
|
+
const parentDir = this.getParentDirectory(currentDir);
|
|
732
|
+
if (!parentDir || parentDir === currentDir) {
|
|
733
|
+
break;
|
|
734
|
+
}
|
|
735
|
+
if (parentDir === currentDir || parentDir.length >= currentDir.length) {
|
|
736
|
+
break;
|
|
737
|
+
}
|
|
738
|
+
currentDir = parentDir;
|
|
739
|
+
iterationCount++;
|
|
740
|
+
const found = await this.checkDirectoryForConfig(currentDir, localPath);
|
|
741
|
+
if (found) {
|
|
742
|
+
return import_node_path2.default.join(currentDir, localPath);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
return null;
|
|
746
|
+
} catch (error) {
|
|
747
|
+
return null;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Check if a config file exists in the specified directory
|
|
752
|
+
* @param dir - The directory to check
|
|
753
|
+
* @param configPath - The relative path to the config file
|
|
754
|
+
* @returns True if the config file exists and is accessible
|
|
755
|
+
*/
|
|
756
|
+
async checkDirectoryForConfig(dir, configPath) {
|
|
757
|
+
try {
|
|
758
|
+
const fullPath = import_node_path2.default.join(dir, configPath);
|
|
759
|
+
await import_promises2.default.access(fullPath);
|
|
760
|
+
return true;
|
|
761
|
+
} catch (error) {
|
|
762
|
+
return false;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Get the parent directory of the specified directory
|
|
767
|
+
* @param dir - The directory to get the parent of
|
|
768
|
+
* @returns The parent directory path, or null if already at root
|
|
769
|
+
*/
|
|
770
|
+
getParentDirectory(dir) {
|
|
771
|
+
const parent = import_node_path2.default.dirname(dir);
|
|
772
|
+
return parent === dir ? null : parent;
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
|
|
776
|
+
// src/utils/url-utils.ts
|
|
777
|
+
function extractHostname(urlString) {
|
|
778
|
+
try {
|
|
779
|
+
let urlToParse = urlString;
|
|
780
|
+
if (!urlToParse.includes("://")) {
|
|
781
|
+
urlToParse = `http://${urlToParse}`;
|
|
782
|
+
}
|
|
783
|
+
const url = new URL(urlToParse);
|
|
784
|
+
return url.hostname;
|
|
785
|
+
} catch (error) {
|
|
786
|
+
return urlString;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
__name(extractHostname, "extractHostname");
|
|
790
|
+
|
|
508
791
|
// src/services/mcp-config-service.ts
|
|
509
792
|
var MCPConfigService = class {
|
|
510
793
|
static {
|
|
@@ -513,10 +796,14 @@ var MCPConfigService = class {
|
|
|
513
796
|
pathRegistry;
|
|
514
797
|
currentOS;
|
|
515
798
|
debug;
|
|
516
|
-
|
|
799
|
+
directoryBubbleService;
|
|
800
|
+
enableDirectoryBubbling;
|
|
801
|
+
constructor(options = {}) {
|
|
517
802
|
this.pathRegistry = new MCPPathRegistry();
|
|
518
|
-
this.currentOS = (0,
|
|
803
|
+
this.currentOS = (0, import_node_os2.platform)();
|
|
519
804
|
this.debug = import_node_util.default.debuglog("ls-mcp");
|
|
805
|
+
this.directoryBubbleService = new DirectoryBubbleService();
|
|
806
|
+
this.enableDirectoryBubbling = options.enableDirectoryBubbling ?? false;
|
|
520
807
|
}
|
|
521
808
|
/**
|
|
522
809
|
* Get MCP configuration files for a specific AI application on the current OS
|
|
@@ -601,7 +888,7 @@ var MCPConfigService = class {
|
|
|
601
888
|
*/
|
|
602
889
|
async validateConfigFile(filePath) {
|
|
603
890
|
try {
|
|
604
|
-
await
|
|
891
|
+
await import_promises3.default.access(filePath);
|
|
605
892
|
const parser = this.createParser(filePath);
|
|
606
893
|
return await parser.isValidSyntax();
|
|
607
894
|
} catch (error) {
|
|
@@ -631,14 +918,28 @@ var MCPConfigService = class {
|
|
|
631
918
|
const uniqueFilePaths = /* @__PURE__ */ new Set();
|
|
632
919
|
let totalServersCount = 0;
|
|
633
920
|
for (const filePathData of paths) {
|
|
634
|
-
|
|
635
|
-
|
|
921
|
+
let resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
922
|
+
let absolutePath = import_node_path3.default.resolve(resolvedPath);
|
|
923
|
+
if (filePathData.type === "local" && this.enableDirectoryBubbling) {
|
|
924
|
+
try {
|
|
925
|
+
await import_promises3.default.access(resolvedPath);
|
|
926
|
+
} catch (error) {
|
|
927
|
+
const bubbledPath = await this.directoryBubbleService.findLocalConfigInParentDirectories(
|
|
928
|
+
filePathData.filePath,
|
|
929
|
+
process.cwd()
|
|
930
|
+
);
|
|
931
|
+
if (bubbledPath) {
|
|
932
|
+
resolvedPath = bubbledPath;
|
|
933
|
+
absolutePath = import_node_path3.default.resolve(resolvedPath);
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
}
|
|
636
937
|
if (uniqueFilePaths.has(absolutePath)) {
|
|
637
938
|
continue;
|
|
638
939
|
}
|
|
639
940
|
uniqueFilePaths.add(absolutePath);
|
|
640
941
|
try {
|
|
641
|
-
await
|
|
942
|
+
await import_promises3.default.access(resolvedPath);
|
|
642
943
|
const parser = this.createParser(resolvedPath);
|
|
643
944
|
const parsable = await parser.isValidSyntax();
|
|
644
945
|
filePathData.parsable = parsable;
|
|
@@ -692,6 +993,12 @@ var MCPConfigService = class {
|
|
|
692
993
|
const serverInfos = [];
|
|
693
994
|
for (const [serverName, serverConfig] of Object.entries(servers)) {
|
|
694
995
|
if (serverConfig && typeof serverConfig === "object") {
|
|
996
|
+
let source;
|
|
997
|
+
if (serverConfig.url) {
|
|
998
|
+
source = extractHostname(serverConfig.url);
|
|
999
|
+
} else {
|
|
1000
|
+
source = serverConfig.command || "";
|
|
1001
|
+
}
|
|
695
1002
|
serverInfos.push({
|
|
696
1003
|
name: serverName,
|
|
697
1004
|
command: serverConfig.command || "",
|
|
@@ -699,11 +1006,16 @@ var MCPConfigService = class {
|
|
|
699
1006
|
transport: serverConfig.type === "streamable-http" ? "http" : serverConfig.type,
|
|
700
1007
|
// Map streamable-http to http
|
|
701
1008
|
type: serverConfig.type,
|
|
702
|
-
source
|
|
1009
|
+
source,
|
|
703
1010
|
env: serverConfig.env,
|
|
1011
|
+
headers: serverConfig.headers,
|
|
704
1012
|
status: "stopped",
|
|
705
1013
|
// Default status, will be updated by server manager
|
|
706
|
-
credentials: CredentialDetectionService.
|
|
1014
|
+
credentials: CredentialDetectionService.analyzeServerConfig({
|
|
1015
|
+
env: serverConfig.env,
|
|
1016
|
+
args: serverConfig.args,
|
|
1017
|
+
headers: serverConfig.headers
|
|
1018
|
+
})
|
|
707
1019
|
});
|
|
708
1020
|
}
|
|
709
1021
|
}
|
|
@@ -731,9 +1043,9 @@ var MCPConfigService = class {
|
|
|
731
1043
|
};
|
|
732
1044
|
|
|
733
1045
|
// src/services/mcp-server-manager-service.ts
|
|
734
|
-
var
|
|
1046
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
735
1047
|
var import_node_child_process = require("child_process");
|
|
736
|
-
var
|
|
1048
|
+
var import_node_os3 = require("os");
|
|
737
1049
|
var MCPServerManagerService = class {
|
|
738
1050
|
static {
|
|
739
1051
|
__name(this, "MCPServerManagerService");
|
|
@@ -760,7 +1072,7 @@ var MCPServerManagerService = class {
|
|
|
760
1072
|
this.transport = "stdio";
|
|
761
1073
|
}
|
|
762
1074
|
if (serverConfig.url) {
|
|
763
|
-
this.source = serverConfig.url;
|
|
1075
|
+
this.source = extractHostname(serverConfig.url);
|
|
764
1076
|
this.transport = "http";
|
|
765
1077
|
} else {
|
|
766
1078
|
const fullCommand = [serverConfig.command, ...serverConfig.args || []].join(" ");
|
|
@@ -789,7 +1101,7 @@ var MCPServerManagerService = class {
|
|
|
789
1101
|
isRunning() {
|
|
790
1102
|
try {
|
|
791
1103
|
let psOutput;
|
|
792
|
-
if ((0,
|
|
1104
|
+
if ((0, import_node_os3.platform)() === "win32") {
|
|
793
1105
|
psOutput = (0, import_node_child_process.execSync)('powershell -Command "Get-CimInstance -ClassName Win32_Process | Select-Object ProcessId,Name,CommandLine,ParentProcessId | ConvertTo-Csv -NoTypeInformation"', {
|
|
794
1106
|
encoding: "utf8",
|
|
795
1107
|
timeout: 5e3
|
|
@@ -807,7 +1119,7 @@ var MCPServerManagerService = class {
|
|
|
807
1119
|
let pid;
|
|
808
1120
|
let ppid;
|
|
809
1121
|
let commandLine;
|
|
810
|
-
if ((0,
|
|
1122
|
+
if ((0, import_node_os3.platform)() === "win32") {
|
|
811
1123
|
if (processLine.startsWith('"ProcessId"') || processLine.startsWith("ProcessId")) continue;
|
|
812
1124
|
const parts = this.parseCSVLine(processLine);
|
|
813
1125
|
if (parts.length < 4) continue;
|
|
@@ -830,7 +1142,7 @@ var MCPServerManagerService = class {
|
|
|
830
1142
|
for (const [pid, processData] of processMap) {
|
|
831
1143
|
const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid);
|
|
832
1144
|
let commandMatchWin32 = false;
|
|
833
|
-
if ((0,
|
|
1145
|
+
if ((0, import_node_os3.platform)() === "win32") {
|
|
834
1146
|
let commandTokensOnWin32 = processData.commandTokens;
|
|
835
1147
|
if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith("cmd")) {
|
|
836
1148
|
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
@@ -941,9 +1253,9 @@ var MCPServerManagerService = class {
|
|
|
941
1253
|
return true;
|
|
942
1254
|
}
|
|
943
1255
|
getBaseCommand(fullCommandPath) {
|
|
944
|
-
let baseCommand =
|
|
945
|
-
if ((0,
|
|
946
|
-
baseCommand =
|
|
1256
|
+
let baseCommand = import_node_path4.default.basename(fullCommandPath);
|
|
1257
|
+
if ((0, import_node_os3.platform)() === "win32") {
|
|
1258
|
+
baseCommand = import_node_path4.default.basename(fullCommandPath, ".exe");
|
|
947
1259
|
}
|
|
948
1260
|
baseCommand = baseCommand.toLowerCase();
|
|
949
1261
|
return baseCommand;
|
|
@@ -1131,7 +1443,7 @@ var MCPFiles = class {
|
|
|
1131
1443
|
}
|
|
1132
1444
|
mcpConfigService;
|
|
1133
1445
|
constructor() {
|
|
1134
|
-
this.mcpConfigService = new MCPConfigService();
|
|
1446
|
+
this.mcpConfigService = new MCPConfigService({ enableDirectoryBubbling: true });
|
|
1135
1447
|
}
|
|
1136
1448
|
/**
|
|
1137
1449
|
* Find and process all MCP configuration files
|
|
@@ -1286,10 +1598,39 @@ function CredentialWarningComponent(credentials) {
|
|
|
1286
1598
|
riskIcon = (0, import_node_util9.styleText)(["blue"], "\u25CF");
|
|
1287
1599
|
}
|
|
1288
1600
|
const riskText = (0, import_node_util9.styleText)([riskColor], `${riskIcon} ${riskLevel.toUpperCase()} RISK`);
|
|
1289
|
-
const
|
|
1290
|
-
|
|
1601
|
+
const credsBySource = credentialVars.reduce((acc, cv) => {
|
|
1602
|
+
const source = cv.source || "env";
|
|
1603
|
+
if (!acc[source]) {
|
|
1604
|
+
acc[source] = [];
|
|
1605
|
+
}
|
|
1606
|
+
acc[source].push(cv);
|
|
1607
|
+
return acc;
|
|
1608
|
+
}, {});
|
|
1609
|
+
const sourceSummaries = Object.entries(credsBySource).map(([source, creds]) => {
|
|
1610
|
+
const sourceIcon = getSourceIcon(source);
|
|
1611
|
+
const credList = creds.map((cv) => `${cv.name}=${cv.value}`).join(", ");
|
|
1612
|
+
return `${sourceIcon}${source}: ${credList}`;
|
|
1613
|
+
});
|
|
1614
|
+
const credentialSummary = sourceSummaries.join(" | ");
|
|
1615
|
+
return `${riskText} ${(0, import_node_util9.styleText)(["dim"], `(${credentialVars.length} creds: ${credentialSummary})`)}`;
|
|
1291
1616
|
}
|
|
1292
1617
|
__name(CredentialWarningComponent, "CredentialWarningComponent");
|
|
1618
|
+
function getSourceIcon(source) {
|
|
1619
|
+
switch (source) {
|
|
1620
|
+
case "env":
|
|
1621
|
+
return "\u{1F331} ";
|
|
1622
|
+
// Environment variable
|
|
1623
|
+
case "args":
|
|
1624
|
+
return "\u26A1 ";
|
|
1625
|
+
// Command argument
|
|
1626
|
+
case "headers":
|
|
1627
|
+
return "\u{1F517} ";
|
|
1628
|
+
// HTTP header
|
|
1629
|
+
default:
|
|
1630
|
+
return "\u{1F4CB} ";
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
__name(getSourceIcon, "getSourceIcon");
|
|
1293
1634
|
|
|
1294
1635
|
// src/components/summary.ts
|
|
1295
1636
|
var import_node_util10 = require("util");
|