ls-mcp 1.13.1 → 1.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/cli.mjs CHANGED
@@ -7,397 +7,10 @@ import { styleText as styleText12 } from "util";
7
7
 
8
8
  // src/services/mcp-config-service.ts
9
9
  import { platform } from "os";
10
- import path3 from "path";
11
- import fs3 from "fs/promises";
12
- import util from "util";
13
-
14
- // src/services/mcp-path-registry.ts
15
10
  import path from "path";
16
- var MCPPathRegistry = class _MCPPathRegistry {
17
- static {
18
- __name(this, "MCPPathRegistry");
19
- }
20
- static WINDOWS_PATHS = {
21
- claude: [
22
- { filePath: path.join(process.env.APPDATA || "", "Claude", "claude_desktop_config.json"), type: "global" }
23
- ],
24
- claude_code: [
25
- { filePath: ".mcp.json", type: "local" }
26
- ],
27
- cursor: [
28
- { filePath: path.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
29
- { filePath: path.join(".cursor", "mcp.json"), type: "local" }
30
- ],
31
- vscode: [
32
- { filePath: path.join(".vscode", "mcp.json"), type: "local" },
33
- { filePath: path.join(process.env.APPDATA || "", "Code", "User", "settings.json"), type: "global" },
34
- { filePath: path.join(process.env.APPDATA || "", "Code - Insiders", "User", "settings.json"), type: "global" },
35
- { filePath: path.join(process.env.APPDATA || "", "Code", "User", "mcp.json"), type: "global" },
36
- { filePath: path.join(process.env.APPDATA || "", "Code - Insiders", "User", "mcp.json"), type: "global" }
37
- ],
38
- cline: [
39
- { filePath: path.join(process.env.APPDATA || "", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
40
- { filePath: path.join(process.env.APPDATA || "", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
41
- ],
42
- windsurf: [
43
- { filePath: path.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
44
- ],
45
- roo: [
46
- { filePath: path.join(process.env.APPDATA || "", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
47
- { filePath: path.join(process.env.APPDATA || "", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
48
- ],
49
- "intellij-github-copilot": [
50
- { filePath: path.join(process.env.LOCALAPPDATA || "", "github-copilot", "intellij", "mcp.json"), type: "global" }
51
- ],
52
- junie: [
53
- { filePath: path.join(process.env.HOME || "", ".junie", "mcp", "mcp.json"), type: "global" }
54
- ],
55
- zed: [
56
- { filePath: path.join(process.env.LOCALAPPDATA || "", "zed", "settings.json"), type: "global" },
57
- { filePath: path.join(".zed", "settings.json"), type: "local" }
58
- ],
59
- gemini: [
60
- { filePath: path.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
61
- { filePath: path.join(".gemini", "settings.json"), type: "local" }
62
- ]
63
- };
64
- static DARWIN_PATHS = {
65
- claude: [
66
- { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Claude", "claude_desktop_config.json"), type: "global" }
67
- ],
68
- claude_code: [
69
- { filePath: ".mcp.json", type: "local" }
70
- ],
71
- cursor: [
72
- { filePath: path.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
73
- { filePath: path.join(".cursor", "mcp.json"), type: "local" }
74
- ],
75
- vscode: [
76
- { filePath: path.join(".vscode", "mcp.json"), type: "local" },
77
- { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "settings.json"), type: "global" },
78
- { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "mcp.json"), type: "global" },
79
- { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "settings.json"), type: "global" },
80
- { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "mcp.json"), type: "global" }
81
- ],
82
- cline: [
83
- { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
84
- { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
85
- ],
86
- windsurf: [
87
- { filePath: path.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
88
- ],
89
- roo: [
90
- { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
91
- { filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
92
- ],
93
- "intellij-github-copilot": [
94
- { filePath: path.join(process.env.HOME || "", ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
95
- ],
96
- junie: [
97
- { filePath: path.join(process.env.HOME || "", ".junie", "mcp", "mcp.json"), type: "global" },
98
- { filePath: path.join(".junie", "mcp", "mcp.json"), type: "local" }
99
- ],
100
- zed: [
101
- { filePath: path.join(process.env.HOME || "", ".config", "zed", "settings.json"), type: "global" },
102
- { filePath: path.join(".zed", "settings.json"), type: "local" }
103
- ],
104
- gemini: [
105
- { filePath: path.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
106
- { filePath: path.join(".gemini", "settings.json"), type: "local" }
107
- ]
108
- };
109
- static LINUX_PATHS = {
110
- claude: [
111
- { filePath: path.join(process.env.HOME || "", ".config", "Claude", "claude_desktop_config.json"), type: "global" }
112
- ],
113
- claude_code: [
114
- { filePath: ".mcp.json", type: "local" }
115
- ],
116
- cursor: [
117
- { filePath: path.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
118
- { filePath: path.join(".cursor", "mcp.json"), type: "local" }
119
- ],
120
- vscode: [
121
- { filePath: path.join(".vscode", "mcp.json"), type: "local" },
122
- { filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "settings.json"), type: "global" },
123
- { filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "settings.json"), type: "global" },
124
- { filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "mcp.json"), type: "global" },
125
- { filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "mcp.json"), type: "global" },
126
- { filePath: path.join(process.env.HOME || "", ".mcp.json"), type: "global" }
127
- ],
128
- cline: [
129
- { filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
130
- { filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
131
- ],
132
- windsurf: [
133
- { filePath: path.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
134
- ],
135
- roo: [
136
- { filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
137
- { filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
138
- ],
139
- "intellij-github-copilot": [
140
- { filePath: path.join(process.env.HOME || "", ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
141
- ],
142
- junie: [
143
- { filePath: path.join(process.env.HOME || "", ".junie", "mcp.json"), type: "global" },
144
- { filePath: path.join(".junie", "mcp", "mcp.json"), type: "local" }
145
- ],
146
- zed: [
147
- { filePath: path.join(process.env.HOME || "", ".config", "zed", "settings.json"), type: "global" },
148
- { filePath: path.join(".zed", "settings.json"), type: "local" }
149
- ],
150
- gemini: [
151
- { filePath: path.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
152
- { filePath: path.join(".gemini", "settings.json"), type: "local" }
153
- ]
154
- };
155
- customApps = /* @__PURE__ */ new Map();
156
- /**
157
- * Get all MCP configuration file paths for a specific operating system
158
- */
159
- getPathsForOS(os) {
160
- switch (os.toLowerCase()) {
161
- case "win32":
162
- case "windows":
163
- return { ..._MCPPathRegistry.WINDOWS_PATHS };
164
- case "darwin":
165
- case "macos":
166
- return { ..._MCPPathRegistry.DARWIN_PATHS };
167
- case "linux":
168
- return { ..._MCPPathRegistry.LINUX_PATHS };
169
- default:
170
- throw new Error(`Unsupported operating system: ${os}`);
171
- }
172
- }
173
- /**
174
- * Get MCP configuration file paths for a specific app on a specific OS
175
- */
176
- getPathsForApp(os, appName) {
177
- const osPaths = this.getPathsForOS(os);
178
- const appPaths = osPaths[appName];
179
- if (!appPaths) {
180
- throw new Error(`App '${appName}' not found for OS '${os}'`);
181
- }
182
- return [...appPaths];
183
- }
184
- /**
185
- * Get all supported app names for a specific OS
186
- */
187
- getSupportedApps(os) {
188
- const osPaths = this.getPathsForOS(os);
189
- return Object.keys(osPaths);
190
- }
191
- /**
192
- * Get all supported operating systems
193
- */
194
- getSupportedOperatingSystems() {
195
- return ["win32", "darwin", "linux"];
196
- }
197
- /**
198
- * Register a custom app with custom paths for a specific OS
199
- */
200
- registerCustomApp(os, appName, paths) {
201
- if (!this.customApps.has(os)) {
202
- this.customApps.set(os, {});
203
- }
204
- const osCustomApps = this.customApps.get(os);
205
- osCustomApps[appName] = [...paths];
206
- }
207
- /**
208
- * Get paths including custom registered apps
209
- */
210
- getPathsForOSWithCustom(os) {
211
- const basePaths = this.getPathsForOS(os);
212
- const customPaths = this.customApps.get(os) || {};
213
- return { ...basePaths, ...customPaths };
214
- }
215
- };
216
-
217
- // src/services/mcp-config-parser.ts
218
11
  import fs from "fs/promises";
219
- import { parse } from "jsonc-parser";
220
- var MCPConfigParser = class {
221
- static {
222
- __name(this, "MCPConfigParser");
223
- }
224
- filePath;
225
- fileContents = null;
226
- parsed = false;
227
- valid = false;
228
- fileContentsData = null;
229
- constructor(filePath) {
230
- this.filePath = filePath;
231
- }
232
- /**
233
- * Parse the configuration file and return structured data
234
- */
235
- async parseConfigFile() {
236
- if (this.parsed) {
237
- return {
238
- raw: this.fileContentsData,
239
- parsed: this.parsed,
240
- valid: this.valid,
241
- servers: await this.extractMCPServers(this.fileContentsData)
242
- };
243
- }
244
- this.parsed = true;
245
- const fileContent = await this.getFileContent();
246
- try {
247
- this.fileContentsData = JSON.parse(fileContent);
248
- if (typeof this.fileContentsData === "object") {
249
- this.valid = true;
250
- }
251
- } catch (e) {
252
- }
253
- if (!this.valid) {
254
- try {
255
- this.fileContentsData = parse(fileContent);
256
- if (typeof this.fileContentsData === "object") {
257
- this.valid = true;
258
- }
259
- } catch (error) {
260
- }
261
- }
262
- if (!this.valid) {
263
- throw new Error(`Failed to parse configuration file: ${this.filePath}`);
264
- }
265
- return {
266
- raw: this.fileContentsData,
267
- parsed: this.parsed,
268
- valid: this.valid,
269
- servers: await this.extractMCPServers(this.fileContentsData)
270
- };
271
- }
272
- /**
273
- * Extract MCP servers from parsed configuration data
274
- */
275
- async extractMCPServers(configData) {
276
- if (!configData || typeof configData !== "object") {
277
- return {};
278
- }
279
- if (configData.servers && typeof configData.servers === "object") {
280
- return this.normalizeServerConfigs(configData.servers);
281
- }
282
- if (configData.mcp?.servers && typeof configData.mcp.servers === "object") {
283
- return this.normalizeServerConfigs(configData.mcp.servers);
284
- }
285
- if (configData.mcpServers && typeof configData.mcpServers === "object") {
286
- return this.normalizeServerConfigs(configData.mcpServers);
287
- }
288
- if (configData.context_servers && typeof configData.context_servers === "object") {
289
- return this.normalizeServerConfigs(configData.context_servers);
290
- }
291
- return {};
292
- }
293
- /**
294
- * Normalize server configurations to ensure consistent structure
295
- */
296
- normalizeServerConfigs(servers) {
297
- const normalized = {};
298
- for (const [serverName, serverConfig] of Object.entries(servers)) {
299
- if (serverConfig && typeof serverConfig === "object") {
300
- const env = serverConfig.env && typeof serverConfig.env === "object" ? serverConfig.env : void 0;
301
- normalized[serverName] = {
302
- name: serverName,
303
- command: serverConfig.command || "",
304
- args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
305
- type: this.validateType(serverConfig.type) ? serverConfig.type : this.inferTransportType(serverConfig),
306
- url: serverConfig.url,
307
- env
308
- };
309
- }
310
- }
311
- return normalized;
312
- }
313
- /**
314
- * Validate type value
315
- */
316
- validateType(type) {
317
- return ["sse", "http", "stdio", "streamable-http"].includes(type);
318
- }
319
- /**
320
- * Infer transport type from server configuration when type field is not explicitly set
321
- */
322
- inferTransportType(serverConfig) {
323
- if (serverConfig.url && typeof serverConfig.url === "string") {
324
- return "http";
325
- }
326
- if (Array.isArray(serverConfig.args)) {
327
- const argsString = serverConfig.args.join(" ").toLowerCase();
328
- if (argsString.includes("stdio")) {
329
- return "stdio";
330
- }
331
- if (argsString.includes("http")) {
332
- return "http";
333
- }
334
- if (argsString.includes("sse")) {
335
- return "sse";
336
- }
337
- }
338
- if (serverConfig.command && typeof serverConfig.command === "string") {
339
- return "stdio";
340
- }
341
- return void 0;
342
- }
343
- /**
344
- * Validate server configuration
345
- */
346
- validateServerConfig(serverConfig) {
347
- if (!serverConfig || typeof serverConfig !== "object") {
348
- return false;
349
- }
350
- if (!serverConfig.name || typeof serverConfig.name !== "string") {
351
- return false;
352
- }
353
- if (!serverConfig.command || typeof serverConfig.command !== "string") {
354
- return false;
355
- }
356
- return true;
357
- }
358
- /**
359
- * Get supported configuration keys that the parser recognizes
360
- */
361
- getSupportedConfigKeys() {
362
- return ["servers", "mcp.servers", "mcpServers", "context_servers"];
363
- }
364
- /**
365
- * Check if the configuration file has valid syntax
366
- */
367
- async isValidSyntax() {
368
- try {
369
- const configData = await this.parseConfigFile();
370
- return configData.valid;
371
- } catch (error) {
372
- return false;
373
- }
374
- }
375
- /**
376
- * Count the number of MCP servers in the configuration
377
- */
378
- async countMCPServers() {
379
- try {
380
- const configData = await this.parseConfigFile();
381
- return Object.keys(configData.servers).length;
382
- } catch (error) {
383
- return 0;
384
- }
385
- }
386
- /**
387
- * Get the raw file content
388
- */
389
- async getFileContent() {
390
- if (this.fileContents) {
391
- return this.fileContents;
392
- }
393
- try {
394
- this.fileContents = await fs.readFile(this.filePath, "utf-8");
395
- return this.fileContents;
396
- } catch (error) {
397
- throw new Error(`Failed to read file: ${this.filePath}`);
398
- }
399
- }
400
- };
12
+ import util from "util";
13
+ import { MCPPathRegistry, MCPConfigParser, DirectoryBubbleService } from "agent-files";
401
14
 
402
15
  // src/services/credential-detection-service.ts
403
16
  var CredentialDetectionService = class {
@@ -513,8 +126,8 @@ var CredentialDetectionService = class {
513
126
  /**
514
127
  * Analyze command-line arguments for potential credentials
515
128
  */
516
- static analyzeArguments(args) {
517
- if (!args || !Array.isArray(args) || args.length === 0) {
129
+ static analyzeArguments(args2) {
130
+ if (!args2 || !Array.isArray(args2) || args2.length === 0) {
518
131
  return {
519
132
  hasCredentials: false,
520
133
  credentialVars: [],
@@ -522,9 +135,9 @@ var CredentialDetectionService = class {
522
135
  };
523
136
  }
524
137
  const credentialVars = [];
525
- for (let i = 0; i < args.length - 1; i++) {
526
- const arg = args[i];
527
- const nextArg = args[i + 1];
138
+ for (let i = 0; i < args2.length - 1; i++) {
139
+ const arg = args2[i];
140
+ const nextArg = args2[i + 1];
528
141
  const isHighRiskArg = this.ARGUMENT_PATTERNS.high.some((pattern) => pattern.test(arg));
529
142
  const isLowRiskArg = this.ARGUMENT_PATTERNS.low.some((pattern) => pattern.test(arg));
530
143
  if (isHighRiskArg || isLowRiskArg) {
@@ -680,77 +293,6 @@ var CredentialDetectionService = class {
680
293
  }
681
294
  };
682
295
 
683
- // src/services/directory-bubble-service.ts
684
- import path2 from "path";
685
- import fs2 from "fs/promises";
686
- import { homedir } from "os";
687
- var DirectoryBubbleService = class {
688
- static {
689
- __name(this, "DirectoryBubbleService");
690
- }
691
- /**
692
- * Find a local MCP config file by bubbling up the directory tree
693
- * @param localPath - The relative path to search for (e.g., '.vscode/mcp.json')
694
- * @param startDir - The directory to start searching from
695
- * @returns The absolute path to the found config file, or null if not found
696
- */
697
- async findLocalConfigInParentDirectories(localPath, startDir) {
698
- try {
699
- let currentDir = path2.resolve(startDir);
700
- const homeDir = homedir();
701
- const rootDir = "/";
702
- let iterationCount = 0;
703
- const maxIterations = 100;
704
- const startDirResult = await this.checkDirectoryForConfig(currentDir, localPath);
705
- if (startDirResult) {
706
- return path2.join(currentDir, localPath);
707
- }
708
- while (currentDir !== homeDir && currentDir !== rootDir && iterationCount < maxIterations) {
709
- const parentDir = this.getParentDirectory(currentDir);
710
- if (!parentDir || parentDir === currentDir) {
711
- break;
712
- }
713
- if (parentDir === currentDir || parentDir.length >= currentDir.length) {
714
- break;
715
- }
716
- currentDir = parentDir;
717
- iterationCount++;
718
- const found = await this.checkDirectoryForConfig(currentDir, localPath);
719
- if (found) {
720
- return path2.join(currentDir, localPath);
721
- }
722
- }
723
- return null;
724
- } catch (error) {
725
- return null;
726
- }
727
- }
728
- /**
729
- * Check if a config file exists in the specified directory
730
- * @param dir - The directory to check
731
- * @param configPath - The relative path to the config file
732
- * @returns True if the config file exists and is accessible
733
- */
734
- async checkDirectoryForConfig(dir, configPath) {
735
- try {
736
- const fullPath = path2.join(dir, configPath);
737
- await fs2.access(fullPath);
738
- return true;
739
- } catch (error) {
740
- return false;
741
- }
742
- }
743
- /**
744
- * Get the parent directory of the specified directory
745
- * @param dir - The directory to get the parent of
746
- * @returns The parent directory path, or null if already at root
747
- */
748
- getParentDirectory(dir) {
749
- const parent = path2.dirname(dir);
750
- return parent === dir ? null : parent;
751
- }
752
- };
753
-
754
296
  // src/services/mcp-version-detection-service.ts
755
297
  var MCPVersionDetectionService = class {
756
298
  static {
@@ -762,14 +304,14 @@ var MCPVersionDetectionService = class {
762
304
  * @param args - Array of arguments passed to the command
763
305
  * @returns PackageVersionInfo if analysis is possible, null otherwise
764
306
  */
765
- analyzeServerVersion(command, args) {
307
+ analyzeServerVersion(command, args2) {
766
308
  if (!["npx", "uvx", "uv"].includes(command)) {
767
309
  return null;
768
310
  }
769
- if (!args || args.length === 0) {
311
+ if (!args2 || args2.length === 0) {
770
312
  return null;
771
313
  }
772
- const packageName = this.extractPackageName(command, args);
314
+ const packageName = this.extractPackageName(command, args2);
773
315
  if (!packageName) {
774
316
  return null;
775
317
  }
@@ -788,14 +330,14 @@ var MCPVersionDetectionService = class {
788
330
  * @param args - Array of arguments passed to the command
789
331
  * @returns The package name/spec or null if not found
790
332
  */
791
- extractPackageName(command, args) {
333
+ extractPackageName(command, args2) {
792
334
  switch (command) {
793
335
  case "npx":
794
- return this.extractNpxPackageName(args);
336
+ return this.extractNpxPackageName(args2);
795
337
  case "uvx":
796
- return this.extractUvxPackageName(args);
338
+ return this.extractUvxPackageName(args2);
797
339
  case "uv":
798
- return this.extractUvPackageName(args);
340
+ return this.extractUvPackageName(args2);
799
341
  default:
800
342
  return null;
801
343
  }
@@ -805,23 +347,23 @@ var MCPVersionDetectionService = class {
805
347
  * @param args - Array of arguments passed to npx
806
348
  * @returns The package name/spec or null if not found
807
349
  */
808
- extractNpxPackageName(args) {
809
- if (!args || args.length === 0) {
350
+ extractNpxPackageName(args2) {
351
+ if (!args2 || args2.length === 0) {
810
352
  return null;
811
353
  }
812
- const yIndex = args.indexOf("-y");
813
- if (yIndex !== -1 && yIndex + 1 < args.length) {
814
- return args[yIndex + 1];
354
+ const yIndex = args2.indexOf("-y");
355
+ if (yIndex !== -1 && yIndex + 1 < args2.length) {
356
+ return args2[yIndex + 1];
815
357
  }
816
- const yesIndex = args.indexOf("--yes");
817
- if (yesIndex !== -1 && yesIndex + 1 < args.length) {
818
- return args[yesIndex + 1];
358
+ const yesIndex = args2.indexOf("--yes");
359
+ if (yesIndex !== -1 && yesIndex + 1 < args2.length) {
360
+ return args2[yesIndex + 1];
819
361
  }
820
- for (let i = 0; i < args.length; i++) {
821
- const arg = args[i];
362
+ for (let i = 0; i < args2.length; i++) {
363
+ const arg = args2[i];
822
364
  if (!arg.startsWith("-")) {
823
365
  if (i > 0) {
824
- const prevArg = args[i - 1];
366
+ const prevArg = args2[i - 1];
825
367
  if (prevArg === "--registry" || prevArg === "-r" || prevArg === "--package" || prevArg === "-p") {
826
368
  continue;
827
369
  }
@@ -836,24 +378,24 @@ var MCPVersionDetectionService = class {
836
378
  * @param args - Array of arguments passed to uvx
837
379
  * @returns The package name/spec or null if not found
838
380
  */
839
- extractUvxPackageName(args) {
840
- if (!args || args.length === 0) {
381
+ extractUvxPackageName(args2) {
382
+ if (!args2 || args2.length === 0) {
841
383
  return null;
842
384
  }
843
- return args[0];
385
+ return args2[0];
844
386
  }
845
387
  /**
846
388
  * Extract the package name from uv arguments
847
389
  * @param args - Array of arguments passed to uv
848
390
  * @returns The package name/spec or null if not found
849
391
  */
850
- extractUvPackageName(args) {
851
- if (!args || args.length === 0) {
392
+ extractUvPackageName(args2) {
393
+ if (!args2 || args2.length === 0) {
852
394
  return null;
853
395
  }
854
- const runIndex = args.indexOf("run");
855
- if (runIndex !== -1 && runIndex + 1 < args.length) {
856
- return args[runIndex + 1];
396
+ const runIndex = args2.indexOf("run");
397
+ if (runIndex !== -1 && runIndex + 1 < args2.length) {
398
+ return args2[runIndex + 1];
857
399
  }
858
400
  return null;
859
401
  }
@@ -1019,7 +561,7 @@ var MCPConfigService = class {
1019
561
  */
1020
562
  async validateConfigFile(filePath) {
1021
563
  try {
1022
- await fs3.access(filePath);
564
+ await fs.access(filePath);
1023
565
  const parser = this.createParser(filePath);
1024
566
  return await parser.isValidSyntax();
1025
567
  } catch (error) {
@@ -1039,7 +581,8 @@ var MCPConfigService = class {
1039
581
  try {
1040
582
  const appPaths = this.getAllConfigFiles();
1041
583
  const mcpFilesPathsData = {};
1042
- for (const [groupName, paths] of Object.entries(appPaths)) {
584
+ for (const groupName of Object.keys(appPaths)) {
585
+ const paths = appPaths[groupName];
1043
586
  mcpFilesPathsData[groupName] = {
1044
587
  name: groupName,
1045
588
  friendlyName: this.getFriendlyName(groupName),
@@ -1050,10 +593,10 @@ var MCPConfigService = class {
1050
593
  let totalServersCount = 0;
1051
594
  for (const filePathData of paths) {
1052
595
  let resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
1053
- let absolutePath = path3.resolve(resolvedPath);
596
+ let absolutePath = path.resolve(resolvedPath);
1054
597
  if (filePathData.type === "local" && this.enableDirectoryBubbling) {
1055
598
  try {
1056
- await fs3.access(resolvedPath);
599
+ await fs.access(resolvedPath);
1057
600
  } catch (error) {
1058
601
  const bubbledPath = await this.directoryBubbleService.findLocalConfigInParentDirectories(
1059
602
  filePathData.filePath,
@@ -1061,7 +604,7 @@ var MCPConfigService = class {
1061
604
  );
1062
605
  if (bubbledPath) {
1063
606
  resolvedPath = bubbledPath;
1064
- absolutePath = path3.resolve(resolvedPath);
607
+ absolutePath = path.resolve(resolvedPath);
1065
608
  }
1066
609
  }
1067
610
  }
@@ -1070,7 +613,7 @@ var MCPConfigService = class {
1070
613
  }
1071
614
  uniqueFilePaths.add(absolutePath);
1072
615
  try {
1073
- await fs3.access(resolvedPath);
616
+ await fs.access(resolvedPath);
1074
617
  const parser = this.createParser(resolvedPath);
1075
618
  const parsable = await parser.isValidSyntax();
1076
619
  filePathData.parsable = parsable;
@@ -1179,7 +722,7 @@ var MCPConfigService = class {
1179
722
  };
1180
723
 
1181
724
  // src/services/mcp-server-manager-service.ts
1182
- import path4 from "path";
725
+ import path2 from "path";
1183
726
  import { execSync } from "child_process";
1184
727
  import { platform as platform2 } from "os";
1185
728
  var MCPServerManagerService = class {
@@ -1389,9 +932,9 @@ var MCPServerManagerService = class {
1389
932
  return true;
1390
933
  }
1391
934
  getBaseCommand(fullCommandPath) {
1392
- let baseCommand = path4.basename(fullCommandPath);
935
+ let baseCommand = path2.basename(fullCommandPath);
1393
936
  if (platform2() === "win32") {
1394
- baseCommand = path4.basename(fullCommandPath, ".exe");
937
+ baseCommand = path2.basename(fullCommandPath, ".exe");
1395
938
  }
1396
939
  baseCommand = baseCommand.toLowerCase();
1397
940
  return baseCommand;
@@ -2017,9 +1560,13 @@ var RenderService = class _RenderService {
2017
1560
  };
2018
1561
 
2019
1562
  // src/bin/cli.ts
1563
+ var args = process.argv.slice(2);
1564
+ var jsonOutput = args.includes("--json");
2020
1565
  async function init() {
2021
- console.log();
2022
- console.log("[+] Detecting MCP Server configurations...");
1566
+ if (!jsonOutput) {
1567
+ console.log();
1568
+ console.log("[+] Detecting MCP Server configurations...");
1569
+ }
2023
1570
  const mcpFilesManager = new MCPFiles();
2024
1571
  const mcpFilesList = await mcpFilesManager.findFiles();
2025
1572
  if (Object.keys(mcpFilesList).length === 0) {
@@ -2058,18 +1605,20 @@ async function init() {
2058
1605
  totalImplicitLatestVersions++;
2059
1606
  }
2060
1607
  }
2061
- const mcpGroupData = [
2062
- { key: "PROVIDER", value: group.friendlyName },
2063
- { key: "FILE", value: filePath },
2064
- { key: "TYPE", value: filePathDataType },
2065
- { key: "PARSABLE", value: filePathValid }
2066
- ];
2067
- const groupMetadata = {
2068
- mcpServersTotal: totalMCPServers,
2069
- mcpServersRunning: totalMCPServersRunning
2070
- };
2071
- RenderService.printMcpGroup(pathIndex, mcpGroupData, groupMetadata);
2072
- RenderService.printMcpServers(mcpServers);
1608
+ if (!jsonOutput) {
1609
+ const mcpGroupData = [
1610
+ { key: "PROVIDER", value: group.friendlyName },
1611
+ { key: "FILE", value: filePath },
1612
+ { key: "TYPE", value: filePathDataType },
1613
+ { key: "PARSABLE", value: filePathValid }
1614
+ ];
1615
+ const groupMetadata = {
1616
+ mcpServersTotal: totalMCPServers,
1617
+ mcpServersRunning: totalMCPServersRunning
1618
+ };
1619
+ RenderService.printMcpGroup(pathIndex, mcpGroupData, groupMetadata);
1620
+ RenderService.printMcpServers(mcpServers);
1621
+ }
2073
1622
  }
2074
1623
  }
2075
1624
  }
@@ -2083,7 +1632,18 @@ async function init() {
2083
1632
  implicitLatestVersions: totalImplicitLatestVersions,
2084
1633
  transportBreakdown: transportCounts
2085
1634
  };
2086
- RenderService.printSummary(summaryStats);
1635
+ if (jsonOutput) {
1636
+ const filteredMcpFiles = Object.fromEntries(
1637
+ Object.entries(mcpFilesList).filter(([, group]) => group.paths.length > 0)
1638
+ );
1639
+ const output = {
1640
+ mcpFiles: filteredMcpFiles,
1641
+ summary: summaryStats
1642
+ };
1643
+ console.log(JSON.stringify(output, null, 2));
1644
+ } else {
1645
+ RenderService.printSummary(summaryStats);
1646
+ }
2087
1647
  }
2088
1648
  __name(init, "init");
2089
1649
  init().then(() => {