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/main.mjs CHANGED
@@ -1,17 +1,173 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
- // src/main.ts
5
- import fs2 from "fs/promises";
6
- import { platform as platform2 } from "os";
4
+ // src/services/mcp-config-service.ts
5
+ import { platform } from "os";
7
6
  import path3 from "path";
7
+ import fs3 from "fs/promises";
8
+ import util from "util";
9
+
10
+ // src/services/mcp-path-registry.ts
11
+ import path from "path";
12
+ var MCPPathRegistry = class _MCPPathRegistry {
13
+ static {
14
+ __name(this, "MCPPathRegistry");
15
+ }
16
+ static WINDOWS_PATHS = {
17
+ claude: [
18
+ { filePath: path.join(process.env.APPDATA || "", "Claude", "claude_desktop_config.json"), type: "global" }
19
+ ],
20
+ claude_code: [
21
+ { filePath: ".mcp.json", type: "local" }
22
+ ],
23
+ cursor: [
24
+ { filePath: path.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
25
+ { filePath: path.join(".cursor", "mcp.json"), type: "local" }
26
+ ],
27
+ vscode: [
28
+ { filePath: path.join(".vscode", "mcp.json"), type: "local" },
29
+ { filePath: path.join(process.env.APPDATA || "", "Code", "User", "settings.json"), type: "global" },
30
+ { filePath: path.join(process.env.APPDATA || "", "Code - Insiders", "User", "settings.json"), type: "global" },
31
+ { filePath: path.join(process.env.APPDATA || "", "Code", "User", "mcp.json"), type: "global" },
32
+ { filePath: path.join(process.env.APPDATA || "", "Code - Insiders", "User", "mcp.json"), type: "global" }
33
+ ],
34
+ cline: [
35
+ { filePath: path.join(process.env.APPDATA || "", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
36
+ { filePath: path.join(process.env.APPDATA || "", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
37
+ ],
38
+ windsurf: [
39
+ { filePath: path.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
40
+ ],
41
+ roo: [
42
+ { filePath: path.join(process.env.APPDATA || "", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
43
+ { filePath: path.join(process.env.APPDATA || "", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
44
+ ],
45
+ "intellij-github-copilot": [
46
+ { filePath: path.join(process.env.LOCALAPPDATA || "", "github-copilot", "intellij", "mcp.json"), type: "global" }
47
+ ],
48
+ junie: [
49
+ { filePath: path.join(process.env.HOME || "", ".junie", "mcp", "mcp.json"), type: "global" }
50
+ ],
51
+ zed: [
52
+ { filePath: path.join(process.env.LOCALAPPDATA || "", "zed", "settings.json"), type: "global" },
53
+ { filePath: path.join(".zed", "settings.json"), type: "local" }
54
+ ],
55
+ gemini: [
56
+ { filePath: path.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
57
+ { filePath: path.join(".gemini", "settings.json"), type: "local" }
58
+ ]
59
+ };
60
+ static DARWIN_PATHS = {
61
+ claude: [
62
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Claude", "claude_desktop_config.json"), type: "global" }
63
+ ],
64
+ claude_code: [
65
+ { filePath: ".mcp.json", type: "local" }
66
+ ],
67
+ cursor: [
68
+ { filePath: path.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
69
+ { filePath: path.join(".cursor", "mcp.json"), type: "local" }
70
+ ],
71
+ vscode: [
72
+ { filePath: path.join(".vscode", "mcp.json"), type: "local" },
73
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "settings.json"), type: "global" },
74
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "mcp.json"), type: "global" },
75
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "settings.json"), type: "global" },
76
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "mcp.json"), type: "global" }
77
+ ],
78
+ cline: [
79
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
80
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
81
+ ],
82
+ windsurf: [
83
+ { filePath: path.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
84
+ ],
85
+ roo: [
86
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
87
+ { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
88
+ ],
89
+ "intellij-github-copilot": [
90
+ { filePath: path.join(process.env.HOME || "", ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
91
+ ],
92
+ junie: [
93
+ { filePath: path.join(process.env.HOME || "", ".junie", "mcp", "mcp.json"), type: "global" },
94
+ { filePath: path.join(".junie", "mcp", "mcp.json"), type: "local" }
95
+ ],
96
+ zed: [
97
+ { filePath: path.join(process.env.HOME || "", ".config", "zed", "settings.json"), type: "global" },
98
+ { filePath: path.join(".zed", "settings.json"), type: "local" }
99
+ ],
100
+ gemini: [
101
+ { filePath: path.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
102
+ { filePath: path.join(".gemini", "settings.json"), type: "local" }
103
+ ]
104
+ };
105
+ customApps = /* @__PURE__ */ new Map();
106
+ /**
107
+ * Get all MCP configuration file paths for a specific operating system
108
+ */
109
+ getPathsForOS(os) {
110
+ switch (os.toLowerCase()) {
111
+ case "win32":
112
+ case "windows":
113
+ return { ..._MCPPathRegistry.WINDOWS_PATHS };
114
+ case "darwin":
115
+ case "macos":
116
+ return { ..._MCPPathRegistry.DARWIN_PATHS };
117
+ default:
118
+ throw new Error(`Unsupported operating system: ${os}`);
119
+ }
120
+ }
121
+ /**
122
+ * Get MCP configuration file paths for a specific app on a specific OS
123
+ */
124
+ getPathsForApp(os, appName) {
125
+ const osPaths = this.getPathsForOS(os);
126
+ const appPaths = osPaths[appName];
127
+ if (!appPaths) {
128
+ throw new Error(`App '${appName}' not found for OS '${os}'`);
129
+ }
130
+ return [...appPaths];
131
+ }
132
+ /**
133
+ * Get all supported app names for a specific OS
134
+ */
135
+ getSupportedApps(os) {
136
+ const osPaths = this.getPathsForOS(os);
137
+ return Object.keys(osPaths);
138
+ }
139
+ /**
140
+ * Get all supported operating systems
141
+ */
142
+ getSupportedOperatingSystems() {
143
+ return ["win32", "darwin"];
144
+ }
145
+ /**
146
+ * Register a custom app with custom paths for a specific OS
147
+ */
148
+ registerCustomApp(os, appName, paths) {
149
+ if (!this.customApps.has(os)) {
150
+ this.customApps.set(os, {});
151
+ }
152
+ const osCustomApps = this.customApps.get(os);
153
+ osCustomApps[appName] = [...paths];
154
+ }
155
+ /**
156
+ * Get paths including custom registered apps
157
+ */
158
+ getPathsForOSWithCustom(os) {
159
+ const basePaths = this.getPathsForOS(os);
160
+ const customPaths = this.customApps.get(os) || {};
161
+ return { ...basePaths, ...customPaths };
162
+ }
163
+ };
8
164
 
9
- // src/services/mcp-config-linter-service.ts
165
+ // src/services/mcp-config-parser.ts
10
166
  import fs from "fs/promises";
11
167
  import { parse } from "jsonc-parser";
12
- var MCPConfigLinterService = class {
168
+ var MCPConfigParser = class {
13
169
  static {
14
- __name(this, "MCPConfigLinterService");
170
+ __name(this, "MCPConfigParser");
15
171
  }
16
172
  filePath;
17
173
  fileContents = null;
@@ -21,9 +177,17 @@ var MCPConfigLinterService = class {
21
177
  constructor(filePath) {
22
178
  this.filePath = filePath;
23
179
  }
24
- async parseFile() {
180
+ /**
181
+ * Parse the configuration file and return structured data
182
+ */
183
+ async parseConfigFile() {
25
184
  if (this.parsed) {
26
- return;
185
+ return {
186
+ raw: this.fileContentsData,
187
+ parsed: this.parsed,
188
+ valid: this.valid,
189
+ servers: await this.extractMCPServers(this.fileContentsData)
190
+ };
27
191
  }
28
192
  this.parsed = true;
29
193
  const fileContent = await this.getFileContent();
@@ -31,63 +195,630 @@ var MCPConfigLinterService = class {
31
195
  this.fileContentsData = JSON.parse(fileContent);
32
196
  if (typeof this.fileContentsData === "object") {
33
197
  this.valid = true;
34
- return;
35
198
  }
36
199
  } catch (e) {
37
200
  }
38
- try {
39
- this.fileContentsData = parse(fileContent);
40
- if (typeof this.fileContentsData === "object") {
41
- this.valid = true;
201
+ if (!this.valid) {
202
+ try {
203
+ this.fileContentsData = parse(fileContent);
204
+ if (typeof this.fileContentsData === "object") {
205
+ this.valid = true;
206
+ }
207
+ } catch (error) {
42
208
  }
43
- } catch (error) {
44
209
  }
210
+ if (!this.valid) {
211
+ throw new Error(`Failed to parse configuration file: ${this.filePath}`);
212
+ }
213
+ return {
214
+ raw: this.fileContentsData,
215
+ parsed: this.parsed,
216
+ valid: this.valid,
217
+ servers: await this.extractMCPServers(this.fileContentsData)
218
+ };
219
+ }
220
+ /**
221
+ * Extract MCP servers from parsed configuration data
222
+ */
223
+ async extractMCPServers(configData) {
224
+ if (!configData || typeof configData !== "object") {
225
+ return {};
226
+ }
227
+ if (configData.servers && typeof configData.servers === "object") {
228
+ return this.normalizeServerConfigs(configData.servers);
229
+ }
230
+ if (configData.mcp?.servers && typeof configData.mcp.servers === "object") {
231
+ return this.normalizeServerConfigs(configData.mcp.servers);
232
+ }
233
+ if (configData.mcpServers && typeof configData.mcpServers === "object") {
234
+ return this.normalizeServerConfigs(configData.mcpServers);
235
+ }
236
+ if (configData.context_servers && typeof configData.context_servers === "object") {
237
+ return this.normalizeServerConfigs(configData.context_servers);
238
+ }
239
+ return {};
240
+ }
241
+ /**
242
+ * Normalize server configurations to ensure consistent structure
243
+ */
244
+ normalizeServerConfigs(servers) {
245
+ const normalized = {};
246
+ for (const [serverName, serverConfig] of Object.entries(servers)) {
247
+ if (serverConfig && typeof serverConfig === "object") {
248
+ const env = serverConfig.env && typeof serverConfig.env === "object" ? serverConfig.env : void 0;
249
+ normalized[serverName] = {
250
+ name: serverName,
251
+ command: serverConfig.command || "",
252
+ args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
253
+ type: this.validateType(serverConfig.type) ? serverConfig.type : this.inferTransportType(serverConfig),
254
+ url: serverConfig.url,
255
+ env
256
+ };
257
+ }
258
+ }
259
+ return normalized;
260
+ }
261
+ /**
262
+ * Validate type value
263
+ */
264
+ validateType(type) {
265
+ return ["sse", "http", "stdio", "streamable-http"].includes(type);
266
+ }
267
+ /**
268
+ * Infer transport type from server configuration when type field is not explicitly set
269
+ */
270
+ inferTransportType(serverConfig) {
271
+ if (serverConfig.url && typeof serverConfig.url === "string") {
272
+ return "http";
273
+ }
274
+ if (Array.isArray(serverConfig.args)) {
275
+ const argsString = serverConfig.args.join(" ").toLowerCase();
276
+ if (argsString.includes("stdio")) {
277
+ return "stdio";
278
+ }
279
+ if (argsString.includes("http")) {
280
+ return "http";
281
+ }
282
+ if (argsString.includes("sse")) {
283
+ return "sse";
284
+ }
285
+ }
286
+ if (serverConfig.command && typeof serverConfig.command === "string") {
287
+ return "stdio";
288
+ }
289
+ return void 0;
290
+ }
291
+ /**
292
+ * Validate server configuration
293
+ */
294
+ validateServerConfig(serverConfig) {
295
+ if (!serverConfig || typeof serverConfig !== "object") {
296
+ return false;
297
+ }
298
+ if (!serverConfig.name || typeof serverConfig.name !== "string") {
299
+ return false;
300
+ }
301
+ if (!serverConfig.command || typeof serverConfig.command !== "string") {
302
+ return false;
303
+ }
304
+ return true;
305
+ }
306
+ /**
307
+ * Get supported configuration keys that the parser recognizes
308
+ */
309
+ getSupportedConfigKeys() {
310
+ return ["servers", "mcp.servers", "mcpServers", "context_servers"];
45
311
  }
312
+ /**
313
+ * Check if the configuration file has valid syntax
314
+ */
46
315
  async isValidSyntax() {
47
316
  try {
48
- await this.parseFile();
49
- return this.valid;
317
+ const configData = await this.parseConfigFile();
318
+ return configData.valid;
50
319
  } catch (error) {
51
320
  return false;
52
321
  }
53
322
  }
323
+ /**
324
+ * Count the number of MCP servers in the configuration
325
+ */
54
326
  async countMCPServers() {
55
327
  try {
56
- const mcpServers = await this.getMCPServers();
57
- return Object.keys(mcpServers).length;
328
+ const configData = await this.parseConfigFile();
329
+ return Object.keys(configData.servers).length;
58
330
  } catch (error) {
59
331
  return 0;
60
332
  }
61
333
  }
62
- async getMCPServers() {
63
- await this.parseFile();
64
- if (this.fileContentsData?.servers) {
65
- return this.fileContentsData.servers;
334
+ /**
335
+ * Get the raw file content
336
+ */
337
+ async getFileContent() {
338
+ if (this.fileContents) {
339
+ return this.fileContents;
66
340
  }
67
- if (this.fileContentsData?.mcp?.servers) {
68
- return this.fileContentsData.mcp.servers;
341
+ try {
342
+ this.fileContents = await fs.readFile(this.filePath, "utf-8");
343
+ return this.fileContents;
344
+ } catch (error) {
345
+ throw new Error(`Failed to read file: ${this.filePath}`);
69
346
  }
70
- if (this.fileContentsData?.mcpServers) {
71
- return this.fileContentsData.mcpServers;
347
+ }
348
+ };
349
+
350
+ // src/services/credential-detection-service.ts
351
+ var CredentialDetectionService = class {
352
+ static {
353
+ __name(this, "CredentialDetectionService");
354
+ }
355
+ /**
356
+ * Credential patterns grouped by risk level for easier maintenance
357
+ */
358
+ static CREDENTIAL_PATTERNS = {
359
+ high: [
360
+ // API Keys and Tokens
361
+ /api[_-]?key/i,
362
+ /api[_-]?token/i,
363
+ /access[_-]?token/i,
364
+ /secret[_-]?key/i,
365
+ /private[_-]?key/i,
366
+ // Authentication Tokens
367
+ /auth[_-]?token/i,
368
+ /bearer[_-]?token/i,
369
+ /jwt[_-]?token/i,
370
+ /oauth[_-]?token/i,
371
+ // Passwords
372
+ /password/i,
373
+ /passwd/i,
374
+ /pwd/i,
375
+ // Credentials
376
+ /credential/i,
377
+ /creds/i,
378
+ // Specific service patterns
379
+ /openai[_-]?api[_-]?key/i,
380
+ /anthropic[_-]?api[_-]?key/i,
381
+ /firecrawl[_-]?api[_-]?key/i,
382
+ /github[_-]?token/i,
383
+ /gitlab[_-]?token/i,
384
+ /bitbucket[_-]?token/i,
385
+ // Database passwords
386
+ /db[_-]?password/i,
387
+ /database[_-]?password/i,
388
+ /redis[_-]?password/i,
389
+ /postgres[_-]?password/i,
390
+ /mysql[_-]?password/i,
391
+ // Cloud services
392
+ /aws[_-]?secret[_-]?access[_-]?key/i,
393
+ /aws[_-]?access[_-]?key[_-]?id/i,
394
+ /azure[_-]?key/i,
395
+ /gcp[_-]?key/i,
396
+ /google[_-]?api[_-]?key/i,
397
+ /gemini[_-]?api[_-]?key/i,
398
+ /claude[_-]?api[_-]?key/i
399
+ ],
400
+ low: [
401
+ // Organization and Account IDs
402
+ /org[_-]?id/i,
403
+ /organization[_-]?id/i,
404
+ /account[_-]?id/i,
405
+ /user[_-]?id/i,
406
+ /openai[_-]?org[_-]?id/i
407
+ ]
408
+ };
409
+ /**
410
+ * Check if an environment variable name suggests it might contain credentials
411
+ */
412
+ static isPotentialCredential(envVarName) {
413
+ return this.CREDENTIAL_PATTERNS.high.some((pattern) => pattern.test(envVarName)) || this.CREDENTIAL_PATTERNS.low.some((pattern) => pattern.test(envVarName));
414
+ }
415
+ /**
416
+ * Analyze environment variables and return credential detection results
417
+ */
418
+ static analyzeEnvironmentVariables(env) {
419
+ if (!env || typeof env !== "object") {
420
+ return {
421
+ hasCredentials: false,
422
+ credentialVars: [],
423
+ riskLevel: "none"
424
+ };
72
425
  }
73
- if (this.fileContentsData?.context_servers) {
74
- return this.fileContentsData.context_servers;
426
+ const credentialVars = [];
427
+ for (const [name, value] of Object.entries(env)) {
428
+ if (this.isPotentialCredential(name)) {
429
+ credentialVars.push({
430
+ name,
431
+ value: this.maskValue(value),
432
+ riskLevel: this.assessRiskLevel(name)
433
+ });
434
+ }
75
435
  }
76
- return {};
436
+ const hasCredentials = credentialVars.length > 0;
437
+ const riskLevel = this.calculateOverallRiskLevel(credentialVars);
438
+ return {
439
+ hasCredentials,
440
+ credentialVars,
441
+ riskLevel
442
+ };
77
443
  }
78
- async getFileContent() {
79
- if (this.fileContents) {
80
- return this.fileContents;
444
+ /**
445
+ * Mask sensitive values for display (show only first and last character)
446
+ */
447
+ static maskValue(value) {
448
+ if (!value || value.length <= 2) {
449
+ return value;
450
+ }
451
+ const first = value.charAt(0);
452
+ const last = value.charAt(value.length - 1);
453
+ const maskedLength = Math.min(value.length - 2, 8);
454
+ return `${first}${"*".repeat(maskedLength)}${last}`;
455
+ }
456
+ /**
457
+ * Assess risk level for a specific credential variable
458
+ */
459
+ static assessRiskLevel(name) {
460
+ if (this.CREDENTIAL_PATTERNS.high.some((pattern) => pattern.test(name))) {
461
+ return "high";
462
+ }
463
+ if (this.CREDENTIAL_PATTERNS.low.some((pattern) => pattern.test(name))) {
464
+ return "low";
465
+ }
466
+ return "high";
467
+ }
468
+ /**
469
+ * Calculate overall risk level based on all credential variables
470
+ */
471
+ static calculateOverallRiskLevel(credentialVars) {
472
+ if (credentialVars.length === 0) {
473
+ return "none";
474
+ }
475
+ const hasHighRisk = credentialVars.some((v) => v.riskLevel === "high");
476
+ if (hasHighRisk) {
477
+ return "high";
478
+ }
479
+ return "low";
480
+ }
481
+ };
482
+
483
+ // src/services/directory-bubble-service.ts
484
+ import path2 from "path";
485
+ import fs2 from "fs/promises";
486
+ import { homedir } from "os";
487
+ var DirectoryBubbleService = class {
488
+ static {
489
+ __name(this, "DirectoryBubbleService");
490
+ }
491
+ /**
492
+ * Find a local MCP config file by bubbling up the directory tree
493
+ * @param localPath - The relative path to search for (e.g., '.vscode/mcp.json')
494
+ * @param startDir - The directory to start searching from
495
+ * @returns The absolute path to the found config file, or null if not found
496
+ */
497
+ async findLocalConfigInParentDirectories(localPath, startDir) {
498
+ try {
499
+ let currentDir = path2.resolve(startDir);
500
+ const homeDir = homedir();
501
+ const rootDir = "/";
502
+ let iterationCount = 0;
503
+ const maxIterations = 100;
504
+ const startDirResult = await this.checkDirectoryForConfig(currentDir, localPath);
505
+ if (startDirResult) {
506
+ return path2.join(currentDir, localPath);
507
+ }
508
+ while (currentDir !== homeDir && currentDir !== rootDir && iterationCount < maxIterations) {
509
+ const parentDir = this.getParentDirectory(currentDir);
510
+ if (!parentDir || parentDir === currentDir) {
511
+ break;
512
+ }
513
+ if (parentDir === currentDir || parentDir.length >= currentDir.length) {
514
+ break;
515
+ }
516
+ currentDir = parentDir;
517
+ iterationCount++;
518
+ const found = await this.checkDirectoryForConfig(currentDir, localPath);
519
+ if (found) {
520
+ return path2.join(currentDir, localPath);
521
+ }
522
+ }
523
+ return null;
524
+ } catch (error) {
525
+ return null;
81
526
  }
82
- this.fileContents = await fs.readFile(this.filePath, "utf-8");
83
- return this.fileContents;
527
+ }
528
+ /**
529
+ * Check if a config file exists in the specified directory
530
+ * @param dir - The directory to check
531
+ * @param configPath - The relative path to the config file
532
+ * @returns True if the config file exists and is accessible
533
+ */
534
+ async checkDirectoryForConfig(dir, configPath) {
535
+ try {
536
+ const fullPath = path2.join(dir, configPath);
537
+ await fs2.access(fullPath);
538
+ return true;
539
+ } catch (error) {
540
+ return false;
541
+ }
542
+ }
543
+ /**
544
+ * Get the parent directory of the specified directory
545
+ * @param dir - The directory to get the parent of
546
+ * @returns The parent directory path, or null if already at root
547
+ */
548
+ getParentDirectory(dir) {
549
+ const parent = path2.dirname(dir);
550
+ return parent === dir ? null : parent;
551
+ }
552
+ };
553
+
554
+ // src/utils/url-utils.ts
555
+ function extractHostname(urlString) {
556
+ try {
557
+ let urlToParse = urlString;
558
+ if (!urlToParse.includes("://")) {
559
+ urlToParse = `http://${urlToParse}`;
560
+ }
561
+ const url = new URL(urlToParse);
562
+ return url.hostname;
563
+ } catch (error) {
564
+ return urlString;
565
+ }
566
+ }
567
+ __name(extractHostname, "extractHostname");
568
+
569
+ // src/services/mcp-config-service.ts
570
+ var MCPConfigService = class {
571
+ static {
572
+ __name(this, "MCPConfigService");
573
+ }
574
+ pathRegistry;
575
+ currentOS;
576
+ debug;
577
+ directoryBubbleService;
578
+ enableDirectoryBubbling;
579
+ constructor(options = {}) {
580
+ this.pathRegistry = new MCPPathRegistry();
581
+ this.currentOS = platform();
582
+ this.debug = util.debuglog("ls-mcp");
583
+ this.directoryBubbleService = new DirectoryBubbleService();
584
+ this.enableDirectoryBubbling = options.enableDirectoryBubbling ?? false;
585
+ }
586
+ /**
587
+ * Get MCP configuration files for a specific AI application on the current OS
588
+ */
589
+ getConfigFilesPerApp(appName) {
590
+ try {
591
+ return this.pathRegistry.getPathsForApp(this.currentOS, appName);
592
+ } catch (error) {
593
+ throw new Error(`Failed to get config files for app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
594
+ }
595
+ }
596
+ /**
597
+ * Get MCP configuration files for all AI applications on the current OS
598
+ */
599
+ getAllConfigFiles() {
600
+ try {
601
+ return this.pathRegistry.getPathsForOS(this.currentOS);
602
+ } catch (error) {
603
+ throw new Error(`Failed to get all config files: ${error instanceof Error ? error.message : "Unknown error"}`);
604
+ }
605
+ }
606
+ /**
607
+ * Get MCP servers configured for a specific AI application on the current OS
608
+ */
609
+ async getMCPServersPerApp(appName) {
610
+ try {
611
+ const appPaths = this.getConfigFilesPerApp(appName);
612
+ const allServers = [];
613
+ for (const filePath of appPaths) {
614
+ const servers = await this.parseConfigFileForServers(filePath.filePath);
615
+ allServers.push(...servers);
616
+ }
617
+ return allServers;
618
+ } catch (error) {
619
+ throw new Error(`Failed to get MCP servers for app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
620
+ }
621
+ }
622
+ /**
623
+ * Get MCP servers configured for all AI applications on the current OS
624
+ */
625
+ async getAllMCPServers() {
626
+ try {
627
+ const allApps = this.pathRegistry.getSupportedApps(this.currentOS);
628
+ const allServers = {};
629
+ for (const appName of allApps) {
630
+ try {
631
+ allServers[appName] = await this.getMCPServersPerApp(appName);
632
+ } catch (error) {
633
+ this.debug(`Failed to get servers for app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
634
+ allServers[appName] = [];
635
+ }
636
+ }
637
+ return allServers;
638
+ } catch (error) {
639
+ throw new Error(`Failed to get all MCP servers: ${error instanceof Error ? error.message : "Unknown error"}`);
640
+ }
641
+ }
642
+ /**
643
+ * Get metadata for all supported AI applications on the current OS
644
+ */
645
+ getSupportedApps() {
646
+ try {
647
+ const appNames = this.pathRegistry.getSupportedApps(this.currentOS);
648
+ const appPaths = this.pathRegistry.getPathsForOS(this.currentOS);
649
+ return appNames.map((appName) => ({
650
+ name: appName,
651
+ friendlyName: this.getFriendlyName(appName),
652
+ paths: appPaths[appName] || []
653
+ }));
654
+ } catch (error) {
655
+ throw new Error(`Failed to get supported apps: ${error instanceof Error ? error.message : "Unknown error"}`);
656
+ }
657
+ }
658
+ /**
659
+ * Get all supported operating systems
660
+ */
661
+ getSupportedOperatingSystems() {
662
+ return this.pathRegistry.getSupportedOperatingSystems();
663
+ }
664
+ /**
665
+ * Validate if a configuration file exists and is parsable
666
+ */
667
+ async validateConfigFile(filePath) {
668
+ try {
669
+ await fs3.access(filePath);
670
+ const parser = this.createParser(filePath);
671
+ return await parser.isValidSyntax();
672
+ } catch (error) {
673
+ return false;
674
+ }
675
+ }
676
+ /**
677
+ * Create a parser instance (can be overridden for testing)
678
+ */
679
+ createParser(filePath) {
680
+ return new MCPConfigParser(filePath);
681
+ }
682
+ /**
683
+ * Get MCP file groups with resolved paths and server information
684
+ */
685
+ async getMCPFileGroups() {
686
+ try {
687
+ const appPaths = this.getAllConfigFiles();
688
+ const mcpFilesPathsData = {};
689
+ for (const [groupName, paths] of Object.entries(appPaths)) {
690
+ mcpFilesPathsData[groupName] = {
691
+ name: groupName,
692
+ friendlyName: this.getFriendlyName(groupName),
693
+ paths: [],
694
+ stats: { serversCount: 0 }
695
+ };
696
+ const uniqueFilePaths = /* @__PURE__ */ new Set();
697
+ let totalServersCount = 0;
698
+ for (const filePathData of paths) {
699
+ let resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
700
+ let absolutePath = path3.resolve(resolvedPath);
701
+ if (filePathData.type === "local" && this.enableDirectoryBubbling) {
702
+ try {
703
+ await fs3.access(resolvedPath);
704
+ } catch (error) {
705
+ const bubbledPath = await this.directoryBubbleService.findLocalConfigInParentDirectories(
706
+ filePathData.filePath,
707
+ process.cwd()
708
+ );
709
+ if (bubbledPath) {
710
+ resolvedPath = bubbledPath;
711
+ absolutePath = path3.resolve(resolvedPath);
712
+ }
713
+ }
714
+ }
715
+ if (uniqueFilePaths.has(absolutePath)) {
716
+ continue;
717
+ }
718
+ uniqueFilePaths.add(absolutePath);
719
+ try {
720
+ await fs3.access(resolvedPath);
721
+ const parser = this.createParser(resolvedPath);
722
+ const parsable = await parser.isValidSyntax();
723
+ filePathData.parsable = parsable;
724
+ if (parsable) {
725
+ const configData = await parser.parseConfigFile();
726
+ const servers = await this.convertToMCPServerInfo(configData.servers || {});
727
+ filePathData.servers = servers;
728
+ totalServersCount += servers.length;
729
+ }
730
+ mcpFilesPathsData[groupName].paths.push(filePathData);
731
+ } catch (error) {
732
+ this.debug(`Skipping file ${resolvedPath}: ${error instanceof Error ? error.message : "Unknown error"}`);
733
+ }
734
+ }
735
+ if (mcpFilesPathsData[groupName] && mcpFilesPathsData[groupName].stats) {
736
+ mcpFilesPathsData[groupName].stats.serversCount = totalServersCount;
737
+ }
738
+ }
739
+ return mcpFilesPathsData;
740
+ } catch (error) {
741
+ throw new Error(`Failed to get MCP file groups: ${error instanceof Error ? error.message : "Unknown error"}`);
742
+ }
743
+ }
744
+ /**
745
+ * Register a custom app with custom paths for the current OS
746
+ */
747
+ registerCustomApp(appName, paths) {
748
+ try {
749
+ this.pathRegistry.registerCustomApp(this.currentOS, appName, paths);
750
+ } catch (error) {
751
+ throw new Error(`Failed to register custom app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
752
+ }
753
+ }
754
+ /**
755
+ * Parse a configuration file and return server information
756
+ */
757
+ async parseConfigFileForServers(filePath) {
758
+ try {
759
+ const parser = this.createParser(filePath);
760
+ const configData = await parser.parseConfigFile();
761
+ return await this.convertToMCPServerInfo(configData.servers || {});
762
+ } catch (error) {
763
+ this.debug(`Failed to parse config file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
764
+ return [];
765
+ }
766
+ }
767
+ /**
768
+ * Convert parsed server configs to MCPServerInfo format
769
+ */
770
+ async convertToMCPServerInfo(servers) {
771
+ const serverInfos = [];
772
+ for (const [serverName, serverConfig] of Object.entries(servers)) {
773
+ if (serverConfig && typeof serverConfig === "object") {
774
+ let source;
775
+ if (serverConfig.url) {
776
+ source = extractHostname(serverConfig.url);
777
+ } else {
778
+ source = serverConfig.command || "";
779
+ }
780
+ serverInfos.push({
781
+ name: serverName,
782
+ command: serverConfig.command || "",
783
+ args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
784
+ transport: serverConfig.type === "streamable-http" ? "http" : serverConfig.type,
785
+ // Map streamable-http to http
786
+ type: serverConfig.type,
787
+ source,
788
+ env: serverConfig.env,
789
+ status: "stopped",
790
+ // Default status, will be updated by server manager
791
+ credentials: CredentialDetectionService.analyzeEnvironmentVariables(serverConfig.env)
792
+ });
793
+ }
794
+ }
795
+ return serverInfos;
796
+ }
797
+ /**
798
+ * Get friendly name for an app
799
+ */
800
+ getFriendlyName(appName) {
801
+ const friendlyNames = {
802
+ claude: "Claude Desktop",
803
+ claude_code: "Claude Code",
804
+ cursor: "Cursor",
805
+ vscode: "VS Code",
806
+ cline: "Cline",
807
+ windsurf: "Windsurf",
808
+ roo: "Roo",
809
+ "intellij-github-copilot": "IntelliJ GitHub Copilot",
810
+ junie: "IntelliJ Junie",
811
+ zed: "Zed",
812
+ gemini: "Gemini CLI"
813
+ };
814
+ return friendlyNames[appName] || appName;
84
815
  }
85
816
  };
86
817
 
87
818
  // src/services/mcp-server-manager-service.ts
88
- import path from "path";
819
+ import path4 from "path";
89
820
  import { execSync } from "child_process";
90
- import { platform } from "os";
821
+ import { platform as platform2 } from "os";
91
822
  var MCPServerManagerService = class {
92
823
  static {
93
824
  __name(this, "MCPServerManagerService");
@@ -107,14 +838,14 @@ var MCPServerManagerService = class {
107
838
  if (serverConfig?.type && serverConfig.type === "sse") {
108
839
  this.transport = "sse";
109
840
  }
110
- if (serverConfig?.type && serverConfig.type === "http") {
841
+ if (serverConfig?.type && (serverConfig.type === "http" || serverConfig.type === "streamable-http")) {
111
842
  this.transport = "http";
112
843
  }
113
844
  if (serverConfig?.type && serverConfig.type === "stdio") {
114
845
  this.transport = "stdio";
115
846
  }
116
847
  if (serverConfig.url) {
117
- this.source = serverConfig.url;
848
+ this.source = extractHostname(serverConfig.url);
118
849
  this.transport = "http";
119
850
  } else {
120
851
  const fullCommand = [serverConfig.command, ...serverConfig.args || []].join(" ");
@@ -143,7 +874,7 @@ var MCPServerManagerService = class {
143
874
  isRunning() {
144
875
  try {
145
876
  let psOutput;
146
- if (platform() === "win32") {
877
+ if (platform2() === "win32") {
147
878
  psOutput = execSync('powershell -Command "Get-CimInstance -ClassName Win32_Process | Select-Object ProcessId,Name,CommandLine,ParentProcessId | ConvertTo-Csv -NoTypeInformation"', {
148
879
  encoding: "utf8",
149
880
  timeout: 5e3
@@ -161,7 +892,7 @@ var MCPServerManagerService = class {
161
892
  let pid;
162
893
  let ppid;
163
894
  let commandLine;
164
- if (platform() === "win32") {
895
+ if (platform2() === "win32") {
165
896
  if (processLine.startsWith('"ProcessId"') || processLine.startsWith("ProcessId")) continue;
166
897
  const parts = this.parseCSVLine(processLine);
167
898
  if (parts.length < 4) continue;
@@ -184,7 +915,7 @@ var MCPServerManagerService = class {
184
915
  for (const [pid, processData] of processMap) {
185
916
  const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid);
186
917
  let commandMatchWin32 = false;
187
- if (platform() === "win32") {
918
+ if (platform2() === "win32") {
188
919
  let commandTokensOnWin32 = processData.commandTokens;
189
920
  if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith("cmd")) {
190
921
  commandTokensOnWin32 = commandTokensOnWin32.slice(1);
@@ -295,9 +1026,9 @@ var MCPServerManagerService = class {
295
1026
  return true;
296
1027
  }
297
1028
  getBaseCommand(fullCommandPath) {
298
- let baseCommand = path.basename(fullCommandPath);
299
- if (platform() === "win32") {
300
- baseCommand = path.basename(fullCommandPath, ".exe");
1029
+ let baseCommand = path4.basename(fullCommandPath);
1030
+ if (platform2() === "win32") {
1031
+ baseCommand = path4.basename(fullCommandPath, ".exe");
301
1032
  }
302
1033
  baseCommand = baseCommand.toLowerCase();
303
1034
  return baseCommand;
@@ -478,240 +1209,58 @@ var MCPServerManagerService = class {
478
1209
  }
479
1210
  };
480
1211
 
481
- // src/utils/os-paths.ts
482
- import path2 from "path";
483
- var appData = process.env.APPDATA || "";
484
- var localAppData = process.env.LOCALAPPDATA || "";
485
- var homeDir = process.env.HOME || "";
486
- function getWindowsPaths() {
487
- return {
488
- claude: [
489
- { filePath: path2.join(appData, "Claude", "claude_desktop_config.json"), type: "global" }
490
- ],
491
- claude_code: [
492
- { filePath: ".mcp.json", type: "local" }
493
- ],
494
- cursor: [
495
- { filePath: path2.join(homeDir, ".cursor", "mcp.json"), type: "global" },
496
- { filePath: path2.join(".cursor", "mcp.json"), type: "local" }
497
- ],
498
- vscode: [
499
- { filePath: path2.join(".vscode", "mcp.json"), type: "local" },
500
- { filePath: path2.join(appData, "Code", "User", "settings.json"), type: "global" },
501
- { filePath: path2.join(appData, "Code - Insiders", "User", "settings.json"), type: "global" },
502
- { filePath: path2.join(appData, "Code", "User", "mcp.json"), type: "global" },
503
- { filePath: path2.join(appData, "Code - Insiders", "User", "mcp.json"), type: "global" }
504
- ],
505
- cline: [
506
- { filePath: path2.join(appData, "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
507
- { filePath: path2.join(appData, "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
508
- ],
509
- windsurf: [
510
- { filePath: path2.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
511
- ],
512
- roo: [
513
- { filePath: path2.join(appData, "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
514
- { filePath: path2.join(appData, "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
515
- ],
516
- "intellij-github-copilot": [
517
- { filePath: path2.join(localAppData, "github-copilot", "intellij", "mcp.json"), type: "global" }
518
- ],
519
- junie: [
520
- { filePath: path2.join(homeDir, ".junie", "mcp", "mcp.json"), type: "global" }
521
- ],
522
- zed: [
523
- { filePath: path2.join(localAppData, "zed", "settings.json"), type: "global" },
524
- { filePath: path2.join(".zed", "settings.json"), type: "local" }
525
- ],
526
- gemini: [
527
- { filePath: path2.join(homeDir, ".gemini", "settings.json"), type: "global" },
528
- { filePath: path2.join(".gemini", "settings.json"), type: "local" }
529
- ]
530
- };
531
- }
532
- __name(getWindowsPaths, "getWindowsPaths");
533
- function getDarwinPaths() {
534
- return {
535
- claude: [
536
- { filePath: path2.join(homeDir, "Library", "Application Support", "Claude", "claude_desktop_config.json"), type: "global" }
537
- ],
538
- claude_code: [
539
- { filePath: ".mcp.json", type: "local" }
540
- ],
541
- cursor: [
542
- { filePath: path2.join(homeDir, ".cursor", "mcp.json"), type: "global" },
543
- { filePath: path2.join(".cursor", "mcp.json"), type: "local" }
544
- ],
545
- vscode: [
546
- { filePath: path2.join(".vscode", "mcp.json"), type: "local" },
547
- { filePath: path2.join(homeDir, "Library", "Application Support", "Code", "User", "settings.json"), type: "global" },
548
- { filePath: path2.join(homeDir, "Library", "Application Support", "Code", "User", "mcp.json"), type: "global" },
549
- { filePath: path2.join(homeDir, "Library", "Application Support", "Code - Insiders", "User", "settings.json"), type: "global" },
550
- { filePath: path2.join(homeDir, "Library", "Application Support", "Code - Insiders", "User", "mcp.json"), type: "global" }
551
- ],
552
- cline: [
553
- { filePath: path2.join(homeDir, "Library", "Application Support", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
554
- { filePath: path2.join(homeDir, "Library", "Application Support", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
555
- ],
556
- windsurf: [
557
- { filePath: path2.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
558
- ],
559
- roo: [
560
- { filePath: path2.join(homeDir, "Library", "Application Support", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
561
- { filePath: path2.join(homeDir, "Library", "Application Support", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
562
- ],
563
- "intellij-github-copilot": [
564
- { filePath: path2.join(homeDir, ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
565
- ],
566
- junie: [
567
- { filePath: path2.join(homeDir, ".junie", "mcp", "mcp.json"), type: "global" },
568
- { filePath: path2.join(".junie", "mcp", "mcp.json"), type: "local" }
569
- ],
570
- zed: [
571
- { filePath: path2.join(homeDir, ".config", "zed", "settings.json"), type: "global" },
572
- { filePath: path2.join(".zed", "settings.json"), type: "local" }
573
- ],
574
- gemini: [
575
- { filePath: path2.join(homeDir, ".gemini", "settings.json"), type: "global" },
576
- { filePath: path2.join(".gemini", "settings.json"), type: "local" }
577
- ]
578
- };
579
- }
580
- __name(getDarwinPaths, "getDarwinPaths");
581
-
582
1212
  // src/main.ts
583
- var osSpecificPaths = {};
584
- if (platform2() === "win32") {
585
- osSpecificPaths = getWindowsPaths();
586
- } else {
587
- osSpecificPaths = getDarwinPaths();
588
- }
589
1213
  var MCPFiles = class {
590
1214
  static {
591
1215
  __name(this, "MCPFiles");
592
1216
  }
593
- mcpFilePathGroups = {
594
- claude: {
595
- name: "claude-desktop",
596
- friendlyName: "Claude Desktop",
597
- paths: osSpecificPaths["claude"]
598
- },
599
- claude_code: {
600
- name: "claude-code",
601
- friendlyName: "Claude Code",
602
- paths: osSpecificPaths["claude_code"]
603
- },
604
- cursor: {
605
- name: "cursor",
606
- friendlyName: "Cursor",
607
- paths: osSpecificPaths["cursor"]
608
- },
609
- vscode: {
610
- name: "vscode",
611
- friendlyName: "VS Code",
612
- paths: osSpecificPaths["vscode"]
613
- },
614
- cline: {
615
- name: "cline",
616
- friendlyName: "Cline",
617
- paths: osSpecificPaths["cline"]
618
- },
619
- windsurf: {
620
- name: "windsurf",
621
- friendlyName: "Windsurf",
622
- paths: osSpecificPaths["windsurf"]
623
- },
624
- roo: {
625
- name: "roo",
626
- friendlyName: "Roo",
627
- paths: osSpecificPaths["roo"]
628
- },
629
- "intellij-github-copilot": {
630
- name: "intellij-github-copilot",
631
- friendlyName: "IntelliJ GitHub Copilot",
632
- paths: osSpecificPaths["intellij-github-copilot"]
633
- },
634
- junie: {
635
- name: "junie",
636
- friendlyName: "IntelliJ Junie",
637
- paths: osSpecificPaths["junie"]
638
- },
639
- zed: {
640
- name: "zed",
641
- friendlyName: "Zed",
642
- paths: osSpecificPaths["zed"]
643
- },
644
- gemini: {
645
- name: "gemini-cli",
646
- friendlyName: "Gemini CLI",
647
- paths: osSpecificPaths.gemini
648
- }
649
- };
650
- constructor(mcpFilePathGroups) {
651
- this.mcpFilePathGroups = mcpFilePathGroups || this.mcpFilePathGroups;
1217
+ mcpConfigService;
1218
+ constructor() {
1219
+ this.mcpConfigService = new MCPConfigService({ enableDirectoryBubbling: true });
652
1220
  }
1221
+ /**
1222
+ * Find and process all MCP configuration files
1223
+ */
653
1224
  async findFiles() {
654
- const mcpFilesPathsData = {};
655
- for (const groupName of Object.keys(this.mcpFilePathGroups)) {
656
- const clientsGroup = this.mcpFilePathGroups[groupName];
657
- mcpFilesPathsData[groupName] = {
658
- name: clientsGroup.name,
659
- friendlyName: clientsGroup.friendlyName,
660
- paths: [],
661
- stats: {}
662
- };
663
- const uniqueFilePaths = /* @__PURE__ */ new Set();
664
- for (const filePathData of clientsGroup.paths) {
665
- const resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
666
- const absolutePath = path3.resolve(resolvedPath);
667
- if (uniqueFilePaths.has(absolutePath)) {
668
- continue;
669
- }
670
- uniqueFilePaths.add(absolutePath);
671
- try {
672
- await fs2.access(resolvedPath);
673
- const MCPConfigLinter = new MCPConfigLinterService(resolvedPath);
674
- const parsable = await MCPConfigLinter.isValidSyntax();
675
- filePathData.parsable = parsable;
676
- const mcpServersData = [];
677
- const mcpServersFromConfig = await MCPConfigLinter.getMCPServers();
678
- for (const serverName of Object.keys(mcpServersFromConfig)) {
679
- const serverConfigRaw = mcpServersFromConfig[serverName];
680
- const serverConfig = {
681
- name: serverName,
682
- command: serverConfigRaw.command || "",
683
- args: serverConfigRaw.args,
684
- url: serverConfigRaw.url,
685
- transport: serverConfigRaw.transport,
686
- type: serverConfigRaw.type,
687
- env: serverConfigRaw.env
688
- };
689
- const MCPServerManager = new MCPServerManagerService(serverConfig);
690
- const mcpServerProcessDetection = MCPServerManager.isRunning();
691
- let mcpServerProcess = false;
692
- if (mcpServerProcessDetection) {
693
- if (typeof mcpServerProcessDetection === "object" && mcpServerProcessDetection.estimatedProduct === clientsGroup.name) {
694
- mcpServerProcess = true;
1225
+ try {
1226
+ const mcpFilesPathsData = await this.mcpConfigService.getMCPFileGroups();
1227
+ for (const groupName of Object.keys(mcpFilesPathsData)) {
1228
+ const group = mcpFilesPathsData[groupName];
1229
+ for (const filePathData of group.paths) {
1230
+ if (filePathData.servers && filePathData.servers.length > 0) {
1231
+ for (const server of filePathData.servers) {
1232
+ const serverConfig = {
1233
+ name: server.name,
1234
+ command: server.command,
1235
+ args: server.args,
1236
+ transport: server.transport,
1237
+ // transport is always populated from type in the data layer
1238
+ type: server.type,
1239
+ env: server.env
1240
+ };
1241
+ const serverManager = new MCPServerManagerService(serverConfig);
1242
+ const processDetection = serverManager.isRunning();
1243
+ let isRunning = false;
1244
+ if (processDetection) {
1245
+ if (typeof processDetection === "object" && processDetection.estimatedProduct === group.name) {
1246
+ isRunning = true;
1247
+ }
695
1248
  }
1249
+ server.status = isRunning ? "running" : "stopped";
696
1250
  }
697
- mcpServersData.push({
698
- name: MCPServerManager.getName(),
699
- command: MCPServerManager.getCmd(),
700
- args: MCPServerManager.getArgs(),
701
- source: MCPServerManager.getSource(),
702
- transport: MCPServerManager.getTransport(),
703
- env: MCPServerManager.getEnv(),
704
- status: mcpServerProcess ? "running" : "stopped"
705
- });
706
1251
  }
707
- filePathData.servers = mcpServersData;
708
- mcpFilesPathsData[groupName]["stats"]["serversCount"] = await MCPConfigLinter.countMCPServers();
709
- mcpFilesPathsData[groupName].paths.push(filePathData);
710
- } catch (error) {
711
1252
  }
712
1253
  }
1254
+ return mcpFilesPathsData;
1255
+ } catch (error) {
1256
+ throw new Error(`Failed to find MCP files: ${error instanceof Error ? error.message : "Unknown error"}`);
713
1257
  }
714
- return mcpFilesPathsData;
1258
+ }
1259
+ /**
1260
+ * Get MCP configuration service instance for advanced operations
1261
+ */
1262
+ getMCPConfigService() {
1263
+ return this.mcpConfigService;
715
1264
  }
716
1265
  };
717
1266
  export {