ls-mcp 1.13.2 → 1.14.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/README.md +25 -0
- package/dist/bin/cli.cjs +131 -482
- package/dist/bin/cli.mjs +121 -472
- package/dist/main.cjs +111 -480
- package/dist/main.d.cts +6 -39
- package/dist/main.d.ts +6 -39
- package/dist/main.mjs +101 -470
- package/package.json +2 -1
- package/src/bin/cli.ts +25 -2
- package/src/main.ts +45 -1
- package/src/services/mcp-config-service.ts +75 -7
- package/src/types/mcp-config-service.types.ts +2 -20
- package/src/services/directory-bubble-service.ts +0 -82
- package/src/services/mcp-config-linter-service.ts +0 -34
- package/src/services/mcp-config-parser.ts +0 -234
- package/src/services/mcp-path-registry.ts +0 -213
package/dist/main.mjs
CHANGED
|
@@ -3,397 +3,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/services/mcp-config-service.ts
|
|
5
5
|
import { platform } from "os";
|
|
6
|
-
import path3 from "path";
|
|
7
|
-
import fs3 from "fs/promises";
|
|
8
|
-
import util from "util";
|
|
9
|
-
|
|
10
|
-
// src/services/mcp-path-registry.ts
|
|
11
6
|
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
|
-
static LINUX_PATHS = {
|
|
106
|
-
claude: [
|
|
107
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Claude", "claude_desktop_config.json"), type: "global" }
|
|
108
|
-
],
|
|
109
|
-
claude_code: [
|
|
110
|
-
{ filePath: ".mcp.json", type: "local" }
|
|
111
|
-
],
|
|
112
|
-
cursor: [
|
|
113
|
-
{ filePath: path.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
|
|
114
|
-
{ filePath: path.join(".cursor", "mcp.json"), type: "local" }
|
|
115
|
-
],
|
|
116
|
-
vscode: [
|
|
117
|
-
{ filePath: path.join(".vscode", "mcp.json"), type: "local" },
|
|
118
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "settings.json"), type: "global" },
|
|
119
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "settings.json"), type: "global" },
|
|
120
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "mcp.json"), type: "global" },
|
|
121
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "mcp.json"), type: "global" },
|
|
122
|
-
{ filePath: path.join(process.env.HOME || "", ".mcp.json"), type: "global" }
|
|
123
|
-
],
|
|
124
|
-
cline: [
|
|
125
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
126
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
127
|
-
],
|
|
128
|
-
windsurf: [
|
|
129
|
-
{ filePath: path.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
|
|
130
|
-
],
|
|
131
|
-
roo: [
|
|
132
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
133
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
134
|
-
],
|
|
135
|
-
"intellij-github-copilot": [
|
|
136
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
|
|
137
|
-
],
|
|
138
|
-
junie: [
|
|
139
|
-
{ filePath: path.join(process.env.HOME || "", ".junie", "mcp.json"), type: "global" },
|
|
140
|
-
{ filePath: path.join(".junie", "mcp", "mcp.json"), type: "local" }
|
|
141
|
-
],
|
|
142
|
-
zed: [
|
|
143
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "zed", "settings.json"), type: "global" },
|
|
144
|
-
{ filePath: path.join(".zed", "settings.json"), type: "local" }
|
|
145
|
-
],
|
|
146
|
-
gemini: [
|
|
147
|
-
{ filePath: path.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
|
|
148
|
-
{ filePath: path.join(".gemini", "settings.json"), type: "local" }
|
|
149
|
-
]
|
|
150
|
-
};
|
|
151
|
-
customApps = /* @__PURE__ */ new Map();
|
|
152
|
-
/**
|
|
153
|
-
* Get all MCP configuration file paths for a specific operating system
|
|
154
|
-
*/
|
|
155
|
-
getPathsForOS(os) {
|
|
156
|
-
switch (os.toLowerCase()) {
|
|
157
|
-
case "win32":
|
|
158
|
-
case "windows":
|
|
159
|
-
return { ..._MCPPathRegistry.WINDOWS_PATHS };
|
|
160
|
-
case "darwin":
|
|
161
|
-
case "macos":
|
|
162
|
-
return { ..._MCPPathRegistry.DARWIN_PATHS };
|
|
163
|
-
case "linux":
|
|
164
|
-
return { ..._MCPPathRegistry.LINUX_PATHS };
|
|
165
|
-
default:
|
|
166
|
-
throw new Error(`Unsupported operating system: ${os}`);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Get MCP configuration file paths for a specific app on a specific OS
|
|
171
|
-
*/
|
|
172
|
-
getPathsForApp(os, appName) {
|
|
173
|
-
const osPaths = this.getPathsForOS(os);
|
|
174
|
-
const appPaths = osPaths[appName];
|
|
175
|
-
if (!appPaths) {
|
|
176
|
-
throw new Error(`App '${appName}' not found for OS '${os}'`);
|
|
177
|
-
}
|
|
178
|
-
return [...appPaths];
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Get all supported app names for a specific OS
|
|
182
|
-
*/
|
|
183
|
-
getSupportedApps(os) {
|
|
184
|
-
const osPaths = this.getPathsForOS(os);
|
|
185
|
-
return Object.keys(osPaths);
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Get all supported operating systems
|
|
189
|
-
*/
|
|
190
|
-
getSupportedOperatingSystems() {
|
|
191
|
-
return ["win32", "darwin", "linux"];
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Register a custom app with custom paths for a specific OS
|
|
195
|
-
*/
|
|
196
|
-
registerCustomApp(os, appName, paths) {
|
|
197
|
-
if (!this.customApps.has(os)) {
|
|
198
|
-
this.customApps.set(os, {});
|
|
199
|
-
}
|
|
200
|
-
const osCustomApps = this.customApps.get(os);
|
|
201
|
-
osCustomApps[appName] = [...paths];
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Get paths including custom registered apps
|
|
205
|
-
*/
|
|
206
|
-
getPathsForOSWithCustom(os) {
|
|
207
|
-
const basePaths = this.getPathsForOS(os);
|
|
208
|
-
const customPaths = this.customApps.get(os) || {};
|
|
209
|
-
return { ...basePaths, ...customPaths };
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
// src/services/mcp-config-parser.ts
|
|
214
7
|
import fs from "fs/promises";
|
|
215
|
-
import
|
|
216
|
-
|
|
217
|
-
static {
|
|
218
|
-
__name(this, "MCPConfigParser");
|
|
219
|
-
}
|
|
220
|
-
filePath;
|
|
221
|
-
fileContents = null;
|
|
222
|
-
parsed = false;
|
|
223
|
-
valid = false;
|
|
224
|
-
fileContentsData = null;
|
|
225
|
-
constructor(filePath) {
|
|
226
|
-
this.filePath = filePath;
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Parse the configuration file and return structured data
|
|
230
|
-
*/
|
|
231
|
-
async parseConfigFile() {
|
|
232
|
-
if (this.parsed) {
|
|
233
|
-
return {
|
|
234
|
-
raw: this.fileContentsData,
|
|
235
|
-
parsed: this.parsed,
|
|
236
|
-
valid: this.valid,
|
|
237
|
-
servers: await this.extractMCPServers(this.fileContentsData)
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
this.parsed = true;
|
|
241
|
-
const fileContent = await this.getFileContent();
|
|
242
|
-
try {
|
|
243
|
-
this.fileContentsData = JSON.parse(fileContent);
|
|
244
|
-
if (typeof this.fileContentsData === "object") {
|
|
245
|
-
this.valid = true;
|
|
246
|
-
}
|
|
247
|
-
} catch (e) {
|
|
248
|
-
}
|
|
249
|
-
if (!this.valid) {
|
|
250
|
-
try {
|
|
251
|
-
this.fileContentsData = parse(fileContent);
|
|
252
|
-
if (typeof this.fileContentsData === "object") {
|
|
253
|
-
this.valid = true;
|
|
254
|
-
}
|
|
255
|
-
} catch (error) {
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
if (!this.valid) {
|
|
259
|
-
throw new Error(`Failed to parse configuration file: ${this.filePath}`);
|
|
260
|
-
}
|
|
261
|
-
return {
|
|
262
|
-
raw: this.fileContentsData,
|
|
263
|
-
parsed: this.parsed,
|
|
264
|
-
valid: this.valid,
|
|
265
|
-
servers: await this.extractMCPServers(this.fileContentsData)
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Extract MCP servers from parsed configuration data
|
|
270
|
-
*/
|
|
271
|
-
async extractMCPServers(configData) {
|
|
272
|
-
if (!configData || typeof configData !== "object") {
|
|
273
|
-
return {};
|
|
274
|
-
}
|
|
275
|
-
if (configData.servers && typeof configData.servers === "object") {
|
|
276
|
-
return this.normalizeServerConfigs(configData.servers);
|
|
277
|
-
}
|
|
278
|
-
if (configData.mcp?.servers && typeof configData.mcp.servers === "object") {
|
|
279
|
-
return this.normalizeServerConfigs(configData.mcp.servers);
|
|
280
|
-
}
|
|
281
|
-
if (configData.mcpServers && typeof configData.mcpServers === "object") {
|
|
282
|
-
return this.normalizeServerConfigs(configData.mcpServers);
|
|
283
|
-
}
|
|
284
|
-
if (configData.context_servers && typeof configData.context_servers === "object") {
|
|
285
|
-
return this.normalizeServerConfigs(configData.context_servers);
|
|
286
|
-
}
|
|
287
|
-
return {};
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Normalize server configurations to ensure consistent structure
|
|
291
|
-
*/
|
|
292
|
-
normalizeServerConfigs(servers) {
|
|
293
|
-
const normalized = {};
|
|
294
|
-
for (const [serverName, serverConfig] of Object.entries(servers)) {
|
|
295
|
-
if (serverConfig && typeof serverConfig === "object") {
|
|
296
|
-
const env = serverConfig.env && typeof serverConfig.env === "object" ? serverConfig.env : void 0;
|
|
297
|
-
normalized[serverName] = {
|
|
298
|
-
name: serverName,
|
|
299
|
-
command: serverConfig.command || "",
|
|
300
|
-
args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
|
|
301
|
-
type: this.validateType(serverConfig.type) ? serverConfig.type : this.inferTransportType(serverConfig),
|
|
302
|
-
url: serverConfig.url,
|
|
303
|
-
env
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
return normalized;
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Validate type value
|
|
311
|
-
*/
|
|
312
|
-
validateType(type) {
|
|
313
|
-
return ["sse", "http", "stdio", "streamable-http"].includes(type);
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Infer transport type from server configuration when type field is not explicitly set
|
|
317
|
-
*/
|
|
318
|
-
inferTransportType(serverConfig) {
|
|
319
|
-
if (serverConfig.url && typeof serverConfig.url === "string") {
|
|
320
|
-
return "http";
|
|
321
|
-
}
|
|
322
|
-
if (Array.isArray(serverConfig.args)) {
|
|
323
|
-
const argsString = serverConfig.args.join(" ").toLowerCase();
|
|
324
|
-
if (argsString.includes("stdio")) {
|
|
325
|
-
return "stdio";
|
|
326
|
-
}
|
|
327
|
-
if (argsString.includes("http")) {
|
|
328
|
-
return "http";
|
|
329
|
-
}
|
|
330
|
-
if (argsString.includes("sse")) {
|
|
331
|
-
return "sse";
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
if (serverConfig.command && typeof serverConfig.command === "string") {
|
|
335
|
-
return "stdio";
|
|
336
|
-
}
|
|
337
|
-
return void 0;
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Validate server configuration
|
|
341
|
-
*/
|
|
342
|
-
validateServerConfig(serverConfig) {
|
|
343
|
-
if (!serverConfig || typeof serverConfig !== "object") {
|
|
344
|
-
return false;
|
|
345
|
-
}
|
|
346
|
-
if (!serverConfig.name || typeof serverConfig.name !== "string") {
|
|
347
|
-
return false;
|
|
348
|
-
}
|
|
349
|
-
if (!serverConfig.command || typeof serverConfig.command !== "string") {
|
|
350
|
-
return false;
|
|
351
|
-
}
|
|
352
|
-
return true;
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Get supported configuration keys that the parser recognizes
|
|
356
|
-
*/
|
|
357
|
-
getSupportedConfigKeys() {
|
|
358
|
-
return ["servers", "mcp.servers", "mcpServers", "context_servers"];
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Check if the configuration file has valid syntax
|
|
362
|
-
*/
|
|
363
|
-
async isValidSyntax() {
|
|
364
|
-
try {
|
|
365
|
-
const configData = await this.parseConfigFile();
|
|
366
|
-
return configData.valid;
|
|
367
|
-
} catch (error) {
|
|
368
|
-
return false;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Count the number of MCP servers in the configuration
|
|
373
|
-
*/
|
|
374
|
-
async countMCPServers() {
|
|
375
|
-
try {
|
|
376
|
-
const configData = await this.parseConfigFile();
|
|
377
|
-
return Object.keys(configData.servers).length;
|
|
378
|
-
} catch (error) {
|
|
379
|
-
return 0;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Get the raw file content
|
|
384
|
-
*/
|
|
385
|
-
async getFileContent() {
|
|
386
|
-
if (this.fileContents) {
|
|
387
|
-
return this.fileContents;
|
|
388
|
-
}
|
|
389
|
-
try {
|
|
390
|
-
this.fileContents = await fs.readFile(this.filePath, "utf-8");
|
|
391
|
-
return this.fileContents;
|
|
392
|
-
} catch (error) {
|
|
393
|
-
throw new Error(`Failed to read file: ${this.filePath}`);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
};
|
|
8
|
+
import util from "util";
|
|
9
|
+
import { MCPPathRegistry, MCPConfigParser, DirectoryBubbleService } from "agent-files";
|
|
397
10
|
|
|
398
11
|
// src/services/credential-detection-service.ts
|
|
399
12
|
var CredentialDetectionService = class {
|
|
@@ -676,77 +289,6 @@ var CredentialDetectionService = class {
|
|
|
676
289
|
}
|
|
677
290
|
};
|
|
678
291
|
|
|
679
|
-
// src/services/directory-bubble-service.ts
|
|
680
|
-
import path2 from "path";
|
|
681
|
-
import fs2 from "fs/promises";
|
|
682
|
-
import { homedir } from "os";
|
|
683
|
-
var DirectoryBubbleService = class {
|
|
684
|
-
static {
|
|
685
|
-
__name(this, "DirectoryBubbleService");
|
|
686
|
-
}
|
|
687
|
-
/**
|
|
688
|
-
* Find a local MCP config file by bubbling up the directory tree
|
|
689
|
-
* @param localPath - The relative path to search for (e.g., '.vscode/mcp.json')
|
|
690
|
-
* @param startDir - The directory to start searching from
|
|
691
|
-
* @returns The absolute path to the found config file, or null if not found
|
|
692
|
-
*/
|
|
693
|
-
async findLocalConfigInParentDirectories(localPath, startDir) {
|
|
694
|
-
try {
|
|
695
|
-
let currentDir = path2.resolve(startDir);
|
|
696
|
-
const homeDir = homedir();
|
|
697
|
-
const rootDir = "/";
|
|
698
|
-
let iterationCount = 0;
|
|
699
|
-
const maxIterations = 100;
|
|
700
|
-
const startDirResult = await this.checkDirectoryForConfig(currentDir, localPath);
|
|
701
|
-
if (startDirResult) {
|
|
702
|
-
return path2.join(currentDir, localPath);
|
|
703
|
-
}
|
|
704
|
-
while (currentDir !== homeDir && currentDir !== rootDir && iterationCount < maxIterations) {
|
|
705
|
-
const parentDir = this.getParentDirectory(currentDir);
|
|
706
|
-
if (!parentDir || parentDir === currentDir) {
|
|
707
|
-
break;
|
|
708
|
-
}
|
|
709
|
-
if (parentDir === currentDir || parentDir.length >= currentDir.length) {
|
|
710
|
-
break;
|
|
711
|
-
}
|
|
712
|
-
currentDir = parentDir;
|
|
713
|
-
iterationCount++;
|
|
714
|
-
const found = await this.checkDirectoryForConfig(currentDir, localPath);
|
|
715
|
-
if (found) {
|
|
716
|
-
return path2.join(currentDir, localPath);
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
return null;
|
|
720
|
-
} catch (error) {
|
|
721
|
-
return null;
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
/**
|
|
725
|
-
* Check if a config file exists in the specified directory
|
|
726
|
-
* @param dir - The directory to check
|
|
727
|
-
* @param configPath - The relative path to the config file
|
|
728
|
-
* @returns True if the config file exists and is accessible
|
|
729
|
-
*/
|
|
730
|
-
async checkDirectoryForConfig(dir, configPath) {
|
|
731
|
-
try {
|
|
732
|
-
const fullPath = path2.join(dir, configPath);
|
|
733
|
-
await fs2.access(fullPath);
|
|
734
|
-
return true;
|
|
735
|
-
} catch (error) {
|
|
736
|
-
return false;
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
/**
|
|
740
|
-
* Get the parent directory of the specified directory
|
|
741
|
-
* @param dir - The directory to get the parent of
|
|
742
|
-
* @returns The parent directory path, or null if already at root
|
|
743
|
-
*/
|
|
744
|
-
getParentDirectory(dir) {
|
|
745
|
-
const parent = path2.dirname(dir);
|
|
746
|
-
return parent === dir ? null : parent;
|
|
747
|
-
}
|
|
748
|
-
};
|
|
749
|
-
|
|
750
292
|
// src/services/mcp-version-detection-service.ts
|
|
751
293
|
var MCPVersionDetectionService = class {
|
|
752
294
|
static {
|
|
@@ -1015,7 +557,7 @@ var MCPConfigService = class {
|
|
|
1015
557
|
*/
|
|
1016
558
|
async validateConfigFile(filePath) {
|
|
1017
559
|
try {
|
|
1018
|
-
await
|
|
560
|
+
await fs.access(filePath);
|
|
1019
561
|
const parser = this.createParser(filePath);
|
|
1020
562
|
return await parser.isValidSyntax();
|
|
1021
563
|
} catch (error) {
|
|
@@ -1035,7 +577,8 @@ var MCPConfigService = class {
|
|
|
1035
577
|
try {
|
|
1036
578
|
const appPaths = this.getAllConfigFiles();
|
|
1037
579
|
const mcpFilesPathsData = {};
|
|
1038
|
-
for (const
|
|
580
|
+
for (const groupName of Object.keys(appPaths)) {
|
|
581
|
+
const paths = appPaths[groupName];
|
|
1039
582
|
mcpFilesPathsData[groupName] = {
|
|
1040
583
|
name: groupName,
|
|
1041
584
|
friendlyName: this.getFriendlyName(groupName),
|
|
@@ -1046,10 +589,10 @@ var MCPConfigService = class {
|
|
|
1046
589
|
let totalServersCount = 0;
|
|
1047
590
|
for (const filePathData of paths) {
|
|
1048
591
|
let resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
1049
|
-
let absolutePath =
|
|
592
|
+
let absolutePath = path.resolve(resolvedPath);
|
|
1050
593
|
if (filePathData.type === "local" && this.enableDirectoryBubbling) {
|
|
1051
594
|
try {
|
|
1052
|
-
await
|
|
595
|
+
await fs.access(resolvedPath);
|
|
1053
596
|
} catch (error) {
|
|
1054
597
|
const bubbledPath = await this.directoryBubbleService.findLocalConfigInParentDirectories(
|
|
1055
598
|
filePathData.filePath,
|
|
@@ -1057,7 +600,7 @@ var MCPConfigService = class {
|
|
|
1057
600
|
);
|
|
1058
601
|
if (bubbledPath) {
|
|
1059
602
|
resolvedPath = bubbledPath;
|
|
1060
|
-
absolutePath =
|
|
603
|
+
absolutePath = path.resolve(resolvedPath);
|
|
1061
604
|
}
|
|
1062
605
|
}
|
|
1063
606
|
}
|
|
@@ -1066,7 +609,7 @@ var MCPConfigService = class {
|
|
|
1066
609
|
}
|
|
1067
610
|
uniqueFilePaths.add(absolutePath);
|
|
1068
611
|
try {
|
|
1069
|
-
await
|
|
612
|
+
await fs.access(resolvedPath);
|
|
1070
613
|
const parser = this.createParser(resolvedPath);
|
|
1071
614
|
const parsable = await parser.isValidSyntax();
|
|
1072
615
|
filePathData.parsable = parsable;
|
|
@@ -1090,6 +633,61 @@ var MCPConfigService = class {
|
|
|
1090
633
|
throw new Error(`Failed to get MCP file groups: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1091
634
|
}
|
|
1092
635
|
}
|
|
636
|
+
/**
|
|
637
|
+
* Parse custom configuration files provided by the user
|
|
638
|
+
* This method processes files independently of standard app-based discovery
|
|
639
|
+
*/
|
|
640
|
+
async parseCustomFiles(filePaths) {
|
|
641
|
+
try {
|
|
642
|
+
const mcpFilesPathsData = {
|
|
643
|
+
custom: {
|
|
644
|
+
name: "custom",
|
|
645
|
+
friendlyName: "Custom Files",
|
|
646
|
+
paths: [],
|
|
647
|
+
stats: { serversCount: 0 }
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
let totalServersCount = 0;
|
|
651
|
+
for (const filePath of filePaths) {
|
|
652
|
+
const resolvedPath = filePath.replace("~", process.env.HOME || "");
|
|
653
|
+
const absolutePath = path.resolve(resolvedPath);
|
|
654
|
+
try {
|
|
655
|
+
await fs.access(absolutePath);
|
|
656
|
+
const parser = this.createParser(absolutePath);
|
|
657
|
+
const parsable = await parser.isValidSyntax();
|
|
658
|
+
const filePathData = {
|
|
659
|
+
filePath: absolutePath,
|
|
660
|
+
type: "local",
|
|
661
|
+
parsable
|
|
662
|
+
};
|
|
663
|
+
if (parsable) {
|
|
664
|
+
const configData = await parser.parseConfigFile();
|
|
665
|
+
const servers = await this.convertToMCPServerInfo(configData.servers || {});
|
|
666
|
+
filePathData.servers = servers;
|
|
667
|
+
totalServersCount += servers.length;
|
|
668
|
+
} else {
|
|
669
|
+
this.debug(`File ${absolutePath} has invalid syntax`);
|
|
670
|
+
filePathData.servers = [];
|
|
671
|
+
}
|
|
672
|
+
mcpFilesPathsData.custom.paths.push(filePathData);
|
|
673
|
+
} catch (error) {
|
|
674
|
+
this.debug(`Skipping file ${absolutePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
675
|
+
mcpFilesPathsData.custom.paths.push({
|
|
676
|
+
filePath: absolutePath,
|
|
677
|
+
type: "local",
|
|
678
|
+
parsable: false,
|
|
679
|
+
servers: []
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
if (mcpFilesPathsData.custom.stats) {
|
|
684
|
+
mcpFilesPathsData.custom.stats.serversCount = totalServersCount;
|
|
685
|
+
}
|
|
686
|
+
return mcpFilesPathsData;
|
|
687
|
+
} catch (error) {
|
|
688
|
+
throw new Error(`Failed to parse custom files: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
1093
691
|
/**
|
|
1094
692
|
* Register a custom app with custom paths for the current OS
|
|
1095
693
|
*/
|
|
@@ -1175,7 +773,7 @@ var MCPConfigService = class {
|
|
|
1175
773
|
};
|
|
1176
774
|
|
|
1177
775
|
// src/services/mcp-server-manager-service.ts
|
|
1178
|
-
import
|
|
776
|
+
import path2 from "path";
|
|
1179
777
|
import { execSync } from "child_process";
|
|
1180
778
|
import { platform as platform2 } from "os";
|
|
1181
779
|
var MCPServerManagerService = class {
|
|
@@ -1385,9 +983,9 @@ var MCPServerManagerService = class {
|
|
|
1385
983
|
return true;
|
|
1386
984
|
}
|
|
1387
985
|
getBaseCommand(fullCommandPath) {
|
|
1388
|
-
let baseCommand =
|
|
986
|
+
let baseCommand = path2.basename(fullCommandPath);
|
|
1389
987
|
if (platform2() === "win32") {
|
|
1390
|
-
baseCommand =
|
|
988
|
+
baseCommand = path2.basename(fullCommandPath, ".exe");
|
|
1391
989
|
}
|
|
1392
990
|
baseCommand = baseCommand.toLowerCase();
|
|
1393
991
|
return baseCommand;
|
|
@@ -1574,14 +1172,47 @@ var MCPFiles = class {
|
|
|
1574
1172
|
__name(this, "MCPFiles");
|
|
1575
1173
|
}
|
|
1576
1174
|
mcpConfigService;
|
|
1577
|
-
|
|
1175
|
+
customFiles;
|
|
1176
|
+
constructor(customFiles) {
|
|
1578
1177
|
this.mcpConfigService = new MCPConfigService({ enableDirectoryBubbling: true });
|
|
1178
|
+
this.customFiles = customFiles;
|
|
1579
1179
|
}
|
|
1580
1180
|
/**
|
|
1581
1181
|
* Find and process all MCP configuration files
|
|
1182
|
+
* If customFiles are provided, only those files are processed (replaces automatic discovery)
|
|
1582
1183
|
*/
|
|
1583
1184
|
async findFiles() {
|
|
1584
1185
|
try {
|
|
1186
|
+
if (this.customFiles && this.customFiles.length > 0) {
|
|
1187
|
+
const mcpFilesPathsData2 = await this.mcpConfigService.parseCustomFiles(this.customFiles);
|
|
1188
|
+
for (const groupName of Object.keys(mcpFilesPathsData2)) {
|
|
1189
|
+
const group = mcpFilesPathsData2[groupName];
|
|
1190
|
+
for (const filePathData of group.paths) {
|
|
1191
|
+
if (filePathData.servers && filePathData.servers.length > 0) {
|
|
1192
|
+
for (const server of filePathData.servers) {
|
|
1193
|
+
const serverConfig = {
|
|
1194
|
+
name: server.name,
|
|
1195
|
+
command: server.command,
|
|
1196
|
+
args: server.args,
|
|
1197
|
+
transport: server.transport,
|
|
1198
|
+
type: server.type,
|
|
1199
|
+
env: server.env
|
|
1200
|
+
};
|
|
1201
|
+
const serverManager = new MCPServerManagerService(serverConfig);
|
|
1202
|
+
const processDetection = serverManager.isRunning();
|
|
1203
|
+
let isRunning = false;
|
|
1204
|
+
if (processDetection) {
|
|
1205
|
+
if (typeof processDetection === "object" && processDetection.estimatedProduct === group.name) {
|
|
1206
|
+
isRunning = true;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
server.status = isRunning ? "running" : "stopped";
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
return mcpFilesPathsData2;
|
|
1215
|
+
}
|
|
1585
1216
|
const mcpFilesPathsData = await this.mcpConfigService.getMCPFileGroups();
|
|
1586
1217
|
for (const groupName of Object.keys(mcpFilesPathsData)) {
|
|
1587
1218
|
const group = mcpFilesPathsData[groupName];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ls-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"description": "list and detect MCP servers and configurations",
|
|
5
5
|
"types": "dist/main.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"url": "https://github.com/lirantal/ls-mcp.git"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
+
"agent-files": "^1.0.1",
|
|
78
79
|
"jsonc-parser": "^3.3.1"
|
|
79
80
|
},
|
|
80
81
|
"devDependencies": {
|