ls-mcp 1.13.2 → 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 {
@@ -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 {
@@ -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;