ls-mcp 1.9.0 → 1.10.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.cjs CHANGED
@@ -34,16 +34,174 @@ __export(main_exports, {
34
34
  MCPFiles: () => MCPFiles
35
35
  });
36
36
  module.exports = __toCommonJS(main_exports);
37
- var import_promises2 = __toESM(require("fs/promises"), 1);
38
- var import_node_os2 = require("os");
37
+
38
+ // src/services/mcp-config-service.ts
39
+ var import_node_os = require("os");
39
40
  var import_node_path2 = __toESM(require("path"), 1);
41
+ var import_promises2 = __toESM(require("fs/promises"), 1);
42
+ var import_node_util = __toESM(require("util"), 1);
43
+
44
+ // src/services/mcp-path-registry.ts
45
+ var import_node_path = __toESM(require("path"), 1);
46
+ var MCPPathRegistry = class _MCPPathRegistry {
47
+ static {
48
+ __name(this, "MCPPathRegistry");
49
+ }
50
+ static WINDOWS_PATHS = {
51
+ claude: [
52
+ { filePath: import_node_path.default.join(process.env.APPDATA || "", "Claude", "claude_desktop_config.json"), type: "global" }
53
+ ],
54
+ claude_code: [
55
+ { filePath: ".mcp.json", type: "local" }
56
+ ],
57
+ cursor: [
58
+ { filePath: import_node_path.default.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
59
+ { filePath: import_node_path.default.join(".cursor", "mcp.json"), type: "local" }
60
+ ],
61
+ vscode: [
62
+ { filePath: import_node_path.default.join(".vscode", "mcp.json"), type: "local" },
63
+ { filePath: import_node_path.default.join(process.env.APPDATA || "", "Code", "User", "settings.json"), type: "global" },
64
+ { filePath: import_node_path.default.join(process.env.APPDATA || "", "Code - Insiders", "User", "settings.json"), type: "global" },
65
+ { filePath: import_node_path.default.join(process.env.APPDATA || "", "Code", "User", "mcp.json"), type: "global" },
66
+ { filePath: import_node_path.default.join(process.env.APPDATA || "", "Code - Insiders", "User", "mcp.json"), type: "global" }
67
+ ],
68
+ cline: [
69
+ { filePath: import_node_path.default.join(process.env.APPDATA || "", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
70
+ { filePath: import_node_path.default.join(process.env.APPDATA || "", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
71
+ ],
72
+ windsurf: [
73
+ { filePath: import_node_path.default.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
74
+ ],
75
+ roo: [
76
+ { filePath: import_node_path.default.join(process.env.APPDATA || "", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
77
+ { filePath: import_node_path.default.join(process.env.APPDATA || "", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
78
+ ],
79
+ "intellij-github-copilot": [
80
+ { filePath: import_node_path.default.join(process.env.LOCALAPPDATA || "", "github-copilot", "intellij", "mcp.json"), type: "global" }
81
+ ],
82
+ junie: [
83
+ { filePath: import_node_path.default.join(process.env.HOME || "", ".junie", "mcp", "mcp.json"), type: "global" }
84
+ ],
85
+ zed: [
86
+ { filePath: import_node_path.default.join(process.env.LOCALAPPDATA || "", "zed", "settings.json"), type: "global" },
87
+ { filePath: import_node_path.default.join(".zed", "settings.json"), type: "local" }
88
+ ],
89
+ gemini: [
90
+ { filePath: import_node_path.default.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
91
+ { filePath: import_node_path.default.join(".gemini", "settings.json"), type: "local" }
92
+ ]
93
+ };
94
+ static DARWIN_PATHS = {
95
+ claude: [
96
+ { filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Claude", "claude_desktop_config.json"), type: "global" }
97
+ ],
98
+ claude_code: [
99
+ { filePath: ".mcp.json", type: "local" }
100
+ ],
101
+ cursor: [
102
+ { filePath: import_node_path.default.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
103
+ { filePath: import_node_path.default.join(".cursor", "mcp.json"), type: "local" }
104
+ ],
105
+ vscode: [
106
+ { filePath: import_node_path.default.join(".vscode", "mcp.json"), type: "local" },
107
+ { filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "settings.json"), type: "global" },
108
+ { filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "mcp.json"), type: "global" },
109
+ { filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "settings.json"), type: "global" },
110
+ { filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "mcp.json"), type: "global" }
111
+ ],
112
+ cline: [
113
+ { filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
114
+ { filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
115
+ ],
116
+ windsurf: [
117
+ { filePath: import_node_path.default.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
118
+ ],
119
+ roo: [
120
+ { filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
121
+ { filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
122
+ ],
123
+ "intellij-github-copilot": [
124
+ { filePath: import_node_path.default.join(process.env.HOME || "", ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
125
+ ],
126
+ junie: [
127
+ { filePath: import_node_path.default.join(process.env.HOME || "", ".junie", "mcp", "mcp.json"), type: "global" },
128
+ { filePath: import_node_path.default.join(".junie", "mcp", "mcp.json"), type: "local" }
129
+ ],
130
+ zed: [
131
+ { filePath: import_node_path.default.join(process.env.HOME || "", ".config", "zed", "settings.json"), type: "global" },
132
+ { filePath: import_node_path.default.join(".zed", "settings.json"), type: "local" }
133
+ ],
134
+ gemini: [
135
+ { filePath: import_node_path.default.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
136
+ { filePath: import_node_path.default.join(".gemini", "settings.json"), type: "local" }
137
+ ]
138
+ };
139
+ customApps = /* @__PURE__ */ new Map();
140
+ /**
141
+ * Get all MCP configuration file paths for a specific operating system
142
+ */
143
+ getPathsForOS(os) {
144
+ switch (os.toLowerCase()) {
145
+ case "win32":
146
+ case "windows":
147
+ return { ..._MCPPathRegistry.WINDOWS_PATHS };
148
+ case "darwin":
149
+ case "macos":
150
+ return { ..._MCPPathRegistry.DARWIN_PATHS };
151
+ default:
152
+ throw new Error(`Unsupported operating system: ${os}`);
153
+ }
154
+ }
155
+ /**
156
+ * Get MCP configuration file paths for a specific app on a specific OS
157
+ */
158
+ getPathsForApp(os, appName) {
159
+ const osPaths = this.getPathsForOS(os);
160
+ const appPaths = osPaths[appName];
161
+ if (!appPaths) {
162
+ throw new Error(`App '${appName}' not found for OS '${os}'`);
163
+ }
164
+ return [...appPaths];
165
+ }
166
+ /**
167
+ * Get all supported app names for a specific OS
168
+ */
169
+ getSupportedApps(os) {
170
+ const osPaths = this.getPathsForOS(os);
171
+ return Object.keys(osPaths);
172
+ }
173
+ /**
174
+ * Get all supported operating systems
175
+ */
176
+ getSupportedOperatingSystems() {
177
+ return ["win32", "darwin"];
178
+ }
179
+ /**
180
+ * Register a custom app with custom paths for a specific OS
181
+ */
182
+ registerCustomApp(os, appName, paths) {
183
+ if (!this.customApps.has(os)) {
184
+ this.customApps.set(os, {});
185
+ }
186
+ const osCustomApps = this.customApps.get(os);
187
+ osCustomApps[appName] = [...paths];
188
+ }
189
+ /**
190
+ * Get paths including custom registered apps
191
+ */
192
+ getPathsForOSWithCustom(os) {
193
+ const basePaths = this.getPathsForOS(os);
194
+ const customPaths = this.customApps.get(os) || {};
195
+ return { ...basePaths, ...customPaths };
196
+ }
197
+ };
40
198
 
41
- // src/services/mcp-config-linter-service.ts
199
+ // src/services/mcp-config-parser.ts
42
200
  var import_promises = __toESM(require("fs/promises"), 1);
43
201
  var import_jsonc_parser = require("jsonc-parser");
44
- var MCPConfigLinterService = class {
202
+ var MCPConfigParser = class {
45
203
  static {
46
- __name(this, "MCPConfigLinterService");
204
+ __name(this, "MCPConfigParser");
47
205
  }
48
206
  filePath;
49
207
  fileContents = null;
@@ -53,9 +211,17 @@ var MCPConfigLinterService = class {
53
211
  constructor(filePath) {
54
212
  this.filePath = filePath;
55
213
  }
56
- async parseFile() {
214
+ /**
215
+ * Parse the configuration file and return structured data
216
+ */
217
+ async parseConfigFile() {
57
218
  if (this.parsed) {
58
- return;
219
+ return {
220
+ raw: this.fileContentsData,
221
+ parsed: this.parsed,
222
+ valid: this.valid,
223
+ servers: await this.extractMCPServers(this.fileContentsData)
224
+ };
59
225
  }
60
226
  this.parsed = true;
61
227
  const fileContent = await this.getFileContent();
@@ -63,63 +229,519 @@ var MCPConfigLinterService = class {
63
229
  this.fileContentsData = JSON.parse(fileContent);
64
230
  if (typeof this.fileContentsData === "object") {
65
231
  this.valid = true;
66
- return;
67
232
  }
68
233
  } catch (e) {
69
234
  }
70
- try {
71
- this.fileContentsData = (0, import_jsonc_parser.parse)(fileContent);
72
- if (typeof this.fileContentsData === "object") {
73
- this.valid = true;
235
+ if (!this.valid) {
236
+ try {
237
+ this.fileContentsData = (0, import_jsonc_parser.parse)(fileContent);
238
+ if (typeof this.fileContentsData === "object") {
239
+ this.valid = true;
240
+ }
241
+ } catch (error) {
74
242
  }
75
- } catch (error) {
76
243
  }
244
+ if (!this.valid) {
245
+ throw new Error(`Failed to parse configuration file: ${this.filePath}`);
246
+ }
247
+ return {
248
+ raw: this.fileContentsData,
249
+ parsed: this.parsed,
250
+ valid: this.valid,
251
+ servers: await this.extractMCPServers(this.fileContentsData)
252
+ };
253
+ }
254
+ /**
255
+ * Extract MCP servers from parsed configuration data
256
+ */
257
+ async extractMCPServers(configData) {
258
+ if (!configData || typeof configData !== "object") {
259
+ return {};
260
+ }
261
+ if (configData.servers && typeof configData.servers === "object") {
262
+ return this.normalizeServerConfigs(configData.servers);
263
+ }
264
+ if (configData.mcp?.servers && typeof configData.mcp.servers === "object") {
265
+ return this.normalizeServerConfigs(configData.mcp.servers);
266
+ }
267
+ if (configData.mcpServers && typeof configData.mcpServers === "object") {
268
+ return this.normalizeServerConfigs(configData.mcpServers);
269
+ }
270
+ if (configData.context_servers && typeof configData.context_servers === "object") {
271
+ return this.normalizeServerConfigs(configData.context_servers);
272
+ }
273
+ return {};
274
+ }
275
+ /**
276
+ * Normalize server configurations to ensure consistent structure
277
+ */
278
+ normalizeServerConfigs(servers) {
279
+ const normalized = {};
280
+ for (const [serverName, serverConfig] of Object.entries(servers)) {
281
+ if (serverConfig && typeof serverConfig === "object") {
282
+ const env = serverConfig.env && typeof serverConfig.env === "object" ? serverConfig.env : void 0;
283
+ normalized[serverName] = {
284
+ name: serverName,
285
+ command: serverConfig.command || "",
286
+ args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
287
+ type: this.validateType(serverConfig.type) ? serverConfig.type : this.inferTransportType(serverConfig),
288
+ env
289
+ };
290
+ }
291
+ }
292
+ return normalized;
293
+ }
294
+ /**
295
+ * Validate type value
296
+ */
297
+ validateType(type) {
298
+ return ["sse", "http", "stdio", "streamable-http"].includes(type);
77
299
  }
300
+ /**
301
+ * Infer transport type from server configuration when type field is not explicitly set
302
+ */
303
+ inferTransportType(serverConfig) {
304
+ if (serverConfig.url && typeof serverConfig.url === "string") {
305
+ return "http";
306
+ }
307
+ if (Array.isArray(serverConfig.args)) {
308
+ const argsString = serverConfig.args.join(" ").toLowerCase();
309
+ if (argsString.includes("stdio")) {
310
+ return "stdio";
311
+ }
312
+ if (argsString.includes("http")) {
313
+ return "http";
314
+ }
315
+ if (argsString.includes("sse")) {
316
+ return "sse";
317
+ }
318
+ }
319
+ if (serverConfig.command && typeof serverConfig.command === "string") {
320
+ return "stdio";
321
+ }
322
+ return void 0;
323
+ }
324
+ /**
325
+ * Validate server configuration
326
+ */
327
+ validateServerConfig(serverConfig) {
328
+ if (!serverConfig || typeof serverConfig !== "object") {
329
+ return false;
330
+ }
331
+ if (!serverConfig.name || typeof serverConfig.name !== "string") {
332
+ return false;
333
+ }
334
+ if (!serverConfig.command || typeof serverConfig.command !== "string") {
335
+ return false;
336
+ }
337
+ return true;
338
+ }
339
+ /**
340
+ * Get supported configuration keys that the parser recognizes
341
+ */
342
+ getSupportedConfigKeys() {
343
+ return ["servers", "mcp.servers", "mcpServers", "context_servers"];
344
+ }
345
+ /**
346
+ * Check if the configuration file has valid syntax
347
+ */
78
348
  async isValidSyntax() {
79
349
  try {
80
- await this.parseFile();
81
- return this.valid;
350
+ const configData = await this.parseConfigFile();
351
+ return configData.valid;
82
352
  } catch (error) {
83
353
  return false;
84
354
  }
85
355
  }
356
+ /**
357
+ * Count the number of MCP servers in the configuration
358
+ */
86
359
  async countMCPServers() {
87
360
  try {
88
- const mcpServers = await this.getMCPServers();
89
- return Object.keys(mcpServers).length;
361
+ const configData = await this.parseConfigFile();
362
+ return Object.keys(configData.servers).length;
90
363
  } catch (error) {
91
364
  return 0;
92
365
  }
93
366
  }
94
- async getMCPServers() {
95
- await this.parseFile();
96
- if (this.fileContentsData?.servers) {
97
- return this.fileContentsData.servers;
367
+ /**
368
+ * Get the raw file content
369
+ */
370
+ async getFileContent() {
371
+ if (this.fileContents) {
372
+ return this.fileContents;
98
373
  }
99
- if (this.fileContentsData?.mcp?.servers) {
100
- return this.fileContentsData.mcp.servers;
374
+ try {
375
+ this.fileContents = await import_promises.default.readFile(this.filePath, "utf-8");
376
+ return this.fileContents;
377
+ } catch (error) {
378
+ throw new Error(`Failed to read file: ${this.filePath}`);
101
379
  }
102
- if (this.fileContentsData?.mcpServers) {
103
- return this.fileContentsData.mcpServers;
380
+ }
381
+ };
382
+
383
+ // src/services/credential-detection-service.ts
384
+ var CredentialDetectionService = class {
385
+ static {
386
+ __name(this, "CredentialDetectionService");
387
+ }
388
+ /**
389
+ * Credential patterns grouped by risk level for easier maintenance
390
+ */
391
+ static CREDENTIAL_PATTERNS = {
392
+ high: [
393
+ // API Keys and Tokens
394
+ /api[_-]?key/i,
395
+ /api[_-]?token/i,
396
+ /access[_-]?token/i,
397
+ /secret[_-]?key/i,
398
+ /private[_-]?key/i,
399
+ // Authentication Tokens
400
+ /auth[_-]?token/i,
401
+ /bearer[_-]?token/i,
402
+ /jwt[_-]?token/i,
403
+ /oauth[_-]?token/i,
404
+ // Passwords
405
+ /password/i,
406
+ /passwd/i,
407
+ /pwd/i,
408
+ // Credentials
409
+ /credential/i,
410
+ /creds/i,
411
+ // Specific service patterns
412
+ /openai[_-]?api[_-]?key/i,
413
+ /anthropic[_-]?api[_-]?key/i,
414
+ /firecrawl[_-]?api[_-]?key/i,
415
+ /github[_-]?token/i,
416
+ /gitlab[_-]?token/i,
417
+ /bitbucket[_-]?token/i,
418
+ // Database passwords
419
+ /db[_-]?password/i,
420
+ /database[_-]?password/i,
421
+ /redis[_-]?password/i,
422
+ /postgres[_-]?password/i,
423
+ /mysql[_-]?password/i,
424
+ // Cloud services
425
+ /aws[_-]?secret[_-]?access[_-]?key/i,
426
+ /aws[_-]?access[_-]?key[_-]?id/i,
427
+ /azure[_-]?key/i,
428
+ /gcp[_-]?key/i,
429
+ /google[_-]?api[_-]?key/i,
430
+ /gemini[_-]?api[_-]?key/i,
431
+ /claude[_-]?api[_-]?key/i
432
+ ],
433
+ low: [
434
+ // Organization and Account IDs
435
+ /org[_-]?id/i,
436
+ /organization[_-]?id/i,
437
+ /account[_-]?id/i,
438
+ /user[_-]?id/i,
439
+ /openai[_-]?org[_-]?id/i
440
+ ]
441
+ };
442
+ /**
443
+ * Check if an environment variable name suggests it might contain credentials
444
+ */
445
+ static isPotentialCredential(envVarName) {
446
+ return this.CREDENTIAL_PATTERNS.high.some((pattern) => pattern.test(envVarName)) || this.CREDENTIAL_PATTERNS.low.some((pattern) => pattern.test(envVarName));
447
+ }
448
+ /**
449
+ * Analyze environment variables and return credential detection results
450
+ */
451
+ static analyzeEnvironmentVariables(env) {
452
+ if (!env || typeof env !== "object") {
453
+ return {
454
+ hasCredentials: false,
455
+ credentialVars: [],
456
+ riskLevel: "none"
457
+ };
104
458
  }
105
- if (this.fileContentsData?.context_servers) {
106
- return this.fileContentsData.context_servers;
459
+ const credentialVars = [];
460
+ for (const [name, value] of Object.entries(env)) {
461
+ if (this.isPotentialCredential(name)) {
462
+ credentialVars.push({
463
+ name,
464
+ value: this.maskValue(value),
465
+ riskLevel: this.assessRiskLevel(name)
466
+ });
467
+ }
107
468
  }
108
- return {};
469
+ const hasCredentials = credentialVars.length > 0;
470
+ const riskLevel = this.calculateOverallRiskLevel(credentialVars);
471
+ return {
472
+ hasCredentials,
473
+ credentialVars,
474
+ riskLevel
475
+ };
109
476
  }
110
- async getFileContent() {
111
- if (this.fileContents) {
112
- return this.fileContents;
477
+ /**
478
+ * Mask sensitive values for display (show only first and last character)
479
+ */
480
+ static maskValue(value) {
481
+ if (!value || value.length <= 2) {
482
+ return value;
113
483
  }
114
- this.fileContents = await import_promises.default.readFile(this.filePath, "utf-8");
115
- return this.fileContents;
484
+ const first = value.charAt(0);
485
+ const last = value.charAt(value.length - 1);
486
+ const maskedLength = Math.min(value.length - 2, 8);
487
+ return `${first}${"*".repeat(maskedLength)}${last}`;
488
+ }
489
+ /**
490
+ * Assess risk level for a specific credential variable
491
+ */
492
+ static assessRiskLevel(name) {
493
+ if (this.CREDENTIAL_PATTERNS.high.some((pattern) => pattern.test(name))) {
494
+ return "high";
495
+ }
496
+ if (this.CREDENTIAL_PATTERNS.low.some((pattern) => pattern.test(name))) {
497
+ return "low";
498
+ }
499
+ return "high";
500
+ }
501
+ /**
502
+ * Calculate overall risk level based on all credential variables
503
+ */
504
+ static calculateOverallRiskLevel(credentialVars) {
505
+ if (credentialVars.length === 0) {
506
+ return "none";
507
+ }
508
+ const hasHighRisk = credentialVars.some((v) => v.riskLevel === "high");
509
+ if (hasHighRisk) {
510
+ return "high";
511
+ }
512
+ return "low";
513
+ }
514
+ };
515
+
516
+ // src/services/mcp-config-service.ts
517
+ var MCPConfigService = class {
518
+ static {
519
+ __name(this, "MCPConfigService");
520
+ }
521
+ pathRegistry;
522
+ currentOS;
523
+ debug;
524
+ constructor() {
525
+ this.pathRegistry = new MCPPathRegistry();
526
+ this.currentOS = (0, import_node_os.platform)();
527
+ this.debug = import_node_util.default.debuglog("ls-mcp");
528
+ }
529
+ /**
530
+ * Get MCP configuration files for a specific AI application on the current OS
531
+ */
532
+ getConfigFilesPerApp(appName) {
533
+ try {
534
+ return this.pathRegistry.getPathsForApp(this.currentOS, appName);
535
+ } catch (error) {
536
+ throw new Error(`Failed to get config files for app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
537
+ }
538
+ }
539
+ /**
540
+ * Get MCP configuration files for all AI applications on the current OS
541
+ */
542
+ getAllConfigFiles() {
543
+ try {
544
+ return this.pathRegistry.getPathsForOS(this.currentOS);
545
+ } catch (error) {
546
+ throw new Error(`Failed to get all config files: ${error instanceof Error ? error.message : "Unknown error"}`);
547
+ }
548
+ }
549
+ /**
550
+ * Get MCP servers configured for a specific AI application on the current OS
551
+ */
552
+ async getMCPServersPerApp(appName) {
553
+ try {
554
+ const appPaths = this.getConfigFilesPerApp(appName);
555
+ const allServers = [];
556
+ for (const filePath of appPaths) {
557
+ const servers = await this.parseConfigFileForServers(filePath.filePath);
558
+ allServers.push(...servers);
559
+ }
560
+ return allServers;
561
+ } catch (error) {
562
+ throw new Error(`Failed to get MCP servers for app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
563
+ }
564
+ }
565
+ /**
566
+ * Get MCP servers configured for all AI applications on the current OS
567
+ */
568
+ async getAllMCPServers() {
569
+ try {
570
+ const allApps = this.pathRegistry.getSupportedApps(this.currentOS);
571
+ const allServers = {};
572
+ for (const appName of allApps) {
573
+ try {
574
+ allServers[appName] = await this.getMCPServersPerApp(appName);
575
+ } catch (error) {
576
+ this.debug(`Failed to get servers for app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
577
+ allServers[appName] = [];
578
+ }
579
+ }
580
+ return allServers;
581
+ } catch (error) {
582
+ throw new Error(`Failed to get all MCP servers: ${error instanceof Error ? error.message : "Unknown error"}`);
583
+ }
584
+ }
585
+ /**
586
+ * Get metadata for all supported AI applications on the current OS
587
+ */
588
+ getSupportedApps() {
589
+ try {
590
+ const appNames = this.pathRegistry.getSupportedApps(this.currentOS);
591
+ const appPaths = this.pathRegistry.getPathsForOS(this.currentOS);
592
+ return appNames.map((appName) => ({
593
+ name: appName,
594
+ friendlyName: this.getFriendlyName(appName),
595
+ paths: appPaths[appName] || []
596
+ }));
597
+ } catch (error) {
598
+ throw new Error(`Failed to get supported apps: ${error instanceof Error ? error.message : "Unknown error"}`);
599
+ }
600
+ }
601
+ /**
602
+ * Get all supported operating systems
603
+ */
604
+ getSupportedOperatingSystems() {
605
+ return this.pathRegistry.getSupportedOperatingSystems();
606
+ }
607
+ /**
608
+ * Validate if a configuration file exists and is parsable
609
+ */
610
+ async validateConfigFile(filePath) {
611
+ try {
612
+ await import_promises2.default.access(filePath);
613
+ const parser = this.createParser(filePath);
614
+ return await parser.isValidSyntax();
615
+ } catch (error) {
616
+ return false;
617
+ }
618
+ }
619
+ /**
620
+ * Create a parser instance (can be overridden for testing)
621
+ */
622
+ createParser(filePath) {
623
+ return new MCPConfigParser(filePath);
624
+ }
625
+ /**
626
+ * Get MCP file groups with resolved paths and server information
627
+ */
628
+ async getMCPFileGroups() {
629
+ try {
630
+ const appPaths = this.getAllConfigFiles();
631
+ const mcpFilesPathsData = {};
632
+ for (const [groupName, paths] of Object.entries(appPaths)) {
633
+ mcpFilesPathsData[groupName] = {
634
+ name: groupName,
635
+ friendlyName: this.getFriendlyName(groupName),
636
+ paths: [],
637
+ stats: { serversCount: 0 }
638
+ };
639
+ const uniqueFilePaths = /* @__PURE__ */ new Set();
640
+ let totalServersCount = 0;
641
+ for (const filePathData of paths) {
642
+ const resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
643
+ const absolutePath = import_node_path2.default.resolve(resolvedPath);
644
+ if (uniqueFilePaths.has(absolutePath)) {
645
+ continue;
646
+ }
647
+ uniqueFilePaths.add(absolutePath);
648
+ try {
649
+ await import_promises2.default.access(resolvedPath);
650
+ const parser = this.createParser(resolvedPath);
651
+ const parsable = await parser.isValidSyntax();
652
+ filePathData.parsable = parsable;
653
+ if (parsable) {
654
+ const configData = await parser.parseConfigFile();
655
+ const servers = await this.convertToMCPServerInfo(configData.servers || {});
656
+ filePathData.servers = servers;
657
+ totalServersCount += servers.length;
658
+ }
659
+ mcpFilesPathsData[groupName].paths.push(filePathData);
660
+ } catch (error) {
661
+ this.debug(`Skipping file ${resolvedPath}: ${error instanceof Error ? error.message : "Unknown error"}`);
662
+ }
663
+ }
664
+ if (mcpFilesPathsData[groupName] && mcpFilesPathsData[groupName].stats) {
665
+ mcpFilesPathsData[groupName].stats.serversCount = totalServersCount;
666
+ }
667
+ }
668
+ return mcpFilesPathsData;
669
+ } catch (error) {
670
+ throw new Error(`Failed to get MCP file groups: ${error instanceof Error ? error.message : "Unknown error"}`);
671
+ }
672
+ }
673
+ /**
674
+ * Register a custom app with custom paths for the current OS
675
+ */
676
+ registerCustomApp(appName, paths) {
677
+ try {
678
+ this.pathRegistry.registerCustomApp(this.currentOS, appName, paths);
679
+ } catch (error) {
680
+ throw new Error(`Failed to register custom app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
681
+ }
682
+ }
683
+ /**
684
+ * Parse a configuration file and return server information
685
+ */
686
+ async parseConfigFileForServers(filePath) {
687
+ try {
688
+ const parser = this.createParser(filePath);
689
+ const configData = await parser.parseConfigFile();
690
+ return await this.convertToMCPServerInfo(configData.servers || {});
691
+ } catch (error) {
692
+ this.debug(`Failed to parse config file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
693
+ return [];
694
+ }
695
+ }
696
+ /**
697
+ * Convert parsed server configs to MCPServerInfo format
698
+ */
699
+ async convertToMCPServerInfo(servers) {
700
+ const serverInfos = [];
701
+ for (const [serverName, serverConfig] of Object.entries(servers)) {
702
+ if (serverConfig && typeof serverConfig === "object") {
703
+ serverInfos.push({
704
+ name: serverName,
705
+ command: serverConfig.command || "",
706
+ args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
707
+ transport: serverConfig.type === "streamable-http" ? "http" : serverConfig.type,
708
+ // Map streamable-http to http
709
+ type: serverConfig.type,
710
+ source: serverConfig.command || "",
711
+ env: serverConfig.env,
712
+ status: "stopped",
713
+ // Default status, will be updated by server manager
714
+ credentials: CredentialDetectionService.analyzeEnvironmentVariables(serverConfig.env)
715
+ });
716
+ }
717
+ }
718
+ return serverInfos;
719
+ }
720
+ /**
721
+ * Get friendly name for an app
722
+ */
723
+ getFriendlyName(appName) {
724
+ const friendlyNames = {
725
+ claude: "Claude Desktop",
726
+ claude_code: "Claude Code",
727
+ cursor: "Cursor",
728
+ vscode: "VS Code",
729
+ cline: "Cline",
730
+ windsurf: "Windsurf",
731
+ roo: "Roo",
732
+ "intellij-github-copilot": "IntelliJ GitHub Copilot",
733
+ junie: "IntelliJ Junie",
734
+ zed: "Zed",
735
+ gemini: "Gemini CLI"
736
+ };
737
+ return friendlyNames[appName] || appName;
116
738
  }
117
739
  };
118
740
 
119
741
  // src/services/mcp-server-manager-service.ts
120
- var import_node_path = __toESM(require("path"), 1);
742
+ var import_node_path3 = __toESM(require("path"), 1);
121
743
  var import_node_child_process = require("child_process");
122
- var import_node_os = require("os");
744
+ var import_node_os2 = require("os");
123
745
  var MCPServerManagerService = class {
124
746
  static {
125
747
  __name(this, "MCPServerManagerService");
@@ -139,7 +761,7 @@ var MCPServerManagerService = class {
139
761
  if (serverConfig?.type && serverConfig.type === "sse") {
140
762
  this.transport = "sse";
141
763
  }
142
- if (serverConfig?.type && serverConfig.type === "http") {
764
+ if (serverConfig?.type && (serverConfig.type === "http" || serverConfig.type === "streamable-http")) {
143
765
  this.transport = "http";
144
766
  }
145
767
  if (serverConfig?.type && serverConfig.type === "stdio") {
@@ -175,7 +797,7 @@ var MCPServerManagerService = class {
175
797
  isRunning() {
176
798
  try {
177
799
  let psOutput;
178
- if ((0, import_node_os.platform)() === "win32") {
800
+ if ((0, import_node_os2.platform)() === "win32") {
179
801
  psOutput = (0, import_node_child_process.execSync)('powershell -Command "Get-CimInstance -ClassName Win32_Process | Select-Object ProcessId,Name,CommandLine,ParentProcessId | ConvertTo-Csv -NoTypeInformation"', {
180
802
  encoding: "utf8",
181
803
  timeout: 5e3
@@ -193,7 +815,7 @@ var MCPServerManagerService = class {
193
815
  let pid;
194
816
  let ppid;
195
817
  let commandLine;
196
- if ((0, import_node_os.platform)() === "win32") {
818
+ if ((0, import_node_os2.platform)() === "win32") {
197
819
  if (processLine.startsWith('"ProcessId"') || processLine.startsWith("ProcessId")) continue;
198
820
  const parts = this.parseCSVLine(processLine);
199
821
  if (parts.length < 4) continue;
@@ -216,7 +838,7 @@ var MCPServerManagerService = class {
216
838
  for (const [pid, processData] of processMap) {
217
839
  const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid);
218
840
  let commandMatchWin32 = false;
219
- if ((0, import_node_os.platform)() === "win32") {
841
+ if ((0, import_node_os2.platform)() === "win32") {
220
842
  let commandTokensOnWin32 = processData.commandTokens;
221
843
  if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith("cmd")) {
222
844
  commandTokensOnWin32 = commandTokensOnWin32.slice(1);
@@ -327,9 +949,9 @@ var MCPServerManagerService = class {
327
949
  return true;
328
950
  }
329
951
  getBaseCommand(fullCommandPath) {
330
- let baseCommand = import_node_path.default.basename(fullCommandPath);
331
- if ((0, import_node_os.platform)() === "win32") {
332
- baseCommand = import_node_path.default.basename(fullCommandPath, ".exe");
952
+ let baseCommand = import_node_path3.default.basename(fullCommandPath);
953
+ if ((0, import_node_os2.platform)() === "win32") {
954
+ baseCommand = import_node_path3.default.basename(fullCommandPath, ".exe");
333
955
  }
334
956
  baseCommand = baseCommand.toLowerCase();
335
957
  return baseCommand;
@@ -511,218 +1133,57 @@ var MCPServerManagerService = class {
511
1133
  };
512
1134
 
513
1135
  // src/main.ts
514
- var osSpecificPaths = {
515
- claude: [],
516
- claude_code: [],
517
- cursor: [],
518
- vscode: [],
519
- cline: [],
520
- windsurf: [],
521
- roo: [],
522
- "intellij-github-copilot": [],
523
- junie: []
524
- };
525
- if ((0, import_node_os2.platform)() === "win32") {
526
- osSpecificPaths["claude"] = [
527
- { filePath: `${process.env.APPDATA}\\Claude\\claude_desktop_config.json`, type: "global" }
528
- ];
529
- osSpecificPaths["claude_code"] = [
530
- { filePath: ".mcp.json", type: "local" }
531
- ];
532
- osSpecificPaths["cursor"] = [
533
- { filePath: "~\\.cursor\\mcp.json", type: "global" },
534
- { filePath: ".cursor\\mcp.json", type: "local" }
535
- ];
536
- osSpecificPaths["vscode"] = [
537
- { filePath: ".vscode\\mcp.json", type: "local" },
538
- { filePath: `${process.env.APPDATA}\\Code\\User\\settings.json`, type: "global" },
539
- { filePath: `${process.env.APPDATA}\\Code - Insiders\\User\\settings.json`, type: "global" },
540
- { filePath: `${process.env.APPDATA}\\Code\\User\\mcp.json`, type: "global" },
541
- { filePath: `${process.env.APPDATA}\\Code - Insiders\\User\\mcp.json`, type: "global" }
542
- ];
543
- osSpecificPaths["cline"] = [
544
- { filePath: `${process.env.APPDATA}\\Code\\User\\globalStorage\\saoudrizwan.claude-dev\\settings\\cline_mcp_settings.json`, type: "global" },
545
- { filePath: `${process.env.APPDATA}\\Code - Insiders\\User\\globalStorage\\saoudrizwan.claude-dev\\settings\\cline_mcp_settings.json`, type: "global" }
546
- ];
547
- osSpecificPaths["windsurf"] = [
548
- { filePath: ".codeium\\windsurf\\mcp_config.json", type: "local" }
549
- ];
550
- osSpecificPaths["roo"] = [
551
- { filePath: `${process.env.APPDATA}\\Code\\User\\globalStorage\\rooveterinaryinc.roo-cline\\settings\\cline_mcp_settings.json`, type: "global" },
552
- { filePath: `${process.env.APPDATA}\\Code - Insiders\\User\\globalStorage\\rooveterinaryinc.roo-cline\\settings\\cline_mcp_settings.json`, type: "global" }
553
- ];
554
- osSpecificPaths["intellij-github-copilot"] = [
555
- { filePath: `${process.env.LOCALAPPDATA}\\github-copilot\\intellij\\mcp.json`, type: "global" }
556
- ];
557
- osSpecificPaths["junie"] = [
558
- { filePath: "~\\.junie\\mcp\\mcp.json", type: "global" }
559
- ];
560
- osSpecificPaths["zed"] = [
561
- { filePath: `${process.env.LOCALAPPDATA}\\zed\\settings.json`, type: "global" },
562
- { filePath: ".zed\\settings.json", type: "local" }
563
- ];
564
- } else {
565
- osSpecificPaths["claude"] = [
566
- { filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
567
- ];
568
- osSpecificPaths["claude_code"] = [
569
- { filePath: ".mcp.json", type: "local" }
570
- ];
571
- osSpecificPaths["cursor"] = [
572
- { filePath: "~/.cursor/mcp.json", type: "global" },
573
- { filePath: ".cursor/mcp.json", type: "local" }
574
- ];
575
- osSpecificPaths["vscode"] = [
576
- { filePath: ".vscode/mcp.json", type: "local" },
577
- { filePath: "~/Library/Application Support/Code/User/settings.json", type: "global" },
578
- { filePath: "~/Library/Application Support/Code/User/mcp.json", type: "global" },
579
- { filePath: "~/Library/Application Support/Code - Insiders/User/settings.json", type: "global" },
580
- { filePath: "~/Library/Application Support/Code - Insiders/User/mcp.json", type: "global" }
581
- ];
582
- osSpecificPaths["cline"] = [
583
- { filePath: "~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json", type: "global" },
584
- { filePath: "~/Library/Application Support/Code - Insiders/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json", type: "global" }
585
- ];
586
- osSpecificPaths["windsurf"] = [
587
- { filePath: ".codeium/windsurf/mcp_config.json", type: "local" }
588
- ];
589
- osSpecificPaths["roo"] = [
590
- { filePath: "~/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json", type: "global" },
591
- { filePath: "~/Library/Application Support/Code - Insiders/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json", type: "global" }
592
- ];
593
- osSpecificPaths["intellij-github-copilot"] = [
594
- { filePath: "~/.config/github-copilot/intellij/mcp.json", type: "global" }
595
- ];
596
- osSpecificPaths["junie"] = [
597
- { filePath: "~/.junie/mcp/mcp.json", type: "global" },
598
- { filePath: ".junie/mcp/mcp.json", type: "local" }
599
- ];
600
- osSpecificPaths["zed"] = [
601
- { filePath: "~/.config/zed/settings.json", type: "global" },
602
- { filePath: ".zed/settings.json", type: "local" }
603
- ];
604
- }
605
1136
  var MCPFiles = class {
606
1137
  static {
607
1138
  __name(this, "MCPFiles");
608
1139
  }
609
- mcpFilePathGroups = {
610
- claude: {
611
- name: "claude-desktop",
612
- friendlyName: "Claude Desktop",
613
- paths: osSpecificPaths["claude"]
614
- },
615
- claude_code: {
616
- name: "claude-code",
617
- friendlyName: "Claude Code",
618
- paths: osSpecificPaths["claude_code"]
619
- },
620
- cursor: {
621
- name: "cursor",
622
- friendlyName: "Cursor",
623
- paths: osSpecificPaths["cursor"]
624
- },
625
- vscode: {
626
- name: "vscode",
627
- friendlyName: "VS Code",
628
- paths: osSpecificPaths["vscode"]
629
- },
630
- cline: {
631
- name: "cline",
632
- friendlyName: "Cline",
633
- paths: osSpecificPaths["cline"]
634
- },
635
- windsurf: {
636
- name: "windsurf",
637
- friendlyName: "Windsurf",
638
- paths: osSpecificPaths["windsurf"]
639
- },
640
- roo: {
641
- name: "roo",
642
- friendlyName: "Roo",
643
- paths: osSpecificPaths["roo"]
644
- },
645
- "intellij-github-copilot": {
646
- name: "intellij-github-copilot",
647
- friendlyName: "IntelliJ GitHub Copilot",
648
- paths: osSpecificPaths["intellij-github-copilot"]
649
- },
650
- junie: {
651
- name: "junie",
652
- friendlyName: "IntelliJ Junie",
653
- paths: osSpecificPaths["junie"]
654
- },
655
- zed: {
656
- name: "zed",
657
- friendlyName: "Zed",
658
- paths: osSpecificPaths["zed"]
659
- }
660
- };
661
- constructor(mcpFilePathGroups) {
662
- this.mcpFilePathGroups = mcpFilePathGroups || this.mcpFilePathGroups;
1140
+ mcpConfigService;
1141
+ constructor() {
1142
+ this.mcpConfigService = new MCPConfigService();
663
1143
  }
1144
+ /**
1145
+ * Find and process all MCP configuration files
1146
+ */
664
1147
  async findFiles() {
665
- const mcpFilesPathsData = {};
666
- for (const groupName of Object.keys(this.mcpFilePathGroups)) {
667
- const clientsGroup = this.mcpFilePathGroups[groupName];
668
- mcpFilesPathsData[groupName] = {
669
- name: clientsGroup.name,
670
- friendlyName: clientsGroup.friendlyName,
671
- paths: [],
672
- stats: {}
673
- };
674
- const uniqueFilePaths = /* @__PURE__ */ new Set();
675
- for (const filePathData of clientsGroup.paths) {
676
- const resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
677
- const absolutePath = import_node_path2.default.resolve(resolvedPath);
678
- if (uniqueFilePaths.has(absolutePath)) {
679
- continue;
680
- }
681
- uniqueFilePaths.add(absolutePath);
682
- try {
683
- await import_promises2.default.access(resolvedPath);
684
- const MCPConfigLinter = new MCPConfigLinterService(resolvedPath);
685
- const parsable = await MCPConfigLinter.isValidSyntax();
686
- filePathData.parsable = parsable;
687
- const mcpServersData = [];
688
- const mcpServersFromConfig = await MCPConfigLinter.getMCPServers();
689
- for (const serverName of Object.keys(mcpServersFromConfig)) {
690
- const serverConfigRaw = mcpServersFromConfig[serverName];
691
- const serverConfig = {
692
- name: serverName,
693
- command: serverConfigRaw.command || "",
694
- args: serverConfigRaw.args,
695
- url: serverConfigRaw.url,
696
- transport: serverConfigRaw.transport,
697
- type: serverConfigRaw.type,
698
- env: serverConfigRaw.env
699
- };
700
- const MCPServerManager = new MCPServerManagerService(serverConfig);
701
- const mcpServerProcessDetection = MCPServerManager.isRunning();
702
- let mcpServerProcess = false;
703
- if (mcpServerProcessDetection) {
704
- if (typeof mcpServerProcessDetection === "object" && mcpServerProcessDetection.estimatedProduct === clientsGroup.name) {
705
- mcpServerProcess = true;
1148
+ try {
1149
+ const mcpFilesPathsData = await this.mcpConfigService.getMCPFileGroups();
1150
+ for (const groupName of Object.keys(mcpFilesPathsData)) {
1151
+ const group = mcpFilesPathsData[groupName];
1152
+ for (const filePathData of group.paths) {
1153
+ if (filePathData.servers && filePathData.servers.length > 0) {
1154
+ for (const server of filePathData.servers) {
1155
+ const serverConfig = {
1156
+ name: server.name,
1157
+ command: server.command,
1158
+ args: server.args,
1159
+ transport: server.transport,
1160
+ // transport is always populated from type in the data layer
1161
+ type: server.type,
1162
+ env: server.env
1163
+ };
1164
+ const serverManager = new MCPServerManagerService(serverConfig);
1165
+ const processDetection = serverManager.isRunning();
1166
+ let isRunning = false;
1167
+ if (processDetection) {
1168
+ if (typeof processDetection === "object" && processDetection.estimatedProduct === group.name) {
1169
+ isRunning = true;
1170
+ }
706
1171
  }
1172
+ server.status = isRunning ? "running" : "stopped";
707
1173
  }
708
- mcpServersData.push({
709
- name: MCPServerManager.getName(),
710
- command: MCPServerManager.getCmd(),
711
- args: MCPServerManager.getArgs(),
712
- source: MCPServerManager.getSource(),
713
- transport: MCPServerManager.getTransport(),
714
- env: MCPServerManager.getEnv(),
715
- status: mcpServerProcess ? "running" : "stopped"
716
- });
717
1174
  }
718
- filePathData.servers = mcpServersData;
719
- mcpFilesPathsData[groupName]["stats"]["serversCount"] = await MCPConfigLinter.countMCPServers();
720
- mcpFilesPathsData[groupName].paths.push(filePathData);
721
- } catch (error) {
722
1175
  }
723
1176
  }
1177
+ return mcpFilesPathsData;
1178
+ } catch (error) {
1179
+ throw new Error(`Failed to find MCP files: ${error instanceof Error ? error.message : "Unknown error"}`);
724
1180
  }
725
- return mcpFilesPathsData;
1181
+ }
1182
+ /**
1183
+ * Get MCP configuration service instance for advanced operations
1184
+ */
1185
+ getMCPConfigService() {
1186
+ return this.mcpConfigService;
726
1187
  }
727
1188
  };
728
1189
  // Annotate the CommonJS export names for ESM import in node: