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/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
|
|
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
|
|
242
|
-
var
|
|
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 {
|
|
@@ -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 {
|
|
@@ -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,
|
|
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
|
|
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
|
|
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 =
|
|
618
|
+
let absolutePath = import_node_path.default.resolve(resolvedPath);
|
|
1076
619
|
if (filePathData.type === "local" && this.enableDirectoryBubbling) {
|
|
1077
620
|
try {
|
|
1078
|
-
await
|
|
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 =
|
|
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
|
|
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;
|
|
@@ -1116,6 +659,61 @@ var MCPConfigService = class {
|
|
|
1116
659
|
throw new Error(`Failed to get MCP file groups: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1117
660
|
}
|
|
1118
661
|
}
|
|
662
|
+
/**
|
|
663
|
+
* Parse custom configuration files provided by the user
|
|
664
|
+
* This method processes files independently of standard app-based discovery
|
|
665
|
+
*/
|
|
666
|
+
async parseCustomFiles(filePaths) {
|
|
667
|
+
try {
|
|
668
|
+
const mcpFilesPathsData = {
|
|
669
|
+
custom: {
|
|
670
|
+
name: "custom",
|
|
671
|
+
friendlyName: "Custom Files",
|
|
672
|
+
paths: [],
|
|
673
|
+
stats: { serversCount: 0 }
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
let totalServersCount = 0;
|
|
677
|
+
for (const filePath of filePaths) {
|
|
678
|
+
const resolvedPath = filePath.replace("~", process.env.HOME || "");
|
|
679
|
+
const absolutePath = import_node_path.default.resolve(resolvedPath);
|
|
680
|
+
try {
|
|
681
|
+
await import_promises.default.access(absolutePath);
|
|
682
|
+
const parser = this.createParser(absolutePath);
|
|
683
|
+
const parsable = await parser.isValidSyntax();
|
|
684
|
+
const filePathData = {
|
|
685
|
+
filePath: absolutePath,
|
|
686
|
+
type: "local",
|
|
687
|
+
parsable
|
|
688
|
+
};
|
|
689
|
+
if (parsable) {
|
|
690
|
+
const configData = await parser.parseConfigFile();
|
|
691
|
+
const servers = await this.convertToMCPServerInfo(configData.servers || {});
|
|
692
|
+
filePathData.servers = servers;
|
|
693
|
+
totalServersCount += servers.length;
|
|
694
|
+
} else {
|
|
695
|
+
this.debug(`File ${absolutePath} has invalid syntax`);
|
|
696
|
+
filePathData.servers = [];
|
|
697
|
+
}
|
|
698
|
+
mcpFilesPathsData.custom.paths.push(filePathData);
|
|
699
|
+
} catch (error) {
|
|
700
|
+
this.debug(`Skipping file ${absolutePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
701
|
+
mcpFilesPathsData.custom.paths.push({
|
|
702
|
+
filePath: absolutePath,
|
|
703
|
+
type: "local",
|
|
704
|
+
parsable: false,
|
|
705
|
+
servers: []
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
if (mcpFilesPathsData.custom.stats) {
|
|
710
|
+
mcpFilesPathsData.custom.stats.serversCount = totalServersCount;
|
|
711
|
+
}
|
|
712
|
+
return mcpFilesPathsData;
|
|
713
|
+
} catch (error) {
|
|
714
|
+
throw new Error(`Failed to parse custom files: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
1119
717
|
/**
|
|
1120
718
|
* Register a custom app with custom paths for the current OS
|
|
1121
719
|
*/
|
|
@@ -1201,9 +799,9 @@ var MCPConfigService = class {
|
|
|
1201
799
|
};
|
|
1202
800
|
|
|
1203
801
|
// src/services/mcp-server-manager-service.ts
|
|
1204
|
-
var
|
|
802
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
1205
803
|
var import_node_child_process = require("child_process");
|
|
1206
|
-
var
|
|
804
|
+
var import_node_os2 = require("os");
|
|
1207
805
|
var MCPServerManagerService = class {
|
|
1208
806
|
static {
|
|
1209
807
|
__name(this, "MCPServerManagerService");
|
|
@@ -1259,7 +857,7 @@ var MCPServerManagerService = class {
|
|
|
1259
857
|
isRunning() {
|
|
1260
858
|
try {
|
|
1261
859
|
let psOutput;
|
|
1262
|
-
if ((0,
|
|
860
|
+
if ((0, import_node_os2.platform)() === "win32") {
|
|
1263
861
|
psOutput = (0, import_node_child_process.execSync)('powershell -Command "Get-CimInstance -ClassName Win32_Process | Select-Object ProcessId,Name,CommandLine,ParentProcessId | ConvertTo-Csv -NoTypeInformation"', {
|
|
1264
862
|
encoding: "utf8",
|
|
1265
863
|
timeout: 5e3
|
|
@@ -1277,7 +875,7 @@ var MCPServerManagerService = class {
|
|
|
1277
875
|
let pid;
|
|
1278
876
|
let ppid;
|
|
1279
877
|
let commandLine;
|
|
1280
|
-
if ((0,
|
|
878
|
+
if ((0, import_node_os2.platform)() === "win32") {
|
|
1281
879
|
if (processLine.startsWith('"ProcessId"') || processLine.startsWith("ProcessId")) continue;
|
|
1282
880
|
const parts = this.parseCSVLine(processLine);
|
|
1283
881
|
if (parts.length < 4) continue;
|
|
@@ -1300,7 +898,7 @@ var MCPServerManagerService = class {
|
|
|
1300
898
|
for (const [pid, processData] of processMap) {
|
|
1301
899
|
const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid);
|
|
1302
900
|
let commandMatchWin32 = false;
|
|
1303
|
-
if ((0,
|
|
901
|
+
if ((0, import_node_os2.platform)() === "win32") {
|
|
1304
902
|
let commandTokensOnWin32 = processData.commandTokens;
|
|
1305
903
|
if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith("cmd")) {
|
|
1306
904
|
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
@@ -1411,9 +1009,9 @@ var MCPServerManagerService = class {
|
|
|
1411
1009
|
return true;
|
|
1412
1010
|
}
|
|
1413
1011
|
getBaseCommand(fullCommandPath) {
|
|
1414
|
-
let baseCommand =
|
|
1415
|
-
if ((0,
|
|
1416
|
-
baseCommand =
|
|
1012
|
+
let baseCommand = import_node_path2.default.basename(fullCommandPath);
|
|
1013
|
+
if ((0, import_node_os2.platform)() === "win32") {
|
|
1014
|
+
baseCommand = import_node_path2.default.basename(fullCommandPath, ".exe");
|
|
1417
1015
|
}
|
|
1418
1016
|
baseCommand = baseCommand.toLowerCase();
|
|
1419
1017
|
return baseCommand;
|
|
@@ -1600,14 +1198,47 @@ var MCPFiles = class {
|
|
|
1600
1198
|
__name(this, "MCPFiles");
|
|
1601
1199
|
}
|
|
1602
1200
|
mcpConfigService;
|
|
1603
|
-
|
|
1201
|
+
customFiles;
|
|
1202
|
+
constructor(customFiles2) {
|
|
1604
1203
|
this.mcpConfigService = new MCPConfigService({ enableDirectoryBubbling: true });
|
|
1204
|
+
this.customFiles = customFiles2;
|
|
1605
1205
|
}
|
|
1606
1206
|
/**
|
|
1607
1207
|
* Find and process all MCP configuration files
|
|
1208
|
+
* If customFiles are provided, only those files are processed (replaces automatic discovery)
|
|
1608
1209
|
*/
|
|
1609
1210
|
async findFiles() {
|
|
1610
1211
|
try {
|
|
1212
|
+
if (this.customFiles && this.customFiles.length > 0) {
|
|
1213
|
+
const mcpFilesPathsData2 = await this.mcpConfigService.parseCustomFiles(this.customFiles);
|
|
1214
|
+
for (const groupName of Object.keys(mcpFilesPathsData2)) {
|
|
1215
|
+
const group = mcpFilesPathsData2[groupName];
|
|
1216
|
+
for (const filePathData of group.paths) {
|
|
1217
|
+
if (filePathData.servers && filePathData.servers.length > 0) {
|
|
1218
|
+
for (const server of filePathData.servers) {
|
|
1219
|
+
const serverConfig = {
|
|
1220
|
+
name: server.name,
|
|
1221
|
+
command: server.command,
|
|
1222
|
+
args: server.args,
|
|
1223
|
+
transport: server.transport,
|
|
1224
|
+
type: server.type,
|
|
1225
|
+
env: server.env
|
|
1226
|
+
};
|
|
1227
|
+
const serverManager = new MCPServerManagerService(serverConfig);
|
|
1228
|
+
const processDetection = serverManager.isRunning();
|
|
1229
|
+
let isRunning = false;
|
|
1230
|
+
if (processDetection) {
|
|
1231
|
+
if (typeof processDetection === "object" && processDetection.estimatedProduct === group.name) {
|
|
1232
|
+
isRunning = true;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
server.status = isRunning ? "running" : "stopped";
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
return mcpFilesPathsData2;
|
|
1241
|
+
}
|
|
1611
1242
|
const mcpFilesPathsData = await this.mcpConfigService.getMCPFileGroups();
|
|
1612
1243
|
for (const groupName of Object.keys(mcpFilesPathsData)) {
|
|
1613
1244
|
const group = mcpFilesPathsData[groupName];
|
|
@@ -2041,12 +1672,30 @@ var RenderService = class _RenderService {
|
|
|
2041
1672
|
// src/bin/cli.ts
|
|
2042
1673
|
var args = process.argv.slice(2);
|
|
2043
1674
|
var jsonOutput = args.includes("--json");
|
|
1675
|
+
var customFiles;
|
|
1676
|
+
var filesIndex = args.findIndex((arg) => arg === "--files");
|
|
1677
|
+
if (filesIndex !== -1 && filesIndex < args.length - 1) {
|
|
1678
|
+
const fileArgs = [];
|
|
1679
|
+
for (let i = filesIndex + 1; i < args.length; i++) {
|
|
1680
|
+
if (args[i].startsWith("--")) {
|
|
1681
|
+
break;
|
|
1682
|
+
}
|
|
1683
|
+
fileArgs.push(args[i]);
|
|
1684
|
+
}
|
|
1685
|
+
customFiles = fileArgs.flatMap(
|
|
1686
|
+
(arg) => arg.includes(",") ? arg.split(",").map((f) => f.trim()) : [arg.trim()]
|
|
1687
|
+
).filter((f) => f.length > 0);
|
|
1688
|
+
}
|
|
2044
1689
|
async function init() {
|
|
2045
1690
|
if (!jsonOutput) {
|
|
2046
1691
|
console.log();
|
|
2047
|
-
|
|
1692
|
+
if (customFiles && customFiles.length > 0) {
|
|
1693
|
+
console.log("[+] Analyzing specified MCP configuration files...");
|
|
1694
|
+
} else {
|
|
1695
|
+
console.log("[+] Detecting MCP Server configurations...");
|
|
1696
|
+
}
|
|
2048
1697
|
}
|
|
2049
|
-
const mcpFilesManager = new MCPFiles();
|
|
1698
|
+
const mcpFilesManager = new MCPFiles(customFiles);
|
|
2050
1699
|
const mcpFilesList = await mcpFilesManager.findFiles();
|
|
2051
1700
|
if (Object.keys(mcpFilesList).length === 0) {
|
|
2052
1701
|
exitWithError("No configuration for MCP Server applications found.");
|