ls-mcp 1.9.1 → 1.11.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/dist/bin/cli.mjs CHANGED
@@ -3,19 +3,175 @@ var __defProp = Object.defineProperty;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
4
 
5
5
  // src/bin/cli.ts
6
- import { styleText as styleText9 } from "util";
6
+ import { styleText as styleText11 } from "util";
7
7
 
8
- // src/main.ts
9
- import fs2 from "fs/promises";
10
- import { platform as platform2 } from "os";
8
+ // src/services/mcp-config-service.ts
9
+ import { platform } from "os";
11
10
  import path3 from "path";
11
+ import fs3 from "fs/promises";
12
+ import util from "util";
12
13
 
13
- // src/services/mcp-config-linter-service.ts
14
+ // src/services/mcp-path-registry.ts
15
+ import path from "path";
16
+ var MCPPathRegistry = class _MCPPathRegistry {
17
+ static {
18
+ __name(this, "MCPPathRegistry");
19
+ }
20
+ static WINDOWS_PATHS = {
21
+ claude: [
22
+ { filePath: path.join(process.env.APPDATA || "", "Claude", "claude_desktop_config.json"), type: "global" }
23
+ ],
24
+ claude_code: [
25
+ { filePath: ".mcp.json", type: "local" }
26
+ ],
27
+ cursor: [
28
+ { filePath: path.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
29
+ { filePath: path.join(".cursor", "mcp.json"), type: "local" }
30
+ ],
31
+ vscode: [
32
+ { filePath: path.join(".vscode", "mcp.json"), type: "local" },
33
+ { filePath: path.join(process.env.APPDATA || "", "Code", "User", "settings.json"), type: "global" },
34
+ { filePath: path.join(process.env.APPDATA || "", "Code - Insiders", "User", "settings.json"), type: "global" },
35
+ { filePath: path.join(process.env.APPDATA || "", "Code", "User", "mcp.json"), type: "global" },
36
+ { filePath: path.join(process.env.APPDATA || "", "Code - Insiders", "User", "mcp.json"), type: "global" }
37
+ ],
38
+ cline: [
39
+ { filePath: path.join(process.env.APPDATA || "", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
40
+ { filePath: path.join(process.env.APPDATA || "", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
41
+ ],
42
+ windsurf: [
43
+ { filePath: path.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
44
+ ],
45
+ roo: [
46
+ { filePath: path.join(process.env.APPDATA || "", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
47
+ { filePath: path.join(process.env.APPDATA || "", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
48
+ ],
49
+ "intellij-github-copilot": [
50
+ { filePath: path.join(process.env.LOCALAPPDATA || "", "github-copilot", "intellij", "mcp.json"), type: "global" }
51
+ ],
52
+ junie: [
53
+ { filePath: path.join(process.env.HOME || "", ".junie", "mcp", "mcp.json"), type: "global" }
54
+ ],
55
+ zed: [
56
+ { filePath: path.join(process.env.LOCALAPPDATA || "", "zed", "settings.json"), type: "global" },
57
+ { filePath: path.join(".zed", "settings.json"), type: "local" }
58
+ ],
59
+ gemini: [
60
+ { filePath: path.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
61
+ { filePath: path.join(".gemini", "settings.json"), type: "local" }
62
+ ]
63
+ };
64
+ static DARWIN_PATHS = {
65
+ claude: [
66
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Claude", "claude_desktop_config.json"), type: "global" }
67
+ ],
68
+ claude_code: [
69
+ { filePath: ".mcp.json", type: "local" }
70
+ ],
71
+ cursor: [
72
+ { filePath: path.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
73
+ { filePath: path.join(".cursor", "mcp.json"), type: "local" }
74
+ ],
75
+ vscode: [
76
+ { filePath: path.join(".vscode", "mcp.json"), type: "local" },
77
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "settings.json"), type: "global" },
78
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "mcp.json"), type: "global" },
79
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "settings.json"), type: "global" },
80
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "mcp.json"), type: "global" }
81
+ ],
82
+ cline: [
83
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
84
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
85
+ ],
86
+ windsurf: [
87
+ { filePath: path.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
88
+ ],
89
+ roo: [
90
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
91
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
92
+ ],
93
+ "intellij-github-copilot": [
94
+ { filePath: path.join(process.env.HOME || "", ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
95
+ ],
96
+ junie: [
97
+ { filePath: path.join(process.env.HOME || "", ".junie", "mcp", "mcp.json"), type: "global" },
98
+ { filePath: path.join(".junie", "mcp", "mcp.json"), type: "local" }
99
+ ],
100
+ zed: [
101
+ { filePath: path.join(process.env.HOME || "", ".config", "zed", "settings.json"), type: "global" },
102
+ { filePath: path.join(".zed", "settings.json"), type: "local" }
103
+ ],
104
+ gemini: [
105
+ { filePath: path.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
106
+ { filePath: path.join(".gemini", "settings.json"), type: "local" }
107
+ ]
108
+ };
109
+ customApps = /* @__PURE__ */ new Map();
110
+ /**
111
+ * Get all MCP configuration file paths for a specific operating system
112
+ */
113
+ getPathsForOS(os) {
114
+ switch (os.toLowerCase()) {
115
+ case "win32":
116
+ case "windows":
117
+ return { ..._MCPPathRegistry.WINDOWS_PATHS };
118
+ case "darwin":
119
+ case "macos":
120
+ return { ..._MCPPathRegistry.DARWIN_PATHS };
121
+ default:
122
+ throw new Error(`Unsupported operating system: ${os}`);
123
+ }
124
+ }
125
+ /**
126
+ * Get MCP configuration file paths for a specific app on a specific OS
127
+ */
128
+ getPathsForApp(os, appName) {
129
+ const osPaths = this.getPathsForOS(os);
130
+ const appPaths = osPaths[appName];
131
+ if (!appPaths) {
132
+ throw new Error(`App '${appName}' not found for OS '${os}'`);
133
+ }
134
+ return [...appPaths];
135
+ }
136
+ /**
137
+ * Get all supported app names for a specific OS
138
+ */
139
+ getSupportedApps(os) {
140
+ const osPaths = this.getPathsForOS(os);
141
+ return Object.keys(osPaths);
142
+ }
143
+ /**
144
+ * Get all supported operating systems
145
+ */
146
+ getSupportedOperatingSystems() {
147
+ return ["win32", "darwin"];
148
+ }
149
+ /**
150
+ * Register a custom app with custom paths for a specific OS
151
+ */
152
+ registerCustomApp(os, appName, paths) {
153
+ if (!this.customApps.has(os)) {
154
+ this.customApps.set(os, {});
155
+ }
156
+ const osCustomApps = this.customApps.get(os);
157
+ osCustomApps[appName] = [...paths];
158
+ }
159
+ /**
160
+ * Get paths including custom registered apps
161
+ */
162
+ getPathsForOSWithCustom(os) {
163
+ const basePaths = this.getPathsForOS(os);
164
+ const customPaths = this.customApps.get(os) || {};
165
+ return { ...basePaths, ...customPaths };
166
+ }
167
+ };
168
+
169
+ // src/services/mcp-config-parser.ts
14
170
  import fs from "fs/promises";
15
171
  import { parse } from "jsonc-parser";
16
- var MCPConfigLinterService = class {
172
+ var MCPConfigParser = class {
17
173
  static {
18
- __name(this, "MCPConfigLinterService");
174
+ __name(this, "MCPConfigParser");
19
175
  }
20
176
  filePath;
21
177
  fileContents = null;
@@ -25,9 +181,17 @@ var MCPConfigLinterService = class {
25
181
  constructor(filePath) {
26
182
  this.filePath = filePath;
27
183
  }
28
- async parseFile() {
184
+ /**
185
+ * Parse the configuration file and return structured data
186
+ */
187
+ async parseConfigFile() {
29
188
  if (this.parsed) {
30
- return;
189
+ return {
190
+ raw: this.fileContentsData,
191
+ parsed: this.parsed,
192
+ valid: this.valid,
193
+ servers: await this.extractMCPServers(this.fileContentsData)
194
+ };
31
195
  }
32
196
  this.parsed = true;
33
197
  const fileContent = await this.getFileContent();
@@ -35,63 +199,630 @@ var MCPConfigLinterService = class {
35
199
  this.fileContentsData = JSON.parse(fileContent);
36
200
  if (typeof this.fileContentsData === "object") {
37
201
  this.valid = true;
38
- return;
39
202
  }
40
203
  } catch (e) {
41
204
  }
42
- try {
43
- this.fileContentsData = parse(fileContent);
44
- if (typeof this.fileContentsData === "object") {
45
- this.valid = true;
205
+ if (!this.valid) {
206
+ try {
207
+ this.fileContentsData = parse(fileContent);
208
+ if (typeof this.fileContentsData === "object") {
209
+ this.valid = true;
210
+ }
211
+ } catch (error) {
46
212
  }
47
- } catch (error) {
48
213
  }
214
+ if (!this.valid) {
215
+ throw new Error(`Failed to parse configuration file: ${this.filePath}`);
216
+ }
217
+ return {
218
+ raw: this.fileContentsData,
219
+ parsed: this.parsed,
220
+ valid: this.valid,
221
+ servers: await this.extractMCPServers(this.fileContentsData)
222
+ };
223
+ }
224
+ /**
225
+ * Extract MCP servers from parsed configuration data
226
+ */
227
+ async extractMCPServers(configData) {
228
+ if (!configData || typeof configData !== "object") {
229
+ return {};
230
+ }
231
+ if (configData.servers && typeof configData.servers === "object") {
232
+ return this.normalizeServerConfigs(configData.servers);
233
+ }
234
+ if (configData.mcp?.servers && typeof configData.mcp.servers === "object") {
235
+ return this.normalizeServerConfigs(configData.mcp.servers);
236
+ }
237
+ if (configData.mcpServers && typeof configData.mcpServers === "object") {
238
+ return this.normalizeServerConfigs(configData.mcpServers);
239
+ }
240
+ if (configData.context_servers && typeof configData.context_servers === "object") {
241
+ return this.normalizeServerConfigs(configData.context_servers);
242
+ }
243
+ return {};
244
+ }
245
+ /**
246
+ * Normalize server configurations to ensure consistent structure
247
+ */
248
+ normalizeServerConfigs(servers) {
249
+ const normalized = {};
250
+ for (const [serverName, serverConfig] of Object.entries(servers)) {
251
+ if (serverConfig && typeof serverConfig === "object") {
252
+ const env = serverConfig.env && typeof serverConfig.env === "object" ? serverConfig.env : void 0;
253
+ normalized[serverName] = {
254
+ name: serverName,
255
+ command: serverConfig.command || "",
256
+ args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
257
+ type: this.validateType(serverConfig.type) ? serverConfig.type : this.inferTransportType(serverConfig),
258
+ url: serverConfig.url,
259
+ env
260
+ };
261
+ }
262
+ }
263
+ return normalized;
264
+ }
265
+ /**
266
+ * Validate type value
267
+ */
268
+ validateType(type) {
269
+ return ["sse", "http", "stdio", "streamable-http"].includes(type);
270
+ }
271
+ /**
272
+ * Infer transport type from server configuration when type field is not explicitly set
273
+ */
274
+ inferTransportType(serverConfig) {
275
+ if (serverConfig.url && typeof serverConfig.url === "string") {
276
+ return "http";
277
+ }
278
+ if (Array.isArray(serverConfig.args)) {
279
+ const argsString = serverConfig.args.join(" ").toLowerCase();
280
+ if (argsString.includes("stdio")) {
281
+ return "stdio";
282
+ }
283
+ if (argsString.includes("http")) {
284
+ return "http";
285
+ }
286
+ if (argsString.includes("sse")) {
287
+ return "sse";
288
+ }
289
+ }
290
+ if (serverConfig.command && typeof serverConfig.command === "string") {
291
+ return "stdio";
292
+ }
293
+ return void 0;
294
+ }
295
+ /**
296
+ * Validate server configuration
297
+ */
298
+ validateServerConfig(serverConfig) {
299
+ if (!serverConfig || typeof serverConfig !== "object") {
300
+ return false;
301
+ }
302
+ if (!serverConfig.name || typeof serverConfig.name !== "string") {
303
+ return false;
304
+ }
305
+ if (!serverConfig.command || typeof serverConfig.command !== "string") {
306
+ return false;
307
+ }
308
+ return true;
49
309
  }
310
+ /**
311
+ * Get supported configuration keys that the parser recognizes
312
+ */
313
+ getSupportedConfigKeys() {
314
+ return ["servers", "mcp.servers", "mcpServers", "context_servers"];
315
+ }
316
+ /**
317
+ * Check if the configuration file has valid syntax
318
+ */
50
319
  async isValidSyntax() {
51
320
  try {
52
- await this.parseFile();
53
- return this.valid;
321
+ const configData = await this.parseConfigFile();
322
+ return configData.valid;
54
323
  } catch (error) {
55
324
  return false;
56
325
  }
57
326
  }
327
+ /**
328
+ * Count the number of MCP servers in the configuration
329
+ */
58
330
  async countMCPServers() {
59
331
  try {
60
- const mcpServers = await this.getMCPServers();
61
- return Object.keys(mcpServers).length;
332
+ const configData = await this.parseConfigFile();
333
+ return Object.keys(configData.servers).length;
62
334
  } catch (error) {
63
335
  return 0;
64
336
  }
65
337
  }
66
- async getMCPServers() {
67
- await this.parseFile();
68
- if (this.fileContentsData?.servers) {
69
- return this.fileContentsData.servers;
338
+ /**
339
+ * Get the raw file content
340
+ */
341
+ async getFileContent() {
342
+ if (this.fileContents) {
343
+ return this.fileContents;
70
344
  }
71
- if (this.fileContentsData?.mcp?.servers) {
72
- return this.fileContentsData.mcp.servers;
345
+ try {
346
+ this.fileContents = await fs.readFile(this.filePath, "utf-8");
347
+ return this.fileContents;
348
+ } catch (error) {
349
+ throw new Error(`Failed to read file: ${this.filePath}`);
73
350
  }
74
- if (this.fileContentsData?.mcpServers) {
75
- return this.fileContentsData.mcpServers;
351
+ }
352
+ };
353
+
354
+ // src/services/credential-detection-service.ts
355
+ var CredentialDetectionService = class {
356
+ static {
357
+ __name(this, "CredentialDetectionService");
358
+ }
359
+ /**
360
+ * Credential patterns grouped by risk level for easier maintenance
361
+ */
362
+ static CREDENTIAL_PATTERNS = {
363
+ high: [
364
+ // API Keys and Tokens
365
+ /api[_-]?key/i,
366
+ /api[_-]?token/i,
367
+ /access[_-]?token/i,
368
+ /secret[_-]?key/i,
369
+ /private[_-]?key/i,
370
+ // Authentication Tokens
371
+ /auth[_-]?token/i,
372
+ /bearer[_-]?token/i,
373
+ /jwt[_-]?token/i,
374
+ /oauth[_-]?token/i,
375
+ // Passwords
376
+ /password/i,
377
+ /passwd/i,
378
+ /pwd/i,
379
+ // Credentials
380
+ /credential/i,
381
+ /creds/i,
382
+ // Specific service patterns
383
+ /openai[_-]?api[_-]?key/i,
384
+ /anthropic[_-]?api[_-]?key/i,
385
+ /firecrawl[_-]?api[_-]?key/i,
386
+ /github[_-]?token/i,
387
+ /gitlab[_-]?token/i,
388
+ /bitbucket[_-]?token/i,
389
+ // Database passwords
390
+ /db[_-]?password/i,
391
+ /database[_-]?password/i,
392
+ /redis[_-]?password/i,
393
+ /postgres[_-]?password/i,
394
+ /mysql[_-]?password/i,
395
+ // Cloud services
396
+ /aws[_-]?secret[_-]?access[_-]?key/i,
397
+ /aws[_-]?access[_-]?key[_-]?id/i,
398
+ /azure[_-]?key/i,
399
+ /gcp[_-]?key/i,
400
+ /google[_-]?api[_-]?key/i,
401
+ /gemini[_-]?api[_-]?key/i,
402
+ /claude[_-]?api[_-]?key/i
403
+ ],
404
+ low: [
405
+ // Organization and Account IDs
406
+ /org[_-]?id/i,
407
+ /organization[_-]?id/i,
408
+ /account[_-]?id/i,
409
+ /user[_-]?id/i,
410
+ /openai[_-]?org[_-]?id/i
411
+ ]
412
+ };
413
+ /**
414
+ * Check if an environment variable name suggests it might contain credentials
415
+ */
416
+ static isPotentialCredential(envVarName) {
417
+ return this.CREDENTIAL_PATTERNS.high.some((pattern) => pattern.test(envVarName)) || this.CREDENTIAL_PATTERNS.low.some((pattern) => pattern.test(envVarName));
418
+ }
419
+ /**
420
+ * Analyze environment variables and return credential detection results
421
+ */
422
+ static analyzeEnvironmentVariables(env) {
423
+ if (!env || typeof env !== "object") {
424
+ return {
425
+ hasCredentials: false,
426
+ credentialVars: [],
427
+ riskLevel: "none"
428
+ };
76
429
  }
77
- if (this.fileContentsData?.context_servers) {
78
- return this.fileContentsData.context_servers;
430
+ const credentialVars = [];
431
+ for (const [name, value] of Object.entries(env)) {
432
+ if (this.isPotentialCredential(name)) {
433
+ credentialVars.push({
434
+ name,
435
+ value: this.maskValue(value),
436
+ riskLevel: this.assessRiskLevel(name)
437
+ });
438
+ }
79
439
  }
80
- return {};
440
+ const hasCredentials = credentialVars.length > 0;
441
+ const riskLevel = this.calculateOverallRiskLevel(credentialVars);
442
+ return {
443
+ hasCredentials,
444
+ credentialVars,
445
+ riskLevel
446
+ };
81
447
  }
82
- async getFileContent() {
83
- if (this.fileContents) {
84
- return this.fileContents;
448
+ /**
449
+ * Mask sensitive values for display (show only first and last character)
450
+ */
451
+ static maskValue(value) {
452
+ if (!value || value.length <= 2) {
453
+ return value;
454
+ }
455
+ const first = value.charAt(0);
456
+ const last = value.charAt(value.length - 1);
457
+ const maskedLength = Math.min(value.length - 2, 8);
458
+ return `${first}${"*".repeat(maskedLength)}${last}`;
459
+ }
460
+ /**
461
+ * Assess risk level for a specific credential variable
462
+ */
463
+ static assessRiskLevel(name) {
464
+ if (this.CREDENTIAL_PATTERNS.high.some((pattern) => pattern.test(name))) {
465
+ return "high";
466
+ }
467
+ if (this.CREDENTIAL_PATTERNS.low.some((pattern) => pattern.test(name))) {
468
+ return "low";
85
469
  }
86
- this.fileContents = await fs.readFile(this.filePath, "utf-8");
87
- return this.fileContents;
470
+ return "high";
471
+ }
472
+ /**
473
+ * Calculate overall risk level based on all credential variables
474
+ */
475
+ static calculateOverallRiskLevel(credentialVars) {
476
+ if (credentialVars.length === 0) {
477
+ return "none";
478
+ }
479
+ const hasHighRisk = credentialVars.some((v) => v.riskLevel === "high");
480
+ if (hasHighRisk) {
481
+ return "high";
482
+ }
483
+ return "low";
484
+ }
485
+ };
486
+
487
+ // src/services/directory-bubble-service.ts
488
+ import path2 from "path";
489
+ import fs2 from "fs/promises";
490
+ import { homedir } from "os";
491
+ var DirectoryBubbleService = class {
492
+ static {
493
+ __name(this, "DirectoryBubbleService");
494
+ }
495
+ /**
496
+ * Find a local MCP config file by bubbling up the directory tree
497
+ * @param localPath - The relative path to search for (e.g., '.vscode/mcp.json')
498
+ * @param startDir - The directory to start searching from
499
+ * @returns The absolute path to the found config file, or null if not found
500
+ */
501
+ async findLocalConfigInParentDirectories(localPath, startDir) {
502
+ try {
503
+ let currentDir = path2.resolve(startDir);
504
+ const homeDir = homedir();
505
+ const rootDir = "/";
506
+ let iterationCount = 0;
507
+ const maxIterations = 100;
508
+ const startDirResult = await this.checkDirectoryForConfig(currentDir, localPath);
509
+ if (startDirResult) {
510
+ return path2.join(currentDir, localPath);
511
+ }
512
+ while (currentDir !== homeDir && currentDir !== rootDir && iterationCount < maxIterations) {
513
+ const parentDir = this.getParentDirectory(currentDir);
514
+ if (!parentDir || parentDir === currentDir) {
515
+ break;
516
+ }
517
+ if (parentDir === currentDir || parentDir.length >= currentDir.length) {
518
+ break;
519
+ }
520
+ currentDir = parentDir;
521
+ iterationCount++;
522
+ const found = await this.checkDirectoryForConfig(currentDir, localPath);
523
+ if (found) {
524
+ return path2.join(currentDir, localPath);
525
+ }
526
+ }
527
+ return null;
528
+ } catch (error) {
529
+ return null;
530
+ }
531
+ }
532
+ /**
533
+ * Check if a config file exists in the specified directory
534
+ * @param dir - The directory to check
535
+ * @param configPath - The relative path to the config file
536
+ * @returns True if the config file exists and is accessible
537
+ */
538
+ async checkDirectoryForConfig(dir, configPath) {
539
+ try {
540
+ const fullPath = path2.join(dir, configPath);
541
+ await fs2.access(fullPath);
542
+ return true;
543
+ } catch (error) {
544
+ return false;
545
+ }
546
+ }
547
+ /**
548
+ * Get the parent directory of the specified directory
549
+ * @param dir - The directory to get the parent of
550
+ * @returns The parent directory path, or null if already at root
551
+ */
552
+ getParentDirectory(dir) {
553
+ const parent = path2.dirname(dir);
554
+ return parent === dir ? null : parent;
555
+ }
556
+ };
557
+
558
+ // src/utils/url-utils.ts
559
+ function extractHostname(urlString) {
560
+ try {
561
+ let urlToParse = urlString;
562
+ if (!urlToParse.includes("://")) {
563
+ urlToParse = `http://${urlToParse}`;
564
+ }
565
+ const url = new URL(urlToParse);
566
+ return url.hostname;
567
+ } catch (error) {
568
+ return urlString;
569
+ }
570
+ }
571
+ __name(extractHostname, "extractHostname");
572
+
573
+ // src/services/mcp-config-service.ts
574
+ var MCPConfigService = class {
575
+ static {
576
+ __name(this, "MCPConfigService");
577
+ }
578
+ pathRegistry;
579
+ currentOS;
580
+ debug;
581
+ directoryBubbleService;
582
+ enableDirectoryBubbling;
583
+ constructor(options = {}) {
584
+ this.pathRegistry = new MCPPathRegistry();
585
+ this.currentOS = platform();
586
+ this.debug = util.debuglog("ls-mcp");
587
+ this.directoryBubbleService = new DirectoryBubbleService();
588
+ this.enableDirectoryBubbling = options.enableDirectoryBubbling ?? false;
589
+ }
590
+ /**
591
+ * Get MCP configuration files for a specific AI application on the current OS
592
+ */
593
+ getConfigFilesPerApp(appName) {
594
+ try {
595
+ return this.pathRegistry.getPathsForApp(this.currentOS, appName);
596
+ } catch (error) {
597
+ throw new Error(`Failed to get config files for app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
598
+ }
599
+ }
600
+ /**
601
+ * Get MCP configuration files for all AI applications on the current OS
602
+ */
603
+ getAllConfigFiles() {
604
+ try {
605
+ return this.pathRegistry.getPathsForOS(this.currentOS);
606
+ } catch (error) {
607
+ throw new Error(`Failed to get all config files: ${error instanceof Error ? error.message : "Unknown error"}`);
608
+ }
609
+ }
610
+ /**
611
+ * Get MCP servers configured for a specific AI application on the current OS
612
+ */
613
+ async getMCPServersPerApp(appName) {
614
+ try {
615
+ const appPaths = this.getConfigFilesPerApp(appName);
616
+ const allServers = [];
617
+ for (const filePath of appPaths) {
618
+ const servers = await this.parseConfigFileForServers(filePath.filePath);
619
+ allServers.push(...servers);
620
+ }
621
+ return allServers;
622
+ } catch (error) {
623
+ throw new Error(`Failed to get MCP servers for app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
624
+ }
625
+ }
626
+ /**
627
+ * Get MCP servers configured for all AI applications on the current OS
628
+ */
629
+ async getAllMCPServers() {
630
+ try {
631
+ const allApps = this.pathRegistry.getSupportedApps(this.currentOS);
632
+ const allServers = {};
633
+ for (const appName of allApps) {
634
+ try {
635
+ allServers[appName] = await this.getMCPServersPerApp(appName);
636
+ } catch (error) {
637
+ this.debug(`Failed to get servers for app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
638
+ allServers[appName] = [];
639
+ }
640
+ }
641
+ return allServers;
642
+ } catch (error) {
643
+ throw new Error(`Failed to get all MCP servers: ${error instanceof Error ? error.message : "Unknown error"}`);
644
+ }
645
+ }
646
+ /**
647
+ * Get metadata for all supported AI applications on the current OS
648
+ */
649
+ getSupportedApps() {
650
+ try {
651
+ const appNames = this.pathRegistry.getSupportedApps(this.currentOS);
652
+ const appPaths = this.pathRegistry.getPathsForOS(this.currentOS);
653
+ return appNames.map((appName) => ({
654
+ name: appName,
655
+ friendlyName: this.getFriendlyName(appName),
656
+ paths: appPaths[appName] || []
657
+ }));
658
+ } catch (error) {
659
+ throw new Error(`Failed to get supported apps: ${error instanceof Error ? error.message : "Unknown error"}`);
660
+ }
661
+ }
662
+ /**
663
+ * Get all supported operating systems
664
+ */
665
+ getSupportedOperatingSystems() {
666
+ return this.pathRegistry.getSupportedOperatingSystems();
667
+ }
668
+ /**
669
+ * Validate if a configuration file exists and is parsable
670
+ */
671
+ async validateConfigFile(filePath) {
672
+ try {
673
+ await fs3.access(filePath);
674
+ const parser = this.createParser(filePath);
675
+ return await parser.isValidSyntax();
676
+ } catch (error) {
677
+ return false;
678
+ }
679
+ }
680
+ /**
681
+ * Create a parser instance (can be overridden for testing)
682
+ */
683
+ createParser(filePath) {
684
+ return new MCPConfigParser(filePath);
685
+ }
686
+ /**
687
+ * Get MCP file groups with resolved paths and server information
688
+ */
689
+ async getMCPFileGroups() {
690
+ try {
691
+ const appPaths = this.getAllConfigFiles();
692
+ const mcpFilesPathsData = {};
693
+ for (const [groupName, paths] of Object.entries(appPaths)) {
694
+ mcpFilesPathsData[groupName] = {
695
+ name: groupName,
696
+ friendlyName: this.getFriendlyName(groupName),
697
+ paths: [],
698
+ stats: { serversCount: 0 }
699
+ };
700
+ const uniqueFilePaths = /* @__PURE__ */ new Set();
701
+ let totalServersCount = 0;
702
+ for (const filePathData of paths) {
703
+ let resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
704
+ let absolutePath = path3.resolve(resolvedPath);
705
+ if (filePathData.type === "local" && this.enableDirectoryBubbling) {
706
+ try {
707
+ await fs3.access(resolvedPath);
708
+ } catch (error) {
709
+ const bubbledPath = await this.directoryBubbleService.findLocalConfigInParentDirectories(
710
+ filePathData.filePath,
711
+ process.cwd()
712
+ );
713
+ if (bubbledPath) {
714
+ resolvedPath = bubbledPath;
715
+ absolutePath = path3.resolve(resolvedPath);
716
+ }
717
+ }
718
+ }
719
+ if (uniqueFilePaths.has(absolutePath)) {
720
+ continue;
721
+ }
722
+ uniqueFilePaths.add(absolutePath);
723
+ try {
724
+ await fs3.access(resolvedPath);
725
+ const parser = this.createParser(resolvedPath);
726
+ const parsable = await parser.isValidSyntax();
727
+ filePathData.parsable = parsable;
728
+ if (parsable) {
729
+ const configData = await parser.parseConfigFile();
730
+ const servers = await this.convertToMCPServerInfo(configData.servers || {});
731
+ filePathData.servers = servers;
732
+ totalServersCount += servers.length;
733
+ }
734
+ mcpFilesPathsData[groupName].paths.push(filePathData);
735
+ } catch (error) {
736
+ this.debug(`Skipping file ${resolvedPath}: ${error instanceof Error ? error.message : "Unknown error"}`);
737
+ }
738
+ }
739
+ if (mcpFilesPathsData[groupName] && mcpFilesPathsData[groupName].stats) {
740
+ mcpFilesPathsData[groupName].stats.serversCount = totalServersCount;
741
+ }
742
+ }
743
+ return mcpFilesPathsData;
744
+ } catch (error) {
745
+ throw new Error(`Failed to get MCP file groups: ${error instanceof Error ? error.message : "Unknown error"}`);
746
+ }
747
+ }
748
+ /**
749
+ * Register a custom app with custom paths for the current OS
750
+ */
751
+ registerCustomApp(appName, paths) {
752
+ try {
753
+ this.pathRegistry.registerCustomApp(this.currentOS, appName, paths);
754
+ } catch (error) {
755
+ throw new Error(`Failed to register custom app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
756
+ }
757
+ }
758
+ /**
759
+ * Parse a configuration file and return server information
760
+ */
761
+ async parseConfigFileForServers(filePath) {
762
+ try {
763
+ const parser = this.createParser(filePath);
764
+ const configData = await parser.parseConfigFile();
765
+ return await this.convertToMCPServerInfo(configData.servers || {});
766
+ } catch (error) {
767
+ this.debug(`Failed to parse config file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
768
+ return [];
769
+ }
770
+ }
771
+ /**
772
+ * Convert parsed server configs to MCPServerInfo format
773
+ */
774
+ async convertToMCPServerInfo(servers) {
775
+ const serverInfos = [];
776
+ for (const [serverName, serverConfig] of Object.entries(servers)) {
777
+ if (serverConfig && typeof serverConfig === "object") {
778
+ let source;
779
+ if (serverConfig.url) {
780
+ source = extractHostname(serverConfig.url);
781
+ } else {
782
+ source = serverConfig.command || "";
783
+ }
784
+ serverInfos.push({
785
+ name: serverName,
786
+ command: serverConfig.command || "",
787
+ args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
788
+ transport: serverConfig.type === "streamable-http" ? "http" : serverConfig.type,
789
+ // Map streamable-http to http
790
+ type: serverConfig.type,
791
+ source,
792
+ env: serverConfig.env,
793
+ status: "stopped",
794
+ // Default status, will be updated by server manager
795
+ credentials: CredentialDetectionService.analyzeEnvironmentVariables(serverConfig.env)
796
+ });
797
+ }
798
+ }
799
+ return serverInfos;
800
+ }
801
+ /**
802
+ * Get friendly name for an app
803
+ */
804
+ getFriendlyName(appName) {
805
+ const friendlyNames = {
806
+ claude: "Claude Desktop",
807
+ claude_code: "Claude Code",
808
+ cursor: "Cursor",
809
+ vscode: "VS Code",
810
+ cline: "Cline",
811
+ windsurf: "Windsurf",
812
+ roo: "Roo",
813
+ "intellij-github-copilot": "IntelliJ GitHub Copilot",
814
+ junie: "IntelliJ Junie",
815
+ zed: "Zed",
816
+ gemini: "Gemini CLI"
817
+ };
818
+ return friendlyNames[appName] || appName;
88
819
  }
89
820
  };
90
821
 
91
822
  // src/services/mcp-server-manager-service.ts
92
- import path from "path";
823
+ import path4 from "path";
93
824
  import { execSync } from "child_process";
94
- import { platform } from "os";
825
+ import { platform as platform2 } from "os";
95
826
  var MCPServerManagerService = class {
96
827
  static {
97
828
  __name(this, "MCPServerManagerService");
@@ -111,14 +842,14 @@ var MCPServerManagerService = class {
111
842
  if (serverConfig?.type && serverConfig.type === "sse") {
112
843
  this.transport = "sse";
113
844
  }
114
- if (serverConfig?.type && serverConfig.type === "http") {
845
+ if (serverConfig?.type && (serverConfig.type === "http" || serverConfig.type === "streamable-http")) {
115
846
  this.transport = "http";
116
847
  }
117
848
  if (serverConfig?.type && serverConfig.type === "stdio") {
118
849
  this.transport = "stdio";
119
850
  }
120
851
  if (serverConfig.url) {
121
- this.source = serverConfig.url;
852
+ this.source = extractHostname(serverConfig.url);
122
853
  this.transport = "http";
123
854
  } else {
124
855
  const fullCommand = [serverConfig.command, ...serverConfig.args || []].join(" ");
@@ -147,7 +878,7 @@ var MCPServerManagerService = class {
147
878
  isRunning() {
148
879
  try {
149
880
  let psOutput;
150
- if (platform() === "win32") {
881
+ if (platform2() === "win32") {
151
882
  psOutput = execSync('powershell -Command "Get-CimInstance -ClassName Win32_Process | Select-Object ProcessId,Name,CommandLine,ParentProcessId | ConvertTo-Csv -NoTypeInformation"', {
152
883
  encoding: "utf8",
153
884
  timeout: 5e3
@@ -165,7 +896,7 @@ var MCPServerManagerService = class {
165
896
  let pid;
166
897
  let ppid;
167
898
  let commandLine;
168
- if (platform() === "win32") {
899
+ if (platform2() === "win32") {
169
900
  if (processLine.startsWith('"ProcessId"') || processLine.startsWith("ProcessId")) continue;
170
901
  const parts = this.parseCSVLine(processLine);
171
902
  if (parts.length < 4) continue;
@@ -188,7 +919,7 @@ var MCPServerManagerService = class {
188
919
  for (const [pid, processData] of processMap) {
189
920
  const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid);
190
921
  let commandMatchWin32 = false;
191
- if (platform() === "win32") {
922
+ if (platform2() === "win32") {
192
923
  let commandTokensOnWin32 = processData.commandTokens;
193
924
  if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith("cmd")) {
194
925
  commandTokensOnWin32 = commandTokensOnWin32.slice(1);
@@ -299,9 +1030,9 @@ var MCPServerManagerService = class {
299
1030
  return true;
300
1031
  }
301
1032
  getBaseCommand(fullCommandPath) {
302
- let baseCommand = path.basename(fullCommandPath);
303
- if (platform() === "win32") {
304
- baseCommand = path.basename(fullCommandPath, ".exe");
1033
+ let baseCommand = path4.basename(fullCommandPath);
1034
+ if (platform2() === "win32") {
1035
+ baseCommand = path4.basename(fullCommandPath, ".exe");
305
1036
  }
306
1037
  baseCommand = baseCommand.toLowerCase();
307
1038
  return baseCommand;
@@ -482,245 +1213,63 @@ var MCPServerManagerService = class {
482
1213
  }
483
1214
  };
484
1215
 
485
- // src/utils/os-paths.ts
486
- import path2 from "path";
487
- var appData = process.env.APPDATA || "";
488
- var localAppData = process.env.LOCALAPPDATA || "";
489
- var homeDir = process.env.HOME || "";
490
- function getWindowsPaths() {
491
- return {
492
- claude: [
493
- { filePath: path2.join(appData, "Claude", "claude_desktop_config.json"), type: "global" }
494
- ],
495
- claude_code: [
496
- { filePath: ".mcp.json", type: "local" }
497
- ],
498
- cursor: [
499
- { filePath: path2.join(homeDir, ".cursor", "mcp.json"), type: "global" },
500
- { filePath: path2.join(".cursor", "mcp.json"), type: "local" }
501
- ],
502
- vscode: [
503
- { filePath: path2.join(".vscode", "mcp.json"), type: "local" },
504
- { filePath: path2.join(appData, "Code", "User", "settings.json"), type: "global" },
505
- { filePath: path2.join(appData, "Code - Insiders", "User", "settings.json"), type: "global" },
506
- { filePath: path2.join(appData, "Code", "User", "mcp.json"), type: "global" },
507
- { filePath: path2.join(appData, "Code - Insiders", "User", "mcp.json"), type: "global" }
508
- ],
509
- cline: [
510
- { filePath: path2.join(appData, "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
511
- { filePath: path2.join(appData, "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
512
- ],
513
- windsurf: [
514
- { filePath: path2.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
515
- ],
516
- roo: [
517
- { filePath: path2.join(appData, "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
518
- { filePath: path2.join(appData, "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
519
- ],
520
- "intellij-github-copilot": [
521
- { filePath: path2.join(localAppData, "github-copilot", "intellij", "mcp.json"), type: "global" }
522
- ],
523
- junie: [
524
- { filePath: path2.join(homeDir, ".junie", "mcp", "mcp.json"), type: "global" }
525
- ],
526
- zed: [
527
- { filePath: path2.join(localAppData, "zed", "settings.json"), type: "global" },
528
- { filePath: path2.join(".zed", "settings.json"), type: "local" }
529
- ],
530
- gemini: [
531
- { filePath: path2.join(homeDir, ".gemini", "settings.json"), type: "global" },
532
- { filePath: path2.join(".gemini", "settings.json"), type: "local" }
533
- ]
534
- };
535
- }
536
- __name(getWindowsPaths, "getWindowsPaths");
537
- function getDarwinPaths() {
538
- return {
539
- claude: [
540
- { filePath: path2.join(homeDir, "Library", "Application Support", "Claude", "claude_desktop_config.json"), type: "global" }
541
- ],
542
- claude_code: [
543
- { filePath: ".mcp.json", type: "local" }
544
- ],
545
- cursor: [
546
- { filePath: path2.join(homeDir, ".cursor", "mcp.json"), type: "global" },
547
- { filePath: path2.join(".cursor", "mcp.json"), type: "local" }
548
- ],
549
- vscode: [
550
- { filePath: path2.join(".vscode", "mcp.json"), type: "local" },
551
- { filePath: path2.join(homeDir, "Library", "Application Support", "Code", "User", "settings.json"), type: "global" },
552
- { filePath: path2.join(homeDir, "Library", "Application Support", "Code", "User", "mcp.json"), type: "global" },
553
- { filePath: path2.join(homeDir, "Library", "Application Support", "Code - Insiders", "User", "settings.json"), type: "global" },
554
- { filePath: path2.join(homeDir, "Library", "Application Support", "Code - Insiders", "User", "mcp.json"), type: "global" }
555
- ],
556
- cline: [
557
- { filePath: path2.join(homeDir, "Library", "Application Support", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
558
- { filePath: path2.join(homeDir, "Library", "Application Support", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
559
- ],
560
- windsurf: [
561
- { filePath: path2.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
562
- ],
563
- roo: [
564
- { filePath: path2.join(homeDir, "Library", "Application Support", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
565
- { filePath: path2.join(homeDir, "Library", "Application Support", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
566
- ],
567
- "intellij-github-copilot": [
568
- { filePath: path2.join(homeDir, ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
569
- ],
570
- junie: [
571
- { filePath: path2.join(homeDir, ".junie", "mcp", "mcp.json"), type: "global" },
572
- { filePath: path2.join(".junie", "mcp", "mcp.json"), type: "local" }
573
- ],
574
- zed: [
575
- { filePath: path2.join(homeDir, ".config", "zed", "settings.json"), type: "global" },
576
- { filePath: path2.join(".zed", "settings.json"), type: "local" }
577
- ],
578
- gemini: [
579
- { filePath: path2.join(homeDir, ".gemini", "settings.json"), type: "global" },
580
- { filePath: path2.join(".gemini", "settings.json"), type: "local" }
581
- ]
582
- };
583
- }
584
- __name(getDarwinPaths, "getDarwinPaths");
585
-
586
1216
  // src/main.ts
587
- var osSpecificPaths = {};
588
- if (platform2() === "win32") {
589
- osSpecificPaths = getWindowsPaths();
590
- } else {
591
- osSpecificPaths = getDarwinPaths();
592
- }
593
1217
  var MCPFiles = class {
594
1218
  static {
595
1219
  __name(this, "MCPFiles");
596
1220
  }
597
- mcpFilePathGroups = {
598
- claude: {
599
- name: "claude-desktop",
600
- friendlyName: "Claude Desktop",
601
- paths: osSpecificPaths["claude"]
602
- },
603
- claude_code: {
604
- name: "claude-code",
605
- friendlyName: "Claude Code",
606
- paths: osSpecificPaths["claude_code"]
607
- },
608
- cursor: {
609
- name: "cursor",
610
- friendlyName: "Cursor",
611
- paths: osSpecificPaths["cursor"]
612
- },
613
- vscode: {
614
- name: "vscode",
615
- friendlyName: "VS Code",
616
- paths: osSpecificPaths["vscode"]
617
- },
618
- cline: {
619
- name: "cline",
620
- friendlyName: "Cline",
621
- paths: osSpecificPaths["cline"]
622
- },
623
- windsurf: {
624
- name: "windsurf",
625
- friendlyName: "Windsurf",
626
- paths: osSpecificPaths["windsurf"]
627
- },
628
- roo: {
629
- name: "roo",
630
- friendlyName: "Roo",
631
- paths: osSpecificPaths["roo"]
632
- },
633
- "intellij-github-copilot": {
634
- name: "intellij-github-copilot",
635
- friendlyName: "IntelliJ GitHub Copilot",
636
- paths: osSpecificPaths["intellij-github-copilot"]
637
- },
638
- junie: {
639
- name: "junie",
640
- friendlyName: "IntelliJ Junie",
641
- paths: osSpecificPaths["junie"]
642
- },
643
- zed: {
644
- name: "zed",
645
- friendlyName: "Zed",
646
- paths: osSpecificPaths["zed"]
647
- },
648
- gemini: {
649
- name: "gemini-cli",
650
- friendlyName: "Gemini CLI",
651
- paths: osSpecificPaths.gemini
652
- }
653
- };
654
- constructor(mcpFilePathGroups) {
655
- this.mcpFilePathGroups = mcpFilePathGroups || this.mcpFilePathGroups;
1221
+ mcpConfigService;
1222
+ constructor() {
1223
+ this.mcpConfigService = new MCPConfigService({ enableDirectoryBubbling: true });
656
1224
  }
1225
+ /**
1226
+ * Find and process all MCP configuration files
1227
+ */
657
1228
  async findFiles() {
658
- const mcpFilesPathsData = {};
659
- for (const groupName of Object.keys(this.mcpFilePathGroups)) {
660
- const clientsGroup = this.mcpFilePathGroups[groupName];
661
- mcpFilesPathsData[groupName] = {
662
- name: clientsGroup.name,
663
- friendlyName: clientsGroup.friendlyName,
664
- paths: [],
665
- stats: {}
666
- };
667
- const uniqueFilePaths = /* @__PURE__ */ new Set();
668
- for (const filePathData of clientsGroup.paths) {
669
- const resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
670
- const absolutePath = path3.resolve(resolvedPath);
671
- if (uniqueFilePaths.has(absolutePath)) {
672
- continue;
673
- }
674
- uniqueFilePaths.add(absolutePath);
675
- try {
676
- await fs2.access(resolvedPath);
677
- const MCPConfigLinter = new MCPConfigLinterService(resolvedPath);
678
- const parsable = await MCPConfigLinter.isValidSyntax();
679
- filePathData.parsable = parsable;
680
- const mcpServersData = [];
681
- const mcpServersFromConfig = await MCPConfigLinter.getMCPServers();
682
- for (const serverName of Object.keys(mcpServersFromConfig)) {
683
- const serverConfigRaw = mcpServersFromConfig[serverName];
684
- const serverConfig = {
685
- name: serverName,
686
- command: serverConfigRaw.command || "",
687
- args: serverConfigRaw.args,
688
- url: serverConfigRaw.url,
689
- transport: serverConfigRaw.transport,
690
- type: serverConfigRaw.type,
691
- env: serverConfigRaw.env
692
- };
693
- const MCPServerManager = new MCPServerManagerService(serverConfig);
694
- const mcpServerProcessDetection = MCPServerManager.isRunning();
695
- let mcpServerProcess = false;
696
- if (mcpServerProcessDetection) {
697
- if (typeof mcpServerProcessDetection === "object" && mcpServerProcessDetection.estimatedProduct === clientsGroup.name) {
698
- mcpServerProcess = true;
1229
+ try {
1230
+ const mcpFilesPathsData = await this.mcpConfigService.getMCPFileGroups();
1231
+ for (const groupName of Object.keys(mcpFilesPathsData)) {
1232
+ const group = mcpFilesPathsData[groupName];
1233
+ for (const filePathData of group.paths) {
1234
+ if (filePathData.servers && filePathData.servers.length > 0) {
1235
+ for (const server of filePathData.servers) {
1236
+ const serverConfig = {
1237
+ name: server.name,
1238
+ command: server.command,
1239
+ args: server.args,
1240
+ transport: server.transport,
1241
+ // transport is always populated from type in the data layer
1242
+ type: server.type,
1243
+ env: server.env
1244
+ };
1245
+ const serverManager = new MCPServerManagerService(serverConfig);
1246
+ const processDetection = serverManager.isRunning();
1247
+ let isRunning = false;
1248
+ if (processDetection) {
1249
+ if (typeof processDetection === "object" && processDetection.estimatedProduct === group.name) {
1250
+ isRunning = true;
1251
+ }
699
1252
  }
1253
+ server.status = isRunning ? "running" : "stopped";
700
1254
  }
701
- mcpServersData.push({
702
- name: MCPServerManager.getName(),
703
- command: MCPServerManager.getCmd(),
704
- args: MCPServerManager.getArgs(),
705
- source: MCPServerManager.getSource(),
706
- transport: MCPServerManager.getTransport(),
707
- env: MCPServerManager.getEnv(),
708
- status: mcpServerProcess ? "running" : "stopped"
709
- });
710
1255
  }
711
- filePathData.servers = mcpServersData;
712
- mcpFilesPathsData[groupName]["stats"]["serversCount"] = await MCPConfigLinter.countMCPServers();
713
- mcpFilesPathsData[groupName].paths.push(filePathData);
714
- } catch (error) {
715
1256
  }
716
1257
  }
1258
+ return mcpFilesPathsData;
1259
+ } catch (error) {
1260
+ throw new Error(`Failed to find MCP files: ${error instanceof Error ? error.message : "Unknown error"}`);
717
1261
  }
718
- return mcpFilesPathsData;
1262
+ }
1263
+ /**
1264
+ * Get MCP configuration service instance for advanced operations
1265
+ */
1266
+ getMCPConfigService() {
1267
+ return this.mcpConfigService;
719
1268
  }
720
1269
  };
721
1270
 
722
1271
  // src/services/render-service.ts
723
- import { styleText as styleText8 } from "util";
1272
+ import { styleText as styleText10 } from "util";
724
1273
 
725
1274
  // src/components/transport.ts
726
1275
  import { styleText } from "util";
@@ -803,6 +1352,71 @@ function render7(text) {
803
1352
  }
804
1353
  __name(render7, "render");
805
1354
 
1355
+ // src/components/credential-warning.ts
1356
+ import { styleText as styleText8 } from "util";
1357
+ function CredentialWarningComponent(credentials) {
1358
+ if (!credentials || !credentials.hasCredentials) {
1359
+ return "";
1360
+ }
1361
+ const { riskLevel, credentialVars } = credentials;
1362
+ let riskColor;
1363
+ let riskIcon;
1364
+ switch (riskLevel) {
1365
+ case "high":
1366
+ riskColor = "red";
1367
+ riskIcon = styleText8(["red"], "\u25CF");
1368
+ break;
1369
+ case "low":
1370
+ riskColor = "blue";
1371
+ riskIcon = styleText8(["blue"], "\u25CF");
1372
+ break;
1373
+ default:
1374
+ riskColor = "blue";
1375
+ riskIcon = styleText8(["blue"], "\u25CF");
1376
+ }
1377
+ const riskText = styleText8([riskColor], `${riskIcon} ${riskLevel.toUpperCase()} RISK`);
1378
+ const credentialSummary = credentialVars.map((cv) => `${cv.name}=${cv.value}`).join(", ");
1379
+ return `${riskText} ${styleText8(["dim"], `(${credentialVars.length} cred vars: ${credentialSummary})`)}`;
1380
+ }
1381
+ __name(CredentialWarningComponent, "CredentialWarningComponent");
1382
+
1383
+ // src/components/summary.ts
1384
+ import { styleText as styleText9 } from "util";
1385
+ function SummaryComponent(stats) {
1386
+ const { totalServers, runningServers, highRiskCredentials, transportBreakdown } = stats;
1387
+ const runningBar = createProgressBar(runningServers, totalServers, 20, "green");
1388
+ const securityBar = createProgressBar(highRiskCredentials, totalServers, 20, "red");
1389
+ const transportText = `stdio: ${transportBreakdown.stdio} | SSE: ${transportBreakdown.sse} | HTTP: ${transportBreakdown.http}`;
1390
+ const lines = [
1391
+ "SUMMARY",
1392
+ ` SERVERS ${runningBar} ${runningServers} / ${totalServers} Running`,
1393
+ ` SECURITY ${securityBar} ${highRiskCredentials} / ${totalServers} High Risk Credentials`,
1394
+ ` TRANSPORT ${transportText}`
1395
+ ];
1396
+ return lines.join("\n");
1397
+ }
1398
+ __name(SummaryComponent, "SummaryComponent");
1399
+ function createProgressBar(count, total, width, color) {
1400
+ if (total === 0) {
1401
+ const emptyBar = "\u2591".repeat(width);
1402
+ return emptyBar;
1403
+ }
1404
+ const progress = Math.min(count / total, 1);
1405
+ const filledWidth = Math.round(progress * width);
1406
+ const emptyWidth = width - filledWidth;
1407
+ let filled;
1408
+ let empty;
1409
+ if (color === "green") {
1410
+ filled = styleText9(["greenBright"], "\u2588".repeat(filledWidth));
1411
+ empty = styleText9(["green"], "\u2591".repeat(emptyWidth));
1412
+ } else {
1413
+ filled = styleText9(["redBright"], "\u2588".repeat(filledWidth));
1414
+ empty = styleText9(["red"], "\u2591".repeat(emptyWidth));
1415
+ }
1416
+ return `${filled}${empty}`;
1417
+ }
1418
+ __name(createProgressBar, "createProgressBar");
1419
+
806
1420
  // src/services/render-service.ts
807
1421
  var RenderService = class _RenderService {
808
1422
  static {
@@ -819,8 +1433,8 @@ var RenderService = class _RenderService {
819
1433
  }
820
1434
  static printMcpServers(data) {
821
1435
  if (data.length === 0) return;
822
- const headers = ["STATUS", "NAME", "SOURCE", "TRANSPORT"];
823
- const keys = ["status", "name", "source", "transport"];
1436
+ const headers = ["STATUS", "NAME", "SOURCE", "TRANSPORT", "CREDENTIALS"];
1437
+ const keys = ["status", "name", "source", "transport", "credentials"];
824
1438
  const centerColumns = [0, 2, 3];
825
1439
  const leftPadding = " ";
826
1440
  const columnWidths = headers.map((header, index) => {
@@ -839,6 +1453,9 @@ var RenderService = class _RenderService {
839
1453
  if (keys[index] === "name") {
840
1454
  text = render4(text);
841
1455
  }
1456
+ if (keys[index] === "credentials") {
1457
+ text = CredentialWarningComponent(row[keys[index]]);
1458
+ }
842
1459
  return _RenderService.getVisibleLength(text);
843
1460
  }));
844
1461
  return Math.max(headerWidth, dataWidth);
@@ -882,6 +1499,9 @@ var RenderService = class _RenderService {
882
1499
  if (key === "name") {
883
1500
  text = render4(text);
884
1501
  }
1502
+ if (key === "credentials") {
1503
+ text = CredentialWarningComponent(row[key]);
1504
+ }
885
1505
  if (centerColumns.includes(index)) {
886
1506
  return centerText(text, columnWidths[index]);
887
1507
  }
@@ -951,14 +1571,33 @@ var RenderService = class _RenderService {
951
1571
  let filled;
952
1572
  let empty;
953
1573
  if (count > 0) {
954
- filled = styleText8(["greenBright"], "\u2588".repeat(filledWidth));
955
- empty = styleText8(["green"], "\u2591".repeat(emptyWidth));
1574
+ filled = styleText10(["greenBright"], "\u2588".repeat(filledWidth));
1575
+ empty = styleText10(["green"], "\u2591".repeat(emptyWidth));
956
1576
  } else {
957
1577
  filled = "\u2588".repeat(filledWidth);
958
1578
  empty = "\u2591".repeat(emptyWidth);
959
1579
  }
960
1580
  return `${filled}${empty} ${count} / ${total} ${label}`;
961
1581
  }
1582
+ /**
1583
+ * Print summary statistics at the end of the output
1584
+ */
1585
+ static printSummary(stats) {
1586
+ console.log("\n");
1587
+ console.log(" \u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584");
1588
+ console.log();
1589
+ const summaryOutput = SummaryComponent(stats);
1590
+ const lines = summaryOutput.split("\n");
1591
+ for (const line of lines) {
1592
+ if (line === "SUMMARY") {
1593
+ console.log(" " + line);
1594
+ } else {
1595
+ console.log(" " + line);
1596
+ }
1597
+ }
1598
+ console.log();
1599
+ console.log(" \u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584");
1600
+ }
962
1601
  };
963
1602
 
964
1603
  // src/bin/cli.ts
@@ -971,6 +1610,10 @@ async function init() {
971
1610
  exitWithError("No configuration for MCP Server applications found.");
972
1611
  }
973
1612
  let pathIndex = 0;
1613
+ let totalServers = 0;
1614
+ let totalRunning = 0;
1615
+ let totalHighRiskCredentials = 0;
1616
+ const transportCounts = { stdio: 0, sse: 0, http: 0 };
974
1617
  for (const groupName of Object.keys(mcpFilesList)) {
975
1618
  const group = mcpFilesList[groupName];
976
1619
  if (group.paths.length > 0) {
@@ -982,6 +1625,19 @@ async function init() {
982
1625
  const mcpServers = filePathData.servers || [];
983
1626
  const totalMCPServers = filePathData.servers ? filePathData.servers.length : 0;
984
1627
  const totalMCPServersRunning = mcpServers.filter((server) => server.status === "running").length;
1628
+ totalServers += totalMCPServers;
1629
+ totalRunning += totalMCPServersRunning;
1630
+ for (const server of mcpServers) {
1631
+ if (server.transport) {
1632
+ const transport = server.transport.toLowerCase();
1633
+ if (transport in transportCounts) {
1634
+ transportCounts[transport]++;
1635
+ }
1636
+ }
1637
+ if (server.credentials?.hasCredentials && server.credentials?.riskLevel === "high") {
1638
+ totalHighRiskCredentials++;
1639
+ }
1640
+ }
985
1641
  const mcpGroupData = [
986
1642
  { key: "PROVIDER", value: group.friendlyName },
987
1643
  { key: "FILE", value: filePath },
@@ -1000,13 +1656,20 @@ async function init() {
1000
1656
  if (pathIndex === 0) {
1001
1657
  exitWithError("No MCP servers found in known configuration files.");
1002
1658
  }
1659
+ const summaryStats = {
1660
+ totalServers,
1661
+ runningServers: totalRunning,
1662
+ highRiskCredentials: totalHighRiskCredentials,
1663
+ transportBreakdown: transportCounts
1664
+ };
1665
+ RenderService.printSummary(summaryStats);
1003
1666
  }
1004
1667
  __name(init, "init");
1005
1668
  init().then(() => {
1006
1669
  console.log("\n");
1007
1670
  });
1008
1671
  function exitWithError(message) {
1009
- console.error(`${styleText9(["red"], "\u25CF")} ${message}
1672
+ console.error(`${styleText11(["red"], "\u25CF")} ${message}
1010
1673
  `);
1011
1674
  process.exit(1);
1012
1675
  }