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.cjs CHANGED
@@ -28,398 +28,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var import_node_util13 = require("util");
29
29
 
30
30
  // src/services/mcp-config-service.ts
31
- var import_node_os2 = require("os");
32
- var import_node_path3 = __toESM(require("path"), 1);
33
- var import_promises3 = __toESM(require("fs/promises"), 1);
34
- var import_node_util = __toESM(require("util"), 1);
35
-
36
- // src/services/mcp-path-registry.ts
31
+ var import_node_os = require("os");
37
32
  var import_node_path = __toESM(require("path"), 1);
38
- var MCPPathRegistry = class _MCPPathRegistry {
39
- static {
40
- __name(this, "MCPPathRegistry");
41
- }
42
- static WINDOWS_PATHS = {
43
- claude: [
44
- { filePath: import_node_path.default.join(process.env.APPDATA || "", "Claude", "claude_desktop_config.json"), type: "global" }
45
- ],
46
- claude_code: [
47
- { filePath: ".mcp.json", type: "local" }
48
- ],
49
- cursor: [
50
- { filePath: import_node_path.default.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
51
- { filePath: import_node_path.default.join(".cursor", "mcp.json"), type: "local" }
52
- ],
53
- vscode: [
54
- { filePath: import_node_path.default.join(".vscode", "mcp.json"), type: "local" },
55
- { filePath: import_node_path.default.join(process.env.APPDATA || "", "Code", "User", "settings.json"), type: "global" },
56
- { filePath: import_node_path.default.join(process.env.APPDATA || "", "Code - Insiders", "User", "settings.json"), type: "global" },
57
- { filePath: import_node_path.default.join(process.env.APPDATA || "", "Code", "User", "mcp.json"), type: "global" },
58
- { filePath: import_node_path.default.join(process.env.APPDATA || "", "Code - Insiders", "User", "mcp.json"), type: "global" }
59
- ],
60
- cline: [
61
- { filePath: import_node_path.default.join(process.env.APPDATA || "", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
62
- { filePath: import_node_path.default.join(process.env.APPDATA || "", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
63
- ],
64
- windsurf: [
65
- { filePath: import_node_path.default.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
66
- ],
67
- roo: [
68
- { filePath: import_node_path.default.join(process.env.APPDATA || "", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
69
- { filePath: import_node_path.default.join(process.env.APPDATA || "", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
70
- ],
71
- "intellij-github-copilot": [
72
- { filePath: import_node_path.default.join(process.env.LOCALAPPDATA || "", "github-copilot", "intellij", "mcp.json"), type: "global" }
73
- ],
74
- junie: [
75
- { filePath: import_node_path.default.join(process.env.HOME || "", ".junie", "mcp", "mcp.json"), type: "global" }
76
- ],
77
- zed: [
78
- { filePath: import_node_path.default.join(process.env.LOCALAPPDATA || "", "zed", "settings.json"), type: "global" },
79
- { filePath: import_node_path.default.join(".zed", "settings.json"), type: "local" }
80
- ],
81
- gemini: [
82
- { filePath: import_node_path.default.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
83
- { filePath: import_node_path.default.join(".gemini", "settings.json"), type: "local" }
84
- ]
85
- };
86
- static DARWIN_PATHS = {
87
- claude: [
88
- { filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Claude", "claude_desktop_config.json"), type: "global" }
89
- ],
90
- claude_code: [
91
- { filePath: ".mcp.json", type: "local" }
92
- ],
93
- cursor: [
94
- { filePath: import_node_path.default.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
95
- { filePath: import_node_path.default.join(".cursor", "mcp.json"), type: "local" }
96
- ],
97
- vscode: [
98
- { filePath: import_node_path.default.join(".vscode", "mcp.json"), type: "local" },
99
- { filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "settings.json"), type: "global" },
100
- { filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "mcp.json"), type: "global" },
101
- { filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "settings.json"), type: "global" },
102
- { filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "mcp.json"), type: "global" }
103
- ],
104
- cline: [
105
- { 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" },
106
- { 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" }
107
- ],
108
- windsurf: [
109
- { filePath: import_node_path.default.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
110
- ],
111
- roo: [
112
- { 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" },
113
- { 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" }
114
- ],
115
- "intellij-github-copilot": [
116
- { filePath: import_node_path.default.join(process.env.HOME || "", ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
117
- ],
118
- junie: [
119
- { filePath: import_node_path.default.join(process.env.HOME || "", ".junie", "mcp", "mcp.json"), type: "global" },
120
- { filePath: import_node_path.default.join(".junie", "mcp", "mcp.json"), type: "local" }
121
- ],
122
- zed: [
123
- { filePath: import_node_path.default.join(process.env.HOME || "", ".config", "zed", "settings.json"), type: "global" },
124
- { filePath: import_node_path.default.join(".zed", "settings.json"), type: "local" }
125
- ],
126
- gemini: [
127
- { filePath: import_node_path.default.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
128
- { filePath: import_node_path.default.join(".gemini", "settings.json"), type: "local" }
129
- ]
130
- };
131
- static LINUX_PATHS = {
132
- claude: [
133
- { filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Claude", "claude_desktop_config.json"), type: "global" }
134
- ],
135
- claude_code: [
136
- { filePath: ".mcp.json", type: "local" }
137
- ],
138
- cursor: [
139
- { filePath: import_node_path.default.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
140
- { filePath: import_node_path.default.join(".cursor", "mcp.json"), type: "local" }
141
- ],
142
- vscode: [
143
- { filePath: import_node_path.default.join(".vscode", "mcp.json"), type: "local" },
144
- { filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code", "User", "settings.json"), type: "global" },
145
- { filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "settings.json"), type: "global" },
146
- { filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code", "User", "mcp.json"), type: "global" },
147
- { filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "mcp.json"), type: "global" },
148
- { filePath: import_node_path.default.join(process.env.HOME || "", ".mcp.json"), type: "global" }
149
- ],
150
- cline: [
151
- { filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
152
- { filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
153
- ],
154
- windsurf: [
155
- { filePath: import_node_path.default.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
156
- ],
157
- roo: [
158
- { filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
159
- { filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
160
- ],
161
- "intellij-github-copilot": [
162
- { filePath: import_node_path.default.join(process.env.HOME || "", ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
163
- ],
164
- junie: [
165
- { filePath: import_node_path.default.join(process.env.HOME || "", ".junie", "mcp.json"), type: "global" },
166
- { filePath: import_node_path.default.join(".junie", "mcp", "mcp.json"), type: "local" }
167
- ],
168
- zed: [
169
- { filePath: import_node_path.default.join(process.env.HOME || "", ".config", "zed", "settings.json"), type: "global" },
170
- { filePath: import_node_path.default.join(".zed", "settings.json"), type: "local" }
171
- ],
172
- gemini: [
173
- { filePath: import_node_path.default.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
174
- { filePath: import_node_path.default.join(".gemini", "settings.json"), type: "local" }
175
- ]
176
- };
177
- customApps = /* @__PURE__ */ new Map();
178
- /**
179
- * Get all MCP configuration file paths for a specific operating system
180
- */
181
- getPathsForOS(os) {
182
- switch (os.toLowerCase()) {
183
- case "win32":
184
- case "windows":
185
- return { ..._MCPPathRegistry.WINDOWS_PATHS };
186
- case "darwin":
187
- case "macos":
188
- return { ..._MCPPathRegistry.DARWIN_PATHS };
189
- case "linux":
190
- return { ..._MCPPathRegistry.LINUX_PATHS };
191
- default:
192
- throw new Error(`Unsupported operating system: ${os}`);
193
- }
194
- }
195
- /**
196
- * Get MCP configuration file paths for a specific app on a specific OS
197
- */
198
- getPathsForApp(os, appName) {
199
- const osPaths = this.getPathsForOS(os);
200
- const appPaths = osPaths[appName];
201
- if (!appPaths) {
202
- throw new Error(`App '${appName}' not found for OS '${os}'`);
203
- }
204
- return [...appPaths];
205
- }
206
- /**
207
- * Get all supported app names for a specific OS
208
- */
209
- getSupportedApps(os) {
210
- const osPaths = this.getPathsForOS(os);
211
- return Object.keys(osPaths);
212
- }
213
- /**
214
- * Get all supported operating systems
215
- */
216
- getSupportedOperatingSystems() {
217
- return ["win32", "darwin", "linux"];
218
- }
219
- /**
220
- * Register a custom app with custom paths for a specific OS
221
- */
222
- registerCustomApp(os, appName, paths) {
223
- if (!this.customApps.has(os)) {
224
- this.customApps.set(os, {});
225
- }
226
- const osCustomApps = this.customApps.get(os);
227
- osCustomApps[appName] = [...paths];
228
- }
229
- /**
230
- * Get paths including custom registered apps
231
- */
232
- getPathsForOSWithCustom(os) {
233
- const basePaths = this.getPathsForOS(os);
234
- const customPaths = this.customApps.get(os) || {};
235
- return { ...basePaths, ...customPaths };
236
- }
237
- };
238
-
239
- // src/services/mcp-config-parser.ts
240
33
  var import_promises = __toESM(require("fs/promises"), 1);
241
- var import_jsonc_parser = require("jsonc-parser");
242
- var MCPConfigParser = class {
243
- static {
244
- __name(this, "MCPConfigParser");
245
- }
246
- filePath;
247
- fileContents = null;
248
- parsed = false;
249
- valid = false;
250
- fileContentsData = null;
251
- constructor(filePath) {
252
- this.filePath = filePath;
253
- }
254
- /**
255
- * Parse the configuration file and return structured data
256
- */
257
- async parseConfigFile() {
258
- if (this.parsed) {
259
- return {
260
- raw: this.fileContentsData,
261
- parsed: this.parsed,
262
- valid: this.valid,
263
- servers: await this.extractMCPServers(this.fileContentsData)
264
- };
265
- }
266
- this.parsed = true;
267
- const fileContent = await this.getFileContent();
268
- try {
269
- this.fileContentsData = JSON.parse(fileContent);
270
- if (typeof this.fileContentsData === "object") {
271
- this.valid = true;
272
- }
273
- } catch (e) {
274
- }
275
- if (!this.valid) {
276
- try {
277
- this.fileContentsData = (0, import_jsonc_parser.parse)(fileContent);
278
- if (typeof this.fileContentsData === "object") {
279
- this.valid = true;
280
- }
281
- } catch (error) {
282
- }
283
- }
284
- if (!this.valid) {
285
- throw new Error(`Failed to parse configuration file: ${this.filePath}`);
286
- }
287
- return {
288
- raw: this.fileContentsData,
289
- parsed: this.parsed,
290
- valid: this.valid,
291
- servers: await this.extractMCPServers(this.fileContentsData)
292
- };
293
- }
294
- /**
295
- * Extract MCP servers from parsed configuration data
296
- */
297
- async extractMCPServers(configData) {
298
- if (!configData || typeof configData !== "object") {
299
- return {};
300
- }
301
- if (configData.servers && typeof configData.servers === "object") {
302
- return this.normalizeServerConfigs(configData.servers);
303
- }
304
- if (configData.mcp?.servers && typeof configData.mcp.servers === "object") {
305
- return this.normalizeServerConfigs(configData.mcp.servers);
306
- }
307
- if (configData.mcpServers && typeof configData.mcpServers === "object") {
308
- return this.normalizeServerConfigs(configData.mcpServers);
309
- }
310
- if (configData.context_servers && typeof configData.context_servers === "object") {
311
- return this.normalizeServerConfigs(configData.context_servers);
312
- }
313
- return {};
314
- }
315
- /**
316
- * Normalize server configurations to ensure consistent structure
317
- */
318
- normalizeServerConfigs(servers) {
319
- const normalized = {};
320
- for (const [serverName, serverConfig] of Object.entries(servers)) {
321
- if (serverConfig && typeof serverConfig === "object") {
322
- const env = serverConfig.env && typeof serverConfig.env === "object" ? serverConfig.env : void 0;
323
- normalized[serverName] = {
324
- name: serverName,
325
- command: serverConfig.command || "",
326
- args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
327
- type: this.validateType(serverConfig.type) ? serverConfig.type : this.inferTransportType(serverConfig),
328
- url: serverConfig.url,
329
- env
330
- };
331
- }
332
- }
333
- return normalized;
334
- }
335
- /**
336
- * Validate type value
337
- */
338
- validateType(type) {
339
- return ["sse", "http", "stdio", "streamable-http"].includes(type);
340
- }
341
- /**
342
- * Infer transport type from server configuration when type field is not explicitly set
343
- */
344
- inferTransportType(serverConfig) {
345
- if (serverConfig.url && typeof serverConfig.url === "string") {
346
- return "http";
347
- }
348
- if (Array.isArray(serverConfig.args)) {
349
- const argsString = serverConfig.args.join(" ").toLowerCase();
350
- if (argsString.includes("stdio")) {
351
- return "stdio";
352
- }
353
- if (argsString.includes("http")) {
354
- return "http";
355
- }
356
- if (argsString.includes("sse")) {
357
- return "sse";
358
- }
359
- }
360
- if (serverConfig.command && typeof serverConfig.command === "string") {
361
- return "stdio";
362
- }
363
- return void 0;
364
- }
365
- /**
366
- * Validate server configuration
367
- */
368
- validateServerConfig(serverConfig) {
369
- if (!serverConfig || typeof serverConfig !== "object") {
370
- return false;
371
- }
372
- if (!serverConfig.name || typeof serverConfig.name !== "string") {
373
- return false;
374
- }
375
- if (!serverConfig.command || typeof serverConfig.command !== "string") {
376
- return false;
377
- }
378
- return true;
379
- }
380
- /**
381
- * Get supported configuration keys that the parser recognizes
382
- */
383
- getSupportedConfigKeys() {
384
- return ["servers", "mcp.servers", "mcpServers", "context_servers"];
385
- }
386
- /**
387
- * Check if the configuration file has valid syntax
388
- */
389
- async isValidSyntax() {
390
- try {
391
- const configData = await this.parseConfigFile();
392
- return configData.valid;
393
- } catch (error) {
394
- return false;
395
- }
396
- }
397
- /**
398
- * Count the number of MCP servers in the configuration
399
- */
400
- async countMCPServers() {
401
- try {
402
- const configData = await this.parseConfigFile();
403
- return Object.keys(configData.servers).length;
404
- } catch (error) {
405
- return 0;
406
- }
407
- }
408
- /**
409
- * Get the raw file content
410
- */
411
- async getFileContent() {
412
- if (this.fileContents) {
413
- return this.fileContents;
414
- }
415
- try {
416
- this.fileContents = await import_promises.default.readFile(this.filePath, "utf-8");
417
- return this.fileContents;
418
- } catch (error) {
419
- throw new Error(`Failed to read file: ${this.filePath}`);
420
- }
421
- }
422
- };
34
+ var import_node_util = __toESM(require("util"), 1);
35
+ var import_agent_files = require("agent-files");
423
36
 
424
37
  // src/services/credential-detection-service.ts
425
38
  var CredentialDetectionService = class {
@@ -535,8 +148,8 @@ var CredentialDetectionService = class {
535
148
  /**
536
149
  * Analyze command-line arguments for potential credentials
537
150
  */
538
- static analyzeArguments(args) {
539
- if (!args || !Array.isArray(args) || args.length === 0) {
151
+ static analyzeArguments(args2) {
152
+ if (!args2 || !Array.isArray(args2) || args2.length === 0) {
540
153
  return {
541
154
  hasCredentials: false,
542
155
  credentialVars: [],
@@ -544,9 +157,9 @@ var CredentialDetectionService = class {
544
157
  };
545
158
  }
546
159
  const credentialVars = [];
547
- for (let i = 0; i < args.length - 1; i++) {
548
- const arg = args[i];
549
- const nextArg = args[i + 1];
160
+ for (let i = 0; i < args2.length - 1; i++) {
161
+ const arg = args2[i];
162
+ const nextArg = args2[i + 1];
550
163
  const isHighRiskArg = this.ARGUMENT_PATTERNS.high.some((pattern) => pattern.test(arg));
551
164
  const isLowRiskArg = this.ARGUMENT_PATTERNS.low.some((pattern) => pattern.test(arg));
552
165
  if (isHighRiskArg || isLowRiskArg) {
@@ -702,77 +315,6 @@ var CredentialDetectionService = class {
702
315
  }
703
316
  };
704
317
 
705
- // src/services/directory-bubble-service.ts
706
- var import_node_path2 = __toESM(require("path"), 1);
707
- var import_promises2 = __toESM(require("fs/promises"), 1);
708
- var import_node_os = require("os");
709
- var DirectoryBubbleService = class {
710
- static {
711
- __name(this, "DirectoryBubbleService");
712
- }
713
- /**
714
- * Find a local MCP config file by bubbling up the directory tree
715
- * @param localPath - The relative path to search for (e.g., '.vscode/mcp.json')
716
- * @param startDir - The directory to start searching from
717
- * @returns The absolute path to the found config file, or null if not found
718
- */
719
- async findLocalConfigInParentDirectories(localPath, startDir) {
720
- try {
721
- let currentDir = import_node_path2.default.resolve(startDir);
722
- const homeDir = (0, import_node_os.homedir)();
723
- const rootDir = "/";
724
- let iterationCount = 0;
725
- const maxIterations = 100;
726
- const startDirResult = await this.checkDirectoryForConfig(currentDir, localPath);
727
- if (startDirResult) {
728
- return import_node_path2.default.join(currentDir, localPath);
729
- }
730
- while (currentDir !== homeDir && currentDir !== rootDir && iterationCount < maxIterations) {
731
- const parentDir = this.getParentDirectory(currentDir);
732
- if (!parentDir || parentDir === currentDir) {
733
- break;
734
- }
735
- if (parentDir === currentDir || parentDir.length >= currentDir.length) {
736
- break;
737
- }
738
- currentDir = parentDir;
739
- iterationCount++;
740
- const found = await this.checkDirectoryForConfig(currentDir, localPath);
741
- if (found) {
742
- return import_node_path2.default.join(currentDir, localPath);
743
- }
744
- }
745
- return null;
746
- } catch (error) {
747
- return null;
748
- }
749
- }
750
- /**
751
- * Check if a config file exists in the specified directory
752
- * @param dir - The directory to check
753
- * @param configPath - The relative path to the config file
754
- * @returns True if the config file exists and is accessible
755
- */
756
- async checkDirectoryForConfig(dir, configPath) {
757
- try {
758
- const fullPath = import_node_path2.default.join(dir, configPath);
759
- await import_promises2.default.access(fullPath);
760
- return true;
761
- } catch (error) {
762
- return false;
763
- }
764
- }
765
- /**
766
- * Get the parent directory of the specified directory
767
- * @param dir - The directory to get the parent of
768
- * @returns The parent directory path, or null if already at root
769
- */
770
- getParentDirectory(dir) {
771
- const parent = import_node_path2.default.dirname(dir);
772
- return parent === dir ? null : parent;
773
- }
774
- };
775
-
776
318
  // src/services/mcp-version-detection-service.ts
777
319
  var MCPVersionDetectionService = class {
778
320
  static {
@@ -784,14 +326,14 @@ var MCPVersionDetectionService = class {
784
326
  * @param args - Array of arguments passed to the command
785
327
  * @returns PackageVersionInfo if analysis is possible, null otherwise
786
328
  */
787
- analyzeServerVersion(command, args) {
329
+ analyzeServerVersion(command, args2) {
788
330
  if (!["npx", "uvx", "uv"].includes(command)) {
789
331
  return null;
790
332
  }
791
- if (!args || args.length === 0) {
333
+ if (!args2 || args2.length === 0) {
792
334
  return null;
793
335
  }
794
- const packageName = this.extractPackageName(command, args);
336
+ const packageName = this.extractPackageName(command, args2);
795
337
  if (!packageName) {
796
338
  return null;
797
339
  }
@@ -810,14 +352,14 @@ var MCPVersionDetectionService = class {
810
352
  * @param args - Array of arguments passed to the command
811
353
  * @returns The package name/spec or null if not found
812
354
  */
813
- extractPackageName(command, args) {
355
+ extractPackageName(command, args2) {
814
356
  switch (command) {
815
357
  case "npx":
816
- return this.extractNpxPackageName(args);
358
+ return this.extractNpxPackageName(args2);
817
359
  case "uvx":
818
- return this.extractUvxPackageName(args);
360
+ return this.extractUvxPackageName(args2);
819
361
  case "uv":
820
- return this.extractUvPackageName(args);
362
+ return this.extractUvPackageName(args2);
821
363
  default:
822
364
  return null;
823
365
  }
@@ -827,23 +369,23 @@ var MCPVersionDetectionService = class {
827
369
  * @param args - Array of arguments passed to npx
828
370
  * @returns The package name/spec or null if not found
829
371
  */
830
- extractNpxPackageName(args) {
831
- if (!args || args.length === 0) {
372
+ extractNpxPackageName(args2) {
373
+ if (!args2 || args2.length === 0) {
832
374
  return null;
833
375
  }
834
- const yIndex = args.indexOf("-y");
835
- if (yIndex !== -1 && yIndex + 1 < args.length) {
836
- return args[yIndex + 1];
376
+ const yIndex = args2.indexOf("-y");
377
+ if (yIndex !== -1 && yIndex + 1 < args2.length) {
378
+ return args2[yIndex + 1];
837
379
  }
838
- const yesIndex = args.indexOf("--yes");
839
- if (yesIndex !== -1 && yesIndex + 1 < args.length) {
840
- return args[yesIndex + 1];
380
+ const yesIndex = args2.indexOf("--yes");
381
+ if (yesIndex !== -1 && yesIndex + 1 < args2.length) {
382
+ return args2[yesIndex + 1];
841
383
  }
842
- for (let i = 0; i < args.length; i++) {
843
- const arg = args[i];
384
+ for (let i = 0; i < args2.length; i++) {
385
+ const arg = args2[i];
844
386
  if (!arg.startsWith("-")) {
845
387
  if (i > 0) {
846
- const prevArg = args[i - 1];
388
+ const prevArg = args2[i - 1];
847
389
  if (prevArg === "--registry" || prevArg === "-r" || prevArg === "--package" || prevArg === "-p") {
848
390
  continue;
849
391
  }
@@ -858,24 +400,24 @@ var MCPVersionDetectionService = class {
858
400
  * @param args - Array of arguments passed to uvx
859
401
  * @returns The package name/spec or null if not found
860
402
  */
861
- extractUvxPackageName(args) {
862
- if (!args || args.length === 0) {
403
+ extractUvxPackageName(args2) {
404
+ if (!args2 || args2.length === 0) {
863
405
  return null;
864
406
  }
865
- return args[0];
407
+ return args2[0];
866
408
  }
867
409
  /**
868
410
  * Extract the package name from uv arguments
869
411
  * @param args - Array of arguments passed to uv
870
412
  * @returns The package name/spec or null if not found
871
413
  */
872
- extractUvPackageName(args) {
873
- if (!args || args.length === 0) {
414
+ extractUvPackageName(args2) {
415
+ if (!args2 || args2.length === 0) {
874
416
  return null;
875
417
  }
876
- const runIndex = args.indexOf("run");
877
- if (runIndex !== -1 && runIndex + 1 < args.length) {
878
- return args[runIndex + 1];
418
+ const runIndex = args2.indexOf("run");
419
+ if (runIndex !== -1 && runIndex + 1 < args2.length) {
420
+ return args2[runIndex + 1];
879
421
  }
880
422
  return null;
881
423
  }
@@ -951,10 +493,10 @@ var MCPConfigService = class {
951
493
  versionDetectionService;
952
494
  enableDirectoryBubbling;
953
495
  constructor(options = {}) {
954
- this.pathRegistry = new MCPPathRegistry();
955
- this.currentOS = (0, import_node_os2.platform)();
496
+ this.pathRegistry = new import_agent_files.MCPPathRegistry();
497
+ this.currentOS = (0, import_node_os.platform)();
956
498
  this.debug = import_node_util.default.debuglog("ls-mcp");
957
- this.directoryBubbleService = new DirectoryBubbleService();
499
+ this.directoryBubbleService = new import_agent_files.DirectoryBubbleService();
958
500
  this.versionDetectionService = new MCPVersionDetectionService();
959
501
  this.enableDirectoryBubbling = options.enableDirectoryBubbling ?? false;
960
502
  }
@@ -1041,7 +583,7 @@ var MCPConfigService = class {
1041
583
  */
1042
584
  async validateConfigFile(filePath) {
1043
585
  try {
1044
- await import_promises3.default.access(filePath);
586
+ await import_promises.default.access(filePath);
1045
587
  const parser = this.createParser(filePath);
1046
588
  return await parser.isValidSyntax();
1047
589
  } catch (error) {
@@ -1052,7 +594,7 @@ var MCPConfigService = class {
1052
594
  * Create a parser instance (can be overridden for testing)
1053
595
  */
1054
596
  createParser(filePath) {
1055
- return new MCPConfigParser(filePath);
597
+ return new import_agent_files.MCPConfigParser(filePath);
1056
598
  }
1057
599
  /**
1058
600
  * Get MCP file groups with resolved paths and server information
@@ -1061,7 +603,8 @@ var MCPConfigService = class {
1061
603
  try {
1062
604
  const appPaths = this.getAllConfigFiles();
1063
605
  const mcpFilesPathsData = {};
1064
- for (const [groupName, paths] of Object.entries(appPaths)) {
606
+ for (const groupName of Object.keys(appPaths)) {
607
+ const paths = appPaths[groupName];
1065
608
  mcpFilesPathsData[groupName] = {
1066
609
  name: groupName,
1067
610
  friendlyName: this.getFriendlyName(groupName),
@@ -1072,10 +615,10 @@ var MCPConfigService = class {
1072
615
  let totalServersCount = 0;
1073
616
  for (const filePathData of paths) {
1074
617
  let resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
1075
- let absolutePath = import_node_path3.default.resolve(resolvedPath);
618
+ let absolutePath = import_node_path.default.resolve(resolvedPath);
1076
619
  if (filePathData.type === "local" && this.enableDirectoryBubbling) {
1077
620
  try {
1078
- await import_promises3.default.access(resolvedPath);
621
+ await import_promises.default.access(resolvedPath);
1079
622
  } catch (error) {
1080
623
  const bubbledPath = await this.directoryBubbleService.findLocalConfigInParentDirectories(
1081
624
  filePathData.filePath,
@@ -1083,7 +626,7 @@ var MCPConfigService = class {
1083
626
  );
1084
627
  if (bubbledPath) {
1085
628
  resolvedPath = bubbledPath;
1086
- absolutePath = import_node_path3.default.resolve(resolvedPath);
629
+ absolutePath = import_node_path.default.resolve(resolvedPath);
1087
630
  }
1088
631
  }
1089
632
  }
@@ -1092,7 +635,7 @@ var MCPConfigService = class {
1092
635
  }
1093
636
  uniqueFilePaths.add(absolutePath);
1094
637
  try {
1095
- await import_promises3.default.access(resolvedPath);
638
+ await import_promises.default.access(resolvedPath);
1096
639
  const parser = this.createParser(resolvedPath);
1097
640
  const parsable = await parser.isValidSyntax();
1098
641
  filePathData.parsable = parsable;
@@ -1201,9 +744,9 @@ var MCPConfigService = class {
1201
744
  };
1202
745
 
1203
746
  // src/services/mcp-server-manager-service.ts
1204
- var import_node_path4 = __toESM(require("path"), 1);
747
+ var import_node_path2 = __toESM(require("path"), 1);
1205
748
  var import_node_child_process = require("child_process");
1206
- var import_node_os3 = require("os");
749
+ var import_node_os2 = require("os");
1207
750
  var MCPServerManagerService = class {
1208
751
  static {
1209
752
  __name(this, "MCPServerManagerService");
@@ -1259,7 +802,7 @@ var MCPServerManagerService = class {
1259
802
  isRunning() {
1260
803
  try {
1261
804
  let psOutput;
1262
- if ((0, import_node_os3.platform)() === "win32") {
805
+ if ((0, import_node_os2.platform)() === "win32") {
1263
806
  psOutput = (0, import_node_child_process.execSync)('powershell -Command "Get-CimInstance -ClassName Win32_Process | Select-Object ProcessId,Name,CommandLine,ParentProcessId | ConvertTo-Csv -NoTypeInformation"', {
1264
807
  encoding: "utf8",
1265
808
  timeout: 5e3
@@ -1277,7 +820,7 @@ var MCPServerManagerService = class {
1277
820
  let pid;
1278
821
  let ppid;
1279
822
  let commandLine;
1280
- if ((0, import_node_os3.platform)() === "win32") {
823
+ if ((0, import_node_os2.platform)() === "win32") {
1281
824
  if (processLine.startsWith('"ProcessId"') || processLine.startsWith("ProcessId")) continue;
1282
825
  const parts = this.parseCSVLine(processLine);
1283
826
  if (parts.length < 4) continue;
@@ -1300,7 +843,7 @@ var MCPServerManagerService = class {
1300
843
  for (const [pid, processData] of processMap) {
1301
844
  const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid);
1302
845
  let commandMatchWin32 = false;
1303
- if ((0, import_node_os3.platform)() === "win32") {
846
+ if ((0, import_node_os2.platform)() === "win32") {
1304
847
  let commandTokensOnWin32 = processData.commandTokens;
1305
848
  if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith("cmd")) {
1306
849
  commandTokensOnWin32 = commandTokensOnWin32.slice(1);
@@ -1411,9 +954,9 @@ var MCPServerManagerService = class {
1411
954
  return true;
1412
955
  }
1413
956
  getBaseCommand(fullCommandPath) {
1414
- let baseCommand = import_node_path4.default.basename(fullCommandPath);
1415
- if ((0, import_node_os3.platform)() === "win32") {
1416
- baseCommand = import_node_path4.default.basename(fullCommandPath, ".exe");
957
+ let baseCommand = import_node_path2.default.basename(fullCommandPath);
958
+ if ((0, import_node_os2.platform)() === "win32") {
959
+ baseCommand = import_node_path2.default.basename(fullCommandPath, ".exe");
1417
960
  }
1418
961
  baseCommand = baseCommand.toLowerCase();
1419
962
  return baseCommand;
@@ -2039,9 +1582,13 @@ var RenderService = class _RenderService {
2039
1582
  };
2040
1583
 
2041
1584
  // src/bin/cli.ts
1585
+ var args = process.argv.slice(2);
1586
+ var jsonOutput = args.includes("--json");
2042
1587
  async function init() {
2043
- console.log();
2044
- console.log("[+] Detecting MCP Server configurations...");
1588
+ if (!jsonOutput) {
1589
+ console.log();
1590
+ console.log("[+] Detecting MCP Server configurations...");
1591
+ }
2045
1592
  const mcpFilesManager = new MCPFiles();
2046
1593
  const mcpFilesList = await mcpFilesManager.findFiles();
2047
1594
  if (Object.keys(mcpFilesList).length === 0) {
@@ -2080,18 +1627,20 @@ async function init() {
2080
1627
  totalImplicitLatestVersions++;
2081
1628
  }
2082
1629
  }
2083
- const mcpGroupData = [
2084
- { key: "PROVIDER", value: group.friendlyName },
2085
- { key: "FILE", value: filePath },
2086
- { key: "TYPE", value: filePathDataType },
2087
- { key: "PARSABLE", value: filePathValid }
2088
- ];
2089
- const groupMetadata = {
2090
- mcpServersTotal: totalMCPServers,
2091
- mcpServersRunning: totalMCPServersRunning
2092
- };
2093
- RenderService.printMcpGroup(pathIndex, mcpGroupData, groupMetadata);
2094
- RenderService.printMcpServers(mcpServers);
1630
+ if (!jsonOutput) {
1631
+ const mcpGroupData = [
1632
+ { key: "PROVIDER", value: group.friendlyName },
1633
+ { key: "FILE", value: filePath },
1634
+ { key: "TYPE", value: filePathDataType },
1635
+ { key: "PARSABLE", value: filePathValid }
1636
+ ];
1637
+ const groupMetadata = {
1638
+ mcpServersTotal: totalMCPServers,
1639
+ mcpServersRunning: totalMCPServersRunning
1640
+ };
1641
+ RenderService.printMcpGroup(pathIndex, mcpGroupData, groupMetadata);
1642
+ RenderService.printMcpServers(mcpServers);
1643
+ }
2095
1644
  }
2096
1645
  }
2097
1646
  }
@@ -2105,7 +1654,18 @@ async function init() {
2105
1654
  implicitLatestVersions: totalImplicitLatestVersions,
2106
1655
  transportBreakdown: transportCounts
2107
1656
  };
2108
- RenderService.printSummary(summaryStats);
1657
+ if (jsonOutput) {
1658
+ const filteredMcpFiles = Object.fromEntries(
1659
+ Object.entries(mcpFilesList).filter(([, group]) => group.paths.length > 0)
1660
+ );
1661
+ const output = {
1662
+ mcpFiles: filteredMcpFiles,
1663
+ summary: summaryStats
1664
+ };
1665
+ console.log(JSON.stringify(output, null, 2));
1666
+ } else {
1667
+ RenderService.printSummary(summaryStats);
1668
+ }
2109
1669
  }
2110
1670
  __name(init, "init");
2111
1671
  init().then(() => {