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.cjs +22 -479
- package/dist/bin/cli.mjs +12 -469
- package/dist/main.cjs +22 -479
- package/dist/main.d.cts +3 -38
- package/dist/main.d.ts +3 -38
- package/dist/main.mjs +12 -469
- package/package.json +2 -1
- package/src/services/mcp-config-service.ts +6 -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;
|
|
@@ -1201,9 +744,9 @@ var MCPConfigService = class {
|
|
|
1201
744
|
};
|
|
1202
745
|
|
|
1203
746
|
// src/services/mcp-server-manager-service.ts
|
|
1204
|
-
var
|
|
747
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
1205
748
|
var import_node_child_process = require("child_process");
|
|
1206
|
-
var
|
|
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,
|
|
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,
|
|
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,
|
|
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 =
|
|
1415
|
-
if ((0,
|
|
1416
|
-
baseCommand =
|
|
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;
|