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.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 path2 from "path";
7
+ import fs2 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,519 @@ 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
+ env
255
+ };
256
+ }
257
+ }
258
+ return normalized;
259
+ }
260
+ /**
261
+ * Validate type value
262
+ */
263
+ validateType(type) {
264
+ return ["sse", "http", "stdio", "streamable-http"].includes(type);
45
265
  }
266
+ /**
267
+ * Infer transport type from server configuration when type field is not explicitly set
268
+ */
269
+ inferTransportType(serverConfig) {
270
+ if (serverConfig.url && typeof serverConfig.url === "string") {
271
+ return "http";
272
+ }
273
+ if (Array.isArray(serverConfig.args)) {
274
+ const argsString = serverConfig.args.join(" ").toLowerCase();
275
+ if (argsString.includes("stdio")) {
276
+ return "stdio";
277
+ }
278
+ if (argsString.includes("http")) {
279
+ return "http";
280
+ }
281
+ if (argsString.includes("sse")) {
282
+ return "sse";
283
+ }
284
+ }
285
+ if (serverConfig.command && typeof serverConfig.command === "string") {
286
+ return "stdio";
287
+ }
288
+ return void 0;
289
+ }
290
+ /**
291
+ * Validate server configuration
292
+ */
293
+ validateServerConfig(serverConfig) {
294
+ if (!serverConfig || typeof serverConfig !== "object") {
295
+ return false;
296
+ }
297
+ if (!serverConfig.name || typeof serverConfig.name !== "string") {
298
+ return false;
299
+ }
300
+ if (!serverConfig.command || typeof serverConfig.command !== "string") {
301
+ return false;
302
+ }
303
+ return true;
304
+ }
305
+ /**
306
+ * Get supported configuration keys that the parser recognizes
307
+ */
308
+ getSupportedConfigKeys() {
309
+ return ["servers", "mcp.servers", "mcpServers", "context_servers"];
310
+ }
311
+ /**
312
+ * Check if the configuration file has valid syntax
313
+ */
46
314
  async isValidSyntax() {
47
315
  try {
48
- await this.parseFile();
49
- return this.valid;
316
+ const configData = await this.parseConfigFile();
317
+ return configData.valid;
50
318
  } catch (error) {
51
319
  return false;
52
320
  }
53
321
  }
322
+ /**
323
+ * Count the number of MCP servers in the configuration
324
+ */
54
325
  async countMCPServers() {
55
326
  try {
56
- const mcpServers = await this.getMCPServers();
57
- return Object.keys(mcpServers).length;
327
+ const configData = await this.parseConfigFile();
328
+ return Object.keys(configData.servers).length;
58
329
  } catch (error) {
59
330
  return 0;
60
331
  }
61
332
  }
62
- async getMCPServers() {
63
- await this.parseFile();
64
- if (this.fileContentsData?.servers) {
65
- return this.fileContentsData.servers;
333
+ /**
334
+ * Get the raw file content
335
+ */
336
+ async getFileContent() {
337
+ if (this.fileContents) {
338
+ return this.fileContents;
66
339
  }
67
- if (this.fileContentsData?.mcp?.servers) {
68
- return this.fileContentsData.mcp.servers;
340
+ try {
341
+ this.fileContents = await fs.readFile(this.filePath, "utf-8");
342
+ return this.fileContents;
343
+ } catch (error) {
344
+ throw new Error(`Failed to read file: ${this.filePath}`);
69
345
  }
70
- if (this.fileContentsData?.mcpServers) {
71
- return this.fileContentsData.mcpServers;
346
+ }
347
+ };
348
+
349
+ // src/services/credential-detection-service.ts
350
+ var CredentialDetectionService = class {
351
+ static {
352
+ __name(this, "CredentialDetectionService");
353
+ }
354
+ /**
355
+ * Credential patterns grouped by risk level for easier maintenance
356
+ */
357
+ static CREDENTIAL_PATTERNS = {
358
+ high: [
359
+ // API Keys and Tokens
360
+ /api[_-]?key/i,
361
+ /api[_-]?token/i,
362
+ /access[_-]?token/i,
363
+ /secret[_-]?key/i,
364
+ /private[_-]?key/i,
365
+ // Authentication Tokens
366
+ /auth[_-]?token/i,
367
+ /bearer[_-]?token/i,
368
+ /jwt[_-]?token/i,
369
+ /oauth[_-]?token/i,
370
+ // Passwords
371
+ /password/i,
372
+ /passwd/i,
373
+ /pwd/i,
374
+ // Credentials
375
+ /credential/i,
376
+ /creds/i,
377
+ // Specific service patterns
378
+ /openai[_-]?api[_-]?key/i,
379
+ /anthropic[_-]?api[_-]?key/i,
380
+ /firecrawl[_-]?api[_-]?key/i,
381
+ /github[_-]?token/i,
382
+ /gitlab[_-]?token/i,
383
+ /bitbucket[_-]?token/i,
384
+ // Database passwords
385
+ /db[_-]?password/i,
386
+ /database[_-]?password/i,
387
+ /redis[_-]?password/i,
388
+ /postgres[_-]?password/i,
389
+ /mysql[_-]?password/i,
390
+ // Cloud services
391
+ /aws[_-]?secret[_-]?access[_-]?key/i,
392
+ /aws[_-]?access[_-]?key[_-]?id/i,
393
+ /azure[_-]?key/i,
394
+ /gcp[_-]?key/i,
395
+ /google[_-]?api[_-]?key/i,
396
+ /gemini[_-]?api[_-]?key/i,
397
+ /claude[_-]?api[_-]?key/i
398
+ ],
399
+ low: [
400
+ // Organization and Account IDs
401
+ /org[_-]?id/i,
402
+ /organization[_-]?id/i,
403
+ /account[_-]?id/i,
404
+ /user[_-]?id/i,
405
+ /openai[_-]?org[_-]?id/i
406
+ ]
407
+ };
408
+ /**
409
+ * Check if an environment variable name suggests it might contain credentials
410
+ */
411
+ static isPotentialCredential(envVarName) {
412
+ return this.CREDENTIAL_PATTERNS.high.some((pattern) => pattern.test(envVarName)) || this.CREDENTIAL_PATTERNS.low.some((pattern) => pattern.test(envVarName));
413
+ }
414
+ /**
415
+ * Analyze environment variables and return credential detection results
416
+ */
417
+ static analyzeEnvironmentVariables(env) {
418
+ if (!env || typeof env !== "object") {
419
+ return {
420
+ hasCredentials: false,
421
+ credentialVars: [],
422
+ riskLevel: "none"
423
+ };
72
424
  }
73
- if (this.fileContentsData?.context_servers) {
74
- return this.fileContentsData.context_servers;
425
+ const credentialVars = [];
426
+ for (const [name, value] of Object.entries(env)) {
427
+ if (this.isPotentialCredential(name)) {
428
+ credentialVars.push({
429
+ name,
430
+ value: this.maskValue(value),
431
+ riskLevel: this.assessRiskLevel(name)
432
+ });
433
+ }
75
434
  }
76
- return {};
435
+ const hasCredentials = credentialVars.length > 0;
436
+ const riskLevel = this.calculateOverallRiskLevel(credentialVars);
437
+ return {
438
+ hasCredentials,
439
+ credentialVars,
440
+ riskLevel
441
+ };
77
442
  }
78
- async getFileContent() {
79
- if (this.fileContents) {
80
- return this.fileContents;
443
+ /**
444
+ * Mask sensitive values for display (show only first and last character)
445
+ */
446
+ static maskValue(value) {
447
+ if (!value || value.length <= 2) {
448
+ return value;
81
449
  }
82
- this.fileContents = await fs.readFile(this.filePath, "utf-8");
83
- return this.fileContents;
450
+ const first = value.charAt(0);
451
+ const last = value.charAt(value.length - 1);
452
+ const maskedLength = Math.min(value.length - 2, 8);
453
+ return `${first}${"*".repeat(maskedLength)}${last}`;
454
+ }
455
+ /**
456
+ * Assess risk level for a specific credential variable
457
+ */
458
+ static assessRiskLevel(name) {
459
+ if (this.CREDENTIAL_PATTERNS.high.some((pattern) => pattern.test(name))) {
460
+ return "high";
461
+ }
462
+ if (this.CREDENTIAL_PATTERNS.low.some((pattern) => pattern.test(name))) {
463
+ return "low";
464
+ }
465
+ return "high";
466
+ }
467
+ /**
468
+ * Calculate overall risk level based on all credential variables
469
+ */
470
+ static calculateOverallRiskLevel(credentialVars) {
471
+ if (credentialVars.length === 0) {
472
+ return "none";
473
+ }
474
+ const hasHighRisk = credentialVars.some((v) => v.riskLevel === "high");
475
+ if (hasHighRisk) {
476
+ return "high";
477
+ }
478
+ return "low";
479
+ }
480
+ };
481
+
482
+ // src/services/mcp-config-service.ts
483
+ var MCPConfigService = class {
484
+ static {
485
+ __name(this, "MCPConfigService");
486
+ }
487
+ pathRegistry;
488
+ currentOS;
489
+ debug;
490
+ constructor() {
491
+ this.pathRegistry = new MCPPathRegistry();
492
+ this.currentOS = platform();
493
+ this.debug = util.debuglog("ls-mcp");
494
+ }
495
+ /**
496
+ * Get MCP configuration files for a specific AI application on the current OS
497
+ */
498
+ getConfigFilesPerApp(appName) {
499
+ try {
500
+ return this.pathRegistry.getPathsForApp(this.currentOS, appName);
501
+ } catch (error) {
502
+ throw new Error(`Failed to get config files for app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
503
+ }
504
+ }
505
+ /**
506
+ * Get MCP configuration files for all AI applications on the current OS
507
+ */
508
+ getAllConfigFiles() {
509
+ try {
510
+ return this.pathRegistry.getPathsForOS(this.currentOS);
511
+ } catch (error) {
512
+ throw new Error(`Failed to get all config files: ${error instanceof Error ? error.message : "Unknown error"}`);
513
+ }
514
+ }
515
+ /**
516
+ * Get MCP servers configured for a specific AI application on the current OS
517
+ */
518
+ async getMCPServersPerApp(appName) {
519
+ try {
520
+ const appPaths = this.getConfigFilesPerApp(appName);
521
+ const allServers = [];
522
+ for (const filePath of appPaths) {
523
+ const servers = await this.parseConfigFileForServers(filePath.filePath);
524
+ allServers.push(...servers);
525
+ }
526
+ return allServers;
527
+ } catch (error) {
528
+ throw new Error(`Failed to get MCP servers for app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
529
+ }
530
+ }
531
+ /**
532
+ * Get MCP servers configured for all AI applications on the current OS
533
+ */
534
+ async getAllMCPServers() {
535
+ try {
536
+ const allApps = this.pathRegistry.getSupportedApps(this.currentOS);
537
+ const allServers = {};
538
+ for (const appName of allApps) {
539
+ try {
540
+ allServers[appName] = await this.getMCPServersPerApp(appName);
541
+ } catch (error) {
542
+ this.debug(`Failed to get servers for app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
543
+ allServers[appName] = [];
544
+ }
545
+ }
546
+ return allServers;
547
+ } catch (error) {
548
+ throw new Error(`Failed to get all MCP servers: ${error instanceof Error ? error.message : "Unknown error"}`);
549
+ }
550
+ }
551
+ /**
552
+ * Get metadata for all supported AI applications on the current OS
553
+ */
554
+ getSupportedApps() {
555
+ try {
556
+ const appNames = this.pathRegistry.getSupportedApps(this.currentOS);
557
+ const appPaths = this.pathRegistry.getPathsForOS(this.currentOS);
558
+ return appNames.map((appName) => ({
559
+ name: appName,
560
+ friendlyName: this.getFriendlyName(appName),
561
+ paths: appPaths[appName] || []
562
+ }));
563
+ } catch (error) {
564
+ throw new Error(`Failed to get supported apps: ${error instanceof Error ? error.message : "Unknown error"}`);
565
+ }
566
+ }
567
+ /**
568
+ * Get all supported operating systems
569
+ */
570
+ getSupportedOperatingSystems() {
571
+ return this.pathRegistry.getSupportedOperatingSystems();
572
+ }
573
+ /**
574
+ * Validate if a configuration file exists and is parsable
575
+ */
576
+ async validateConfigFile(filePath) {
577
+ try {
578
+ await fs2.access(filePath);
579
+ const parser = this.createParser(filePath);
580
+ return await parser.isValidSyntax();
581
+ } catch (error) {
582
+ return false;
583
+ }
584
+ }
585
+ /**
586
+ * Create a parser instance (can be overridden for testing)
587
+ */
588
+ createParser(filePath) {
589
+ return new MCPConfigParser(filePath);
590
+ }
591
+ /**
592
+ * Get MCP file groups with resolved paths and server information
593
+ */
594
+ async getMCPFileGroups() {
595
+ try {
596
+ const appPaths = this.getAllConfigFiles();
597
+ const mcpFilesPathsData = {};
598
+ for (const [groupName, paths] of Object.entries(appPaths)) {
599
+ mcpFilesPathsData[groupName] = {
600
+ name: groupName,
601
+ friendlyName: this.getFriendlyName(groupName),
602
+ paths: [],
603
+ stats: { serversCount: 0 }
604
+ };
605
+ const uniqueFilePaths = /* @__PURE__ */ new Set();
606
+ let totalServersCount = 0;
607
+ for (const filePathData of paths) {
608
+ const resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
609
+ const absolutePath = path2.resolve(resolvedPath);
610
+ if (uniqueFilePaths.has(absolutePath)) {
611
+ continue;
612
+ }
613
+ uniqueFilePaths.add(absolutePath);
614
+ try {
615
+ await fs2.access(resolvedPath);
616
+ const parser = this.createParser(resolvedPath);
617
+ const parsable = await parser.isValidSyntax();
618
+ filePathData.parsable = parsable;
619
+ if (parsable) {
620
+ const configData = await parser.parseConfigFile();
621
+ const servers = await this.convertToMCPServerInfo(configData.servers || {});
622
+ filePathData.servers = servers;
623
+ totalServersCount += servers.length;
624
+ }
625
+ mcpFilesPathsData[groupName].paths.push(filePathData);
626
+ } catch (error) {
627
+ this.debug(`Skipping file ${resolvedPath}: ${error instanceof Error ? error.message : "Unknown error"}`);
628
+ }
629
+ }
630
+ if (mcpFilesPathsData[groupName] && mcpFilesPathsData[groupName].stats) {
631
+ mcpFilesPathsData[groupName].stats.serversCount = totalServersCount;
632
+ }
633
+ }
634
+ return mcpFilesPathsData;
635
+ } catch (error) {
636
+ throw new Error(`Failed to get MCP file groups: ${error instanceof Error ? error.message : "Unknown error"}`);
637
+ }
638
+ }
639
+ /**
640
+ * Register a custom app with custom paths for the current OS
641
+ */
642
+ registerCustomApp(appName, paths) {
643
+ try {
644
+ this.pathRegistry.registerCustomApp(this.currentOS, appName, paths);
645
+ } catch (error) {
646
+ throw new Error(`Failed to register custom app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
647
+ }
648
+ }
649
+ /**
650
+ * Parse a configuration file and return server information
651
+ */
652
+ async parseConfigFileForServers(filePath) {
653
+ try {
654
+ const parser = this.createParser(filePath);
655
+ const configData = await parser.parseConfigFile();
656
+ return await this.convertToMCPServerInfo(configData.servers || {});
657
+ } catch (error) {
658
+ this.debug(`Failed to parse config file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
659
+ return [];
660
+ }
661
+ }
662
+ /**
663
+ * Convert parsed server configs to MCPServerInfo format
664
+ */
665
+ async convertToMCPServerInfo(servers) {
666
+ const serverInfos = [];
667
+ for (const [serverName, serverConfig] of Object.entries(servers)) {
668
+ if (serverConfig && typeof serverConfig === "object") {
669
+ serverInfos.push({
670
+ name: serverName,
671
+ command: serverConfig.command || "",
672
+ args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
673
+ transport: serverConfig.type === "streamable-http" ? "http" : serverConfig.type,
674
+ // Map streamable-http to http
675
+ type: serverConfig.type,
676
+ source: serverConfig.command || "",
677
+ env: serverConfig.env,
678
+ status: "stopped",
679
+ // Default status, will be updated by server manager
680
+ credentials: CredentialDetectionService.analyzeEnvironmentVariables(serverConfig.env)
681
+ });
682
+ }
683
+ }
684
+ return serverInfos;
685
+ }
686
+ /**
687
+ * Get friendly name for an app
688
+ */
689
+ getFriendlyName(appName) {
690
+ const friendlyNames = {
691
+ claude: "Claude Desktop",
692
+ claude_code: "Claude Code",
693
+ cursor: "Cursor",
694
+ vscode: "VS Code",
695
+ cline: "Cline",
696
+ windsurf: "Windsurf",
697
+ roo: "Roo",
698
+ "intellij-github-copilot": "IntelliJ GitHub Copilot",
699
+ junie: "IntelliJ Junie",
700
+ zed: "Zed",
701
+ gemini: "Gemini CLI"
702
+ };
703
+ return friendlyNames[appName] || appName;
84
704
  }
85
705
  };
86
706
 
87
707
  // src/services/mcp-server-manager-service.ts
88
- import path from "path";
708
+ import path3 from "path";
89
709
  import { execSync } from "child_process";
90
- import { platform } from "os";
710
+ import { platform as platform2 } from "os";
91
711
  var MCPServerManagerService = class {
92
712
  static {
93
713
  __name(this, "MCPServerManagerService");
@@ -107,7 +727,7 @@ var MCPServerManagerService = class {
107
727
  if (serverConfig?.type && serverConfig.type === "sse") {
108
728
  this.transport = "sse";
109
729
  }
110
- if (serverConfig?.type && serverConfig.type === "http") {
730
+ if (serverConfig?.type && (serverConfig.type === "http" || serverConfig.type === "streamable-http")) {
111
731
  this.transport = "http";
112
732
  }
113
733
  if (serverConfig?.type && serverConfig.type === "stdio") {
@@ -143,7 +763,7 @@ var MCPServerManagerService = class {
143
763
  isRunning() {
144
764
  try {
145
765
  let psOutput;
146
- if (platform() === "win32") {
766
+ if (platform2() === "win32") {
147
767
  psOutput = execSync('powershell -Command "Get-CimInstance -ClassName Win32_Process | Select-Object ProcessId,Name,CommandLine,ParentProcessId | ConvertTo-Csv -NoTypeInformation"', {
148
768
  encoding: "utf8",
149
769
  timeout: 5e3
@@ -161,7 +781,7 @@ var MCPServerManagerService = class {
161
781
  let pid;
162
782
  let ppid;
163
783
  let commandLine;
164
- if (platform() === "win32") {
784
+ if (platform2() === "win32") {
165
785
  if (processLine.startsWith('"ProcessId"') || processLine.startsWith("ProcessId")) continue;
166
786
  const parts = this.parseCSVLine(processLine);
167
787
  if (parts.length < 4) continue;
@@ -184,7 +804,7 @@ var MCPServerManagerService = class {
184
804
  for (const [pid, processData] of processMap) {
185
805
  const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid);
186
806
  let commandMatchWin32 = false;
187
- if (platform() === "win32") {
807
+ if (platform2() === "win32") {
188
808
  let commandTokensOnWin32 = processData.commandTokens;
189
809
  if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith("cmd")) {
190
810
  commandTokensOnWin32 = commandTokensOnWin32.slice(1);
@@ -295,9 +915,9 @@ var MCPServerManagerService = class {
295
915
  return true;
296
916
  }
297
917
  getBaseCommand(fullCommandPath) {
298
- let baseCommand = path.basename(fullCommandPath);
299
- if (platform() === "win32") {
300
- baseCommand = path.basename(fullCommandPath, ".exe");
918
+ let baseCommand = path3.basename(fullCommandPath);
919
+ if (platform2() === "win32") {
920
+ baseCommand = path3.basename(fullCommandPath, ".exe");
301
921
  }
302
922
  baseCommand = baseCommand.toLowerCase();
303
923
  return baseCommand;
@@ -479,218 +1099,57 @@ var MCPServerManagerService = class {
479
1099
  };
480
1100
 
481
1101
  // src/main.ts
482
- var osSpecificPaths = {
483
- claude: [],
484
- claude_code: [],
485
- cursor: [],
486
- vscode: [],
487
- cline: [],
488
- windsurf: [],
489
- roo: [],
490
- "intellij-github-copilot": [],
491
- junie: []
492
- };
493
- if (platform2() === "win32") {
494
- osSpecificPaths["claude"] = [
495
- { filePath: `${process.env.APPDATA}\\Claude\\claude_desktop_config.json`, type: "global" }
496
- ];
497
- osSpecificPaths["claude_code"] = [
498
- { filePath: ".mcp.json", type: "local" }
499
- ];
500
- osSpecificPaths["cursor"] = [
501
- { filePath: "~\\.cursor\\mcp.json", type: "global" },
502
- { filePath: ".cursor\\mcp.json", type: "local" }
503
- ];
504
- osSpecificPaths["vscode"] = [
505
- { filePath: ".vscode\\mcp.json", type: "local" },
506
- { filePath: `${process.env.APPDATA}\\Code\\User\\settings.json`, type: "global" },
507
- { filePath: `${process.env.APPDATA}\\Code - Insiders\\User\\settings.json`, type: "global" },
508
- { filePath: `${process.env.APPDATA}\\Code\\User\\mcp.json`, type: "global" },
509
- { filePath: `${process.env.APPDATA}\\Code - Insiders\\User\\mcp.json`, type: "global" }
510
- ];
511
- osSpecificPaths["cline"] = [
512
- { filePath: `${process.env.APPDATA}\\Code\\User\\globalStorage\\saoudrizwan.claude-dev\\settings\\cline_mcp_settings.json`, type: "global" },
513
- { filePath: `${process.env.APPDATA}\\Code - Insiders\\User\\globalStorage\\saoudrizwan.claude-dev\\settings\\cline_mcp_settings.json`, type: "global" }
514
- ];
515
- osSpecificPaths["windsurf"] = [
516
- { filePath: ".codeium\\windsurf\\mcp_config.json", type: "local" }
517
- ];
518
- osSpecificPaths["roo"] = [
519
- { filePath: `${process.env.APPDATA}\\Code\\User\\globalStorage\\rooveterinaryinc.roo-cline\\settings\\cline_mcp_settings.json`, type: "global" },
520
- { filePath: `${process.env.APPDATA}\\Code - Insiders\\User\\globalStorage\\rooveterinaryinc.roo-cline\\settings\\cline_mcp_settings.json`, type: "global" }
521
- ];
522
- osSpecificPaths["intellij-github-copilot"] = [
523
- { filePath: `${process.env.LOCALAPPDATA}\\github-copilot\\intellij\\mcp.json`, type: "global" }
524
- ];
525
- osSpecificPaths["junie"] = [
526
- { filePath: "~\\.junie\\mcp\\mcp.json", type: "global" }
527
- ];
528
- osSpecificPaths["zed"] = [
529
- { filePath: `${process.env.LOCALAPPDATA}\\zed\\settings.json`, type: "global" },
530
- { filePath: ".zed\\settings.json", type: "local" }
531
- ];
532
- } else {
533
- osSpecificPaths["claude"] = [
534
- { filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
535
- ];
536
- osSpecificPaths["claude_code"] = [
537
- { filePath: ".mcp.json", type: "local" }
538
- ];
539
- osSpecificPaths["cursor"] = [
540
- { filePath: "~/.cursor/mcp.json", type: "global" },
541
- { filePath: ".cursor/mcp.json", type: "local" }
542
- ];
543
- osSpecificPaths["vscode"] = [
544
- { filePath: ".vscode/mcp.json", type: "local" },
545
- { filePath: "~/Library/Application Support/Code/User/settings.json", type: "global" },
546
- { filePath: "~/Library/Application Support/Code/User/mcp.json", type: "global" },
547
- { filePath: "~/Library/Application Support/Code - Insiders/User/settings.json", type: "global" },
548
- { filePath: "~/Library/Application Support/Code - Insiders/User/mcp.json", type: "global" }
549
- ];
550
- osSpecificPaths["cline"] = [
551
- { filePath: "~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json", type: "global" },
552
- { filePath: "~/Library/Application Support/Code - Insiders/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json", type: "global" }
553
- ];
554
- osSpecificPaths["windsurf"] = [
555
- { filePath: ".codeium/windsurf/mcp_config.json", type: "local" }
556
- ];
557
- osSpecificPaths["roo"] = [
558
- { filePath: "~/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json", type: "global" },
559
- { filePath: "~/Library/Application Support/Code - Insiders/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json", type: "global" }
560
- ];
561
- osSpecificPaths["intellij-github-copilot"] = [
562
- { filePath: "~/.config/github-copilot/intellij/mcp.json", type: "global" }
563
- ];
564
- osSpecificPaths["junie"] = [
565
- { filePath: "~/.junie/mcp/mcp.json", type: "global" },
566
- { filePath: ".junie/mcp/mcp.json", type: "local" }
567
- ];
568
- osSpecificPaths["zed"] = [
569
- { filePath: "~/.config/zed/settings.json", type: "global" },
570
- { filePath: ".zed/settings.json", type: "local" }
571
- ];
572
- }
573
1102
  var MCPFiles = class {
574
1103
  static {
575
1104
  __name(this, "MCPFiles");
576
1105
  }
577
- mcpFilePathGroups = {
578
- claude: {
579
- name: "claude-desktop",
580
- friendlyName: "Claude Desktop",
581
- paths: osSpecificPaths["claude"]
582
- },
583
- claude_code: {
584
- name: "claude-code",
585
- friendlyName: "Claude Code",
586
- paths: osSpecificPaths["claude_code"]
587
- },
588
- cursor: {
589
- name: "cursor",
590
- friendlyName: "Cursor",
591
- paths: osSpecificPaths["cursor"]
592
- },
593
- vscode: {
594
- name: "vscode",
595
- friendlyName: "VS Code",
596
- paths: osSpecificPaths["vscode"]
597
- },
598
- cline: {
599
- name: "cline",
600
- friendlyName: "Cline",
601
- paths: osSpecificPaths["cline"]
602
- },
603
- windsurf: {
604
- name: "windsurf",
605
- friendlyName: "Windsurf",
606
- paths: osSpecificPaths["windsurf"]
607
- },
608
- roo: {
609
- name: "roo",
610
- friendlyName: "Roo",
611
- paths: osSpecificPaths["roo"]
612
- },
613
- "intellij-github-copilot": {
614
- name: "intellij-github-copilot",
615
- friendlyName: "IntelliJ GitHub Copilot",
616
- paths: osSpecificPaths["intellij-github-copilot"]
617
- },
618
- junie: {
619
- name: "junie",
620
- friendlyName: "IntelliJ Junie",
621
- paths: osSpecificPaths["junie"]
622
- },
623
- zed: {
624
- name: "zed",
625
- friendlyName: "Zed",
626
- paths: osSpecificPaths["zed"]
627
- }
628
- };
629
- constructor(mcpFilePathGroups) {
630
- this.mcpFilePathGroups = mcpFilePathGroups || this.mcpFilePathGroups;
1106
+ mcpConfigService;
1107
+ constructor() {
1108
+ this.mcpConfigService = new MCPConfigService();
631
1109
  }
1110
+ /**
1111
+ * Find and process all MCP configuration files
1112
+ */
632
1113
  async findFiles() {
633
- const mcpFilesPathsData = {};
634
- for (const groupName of Object.keys(this.mcpFilePathGroups)) {
635
- const clientsGroup = this.mcpFilePathGroups[groupName];
636
- mcpFilesPathsData[groupName] = {
637
- name: clientsGroup.name,
638
- friendlyName: clientsGroup.friendlyName,
639
- paths: [],
640
- stats: {}
641
- };
642
- const uniqueFilePaths = /* @__PURE__ */ new Set();
643
- for (const filePathData of clientsGroup.paths) {
644
- const resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
645
- const absolutePath = path2.resolve(resolvedPath);
646
- if (uniqueFilePaths.has(absolutePath)) {
647
- continue;
648
- }
649
- uniqueFilePaths.add(absolutePath);
650
- try {
651
- await fs2.access(resolvedPath);
652
- const MCPConfigLinter = new MCPConfigLinterService(resolvedPath);
653
- const parsable = await MCPConfigLinter.isValidSyntax();
654
- filePathData.parsable = parsable;
655
- const mcpServersData = [];
656
- const mcpServersFromConfig = await MCPConfigLinter.getMCPServers();
657
- for (const serverName of Object.keys(mcpServersFromConfig)) {
658
- const serverConfigRaw = mcpServersFromConfig[serverName];
659
- const serverConfig = {
660
- name: serverName,
661
- command: serverConfigRaw.command || "",
662
- args: serverConfigRaw.args,
663
- url: serverConfigRaw.url,
664
- transport: serverConfigRaw.transport,
665
- type: serverConfigRaw.type,
666
- env: serverConfigRaw.env
667
- };
668
- const MCPServerManager = new MCPServerManagerService(serverConfig);
669
- const mcpServerProcessDetection = MCPServerManager.isRunning();
670
- let mcpServerProcess = false;
671
- if (mcpServerProcessDetection) {
672
- if (typeof mcpServerProcessDetection === "object" && mcpServerProcessDetection.estimatedProduct === clientsGroup.name) {
673
- mcpServerProcess = true;
1114
+ try {
1115
+ const mcpFilesPathsData = await this.mcpConfigService.getMCPFileGroups();
1116
+ for (const groupName of Object.keys(mcpFilesPathsData)) {
1117
+ const group = mcpFilesPathsData[groupName];
1118
+ for (const filePathData of group.paths) {
1119
+ if (filePathData.servers && filePathData.servers.length > 0) {
1120
+ for (const server of filePathData.servers) {
1121
+ const serverConfig = {
1122
+ name: server.name,
1123
+ command: server.command,
1124
+ args: server.args,
1125
+ transport: server.transport,
1126
+ // transport is always populated from type in the data layer
1127
+ type: server.type,
1128
+ env: server.env
1129
+ };
1130
+ const serverManager = new MCPServerManagerService(serverConfig);
1131
+ const processDetection = serverManager.isRunning();
1132
+ let isRunning = false;
1133
+ if (processDetection) {
1134
+ if (typeof processDetection === "object" && processDetection.estimatedProduct === group.name) {
1135
+ isRunning = true;
1136
+ }
674
1137
  }
1138
+ server.status = isRunning ? "running" : "stopped";
675
1139
  }
676
- mcpServersData.push({
677
- name: MCPServerManager.getName(),
678
- command: MCPServerManager.getCmd(),
679
- args: MCPServerManager.getArgs(),
680
- source: MCPServerManager.getSource(),
681
- transport: MCPServerManager.getTransport(),
682
- env: MCPServerManager.getEnv(),
683
- status: mcpServerProcess ? "running" : "stopped"
684
- });
685
1140
  }
686
- filePathData.servers = mcpServersData;
687
- mcpFilesPathsData[groupName]["stats"]["serversCount"] = await MCPConfigLinter.countMCPServers();
688
- mcpFilesPathsData[groupName].paths.push(filePathData);
689
- } catch (error) {
690
1141
  }
691
1142
  }
1143
+ return mcpFilesPathsData;
1144
+ } catch (error) {
1145
+ throw new Error(`Failed to find MCP files: ${error instanceof Error ? error.message : "Unknown error"}`);
692
1146
  }
693
- return mcpFilesPathsData;
1147
+ }
1148
+ /**
1149
+ * Get MCP configuration service instance for advanced operations
1150
+ */
1151
+ getMCPConfigService() {
1152
+ return this.mcpConfigService;
694
1153
  }
695
1154
  };
696
1155
  export {