ls-mcp 1.13.1 → 1.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/bin/cli.cjs +85 -525
- package/dist/bin/cli.mjs +75 -515
- 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/bin/cli.ts +40 -17
- 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/main.cjs
CHANGED
|
@@ -36,398 +36,11 @@ __export(main_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(main_exports);
|
|
37
37
|
|
|
38
38
|
// src/services/mcp-config-service.ts
|
|
39
|
-
var
|
|
40
|
-
var import_node_path3 = __toESM(require("path"), 1);
|
|
41
|
-
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
42
|
-
var import_node_util = __toESM(require("util"), 1);
|
|
43
|
-
|
|
44
|
-
// src/services/mcp-path-registry.ts
|
|
39
|
+
var import_node_os = require("os");
|
|
45
40
|
var import_node_path = __toESM(require("path"), 1);
|
|
46
|
-
var MCPPathRegistry = class _MCPPathRegistry {
|
|
47
|
-
static {
|
|
48
|
-
__name(this, "MCPPathRegistry");
|
|
49
|
-
}
|
|
50
|
-
static WINDOWS_PATHS = {
|
|
51
|
-
claude: [
|
|
52
|
-
{ filePath: import_node_path.default.join(process.env.APPDATA || "", "Claude", "claude_desktop_config.json"), type: "global" }
|
|
53
|
-
],
|
|
54
|
-
claude_code: [
|
|
55
|
-
{ filePath: ".mcp.json", type: "local" }
|
|
56
|
-
],
|
|
57
|
-
cursor: [
|
|
58
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
|
|
59
|
-
{ filePath: import_node_path.default.join(".cursor", "mcp.json"), type: "local" }
|
|
60
|
-
],
|
|
61
|
-
vscode: [
|
|
62
|
-
{ filePath: import_node_path.default.join(".vscode", "mcp.json"), type: "local" },
|
|
63
|
-
{ filePath: import_node_path.default.join(process.env.APPDATA || "", "Code", "User", "settings.json"), type: "global" },
|
|
64
|
-
{ filePath: import_node_path.default.join(process.env.APPDATA || "", "Code - Insiders", "User", "settings.json"), type: "global" },
|
|
65
|
-
{ filePath: import_node_path.default.join(process.env.APPDATA || "", "Code", "User", "mcp.json"), type: "global" },
|
|
66
|
-
{ filePath: import_node_path.default.join(process.env.APPDATA || "", "Code - Insiders", "User", "mcp.json"), type: "global" }
|
|
67
|
-
],
|
|
68
|
-
cline: [
|
|
69
|
-
{ filePath: import_node_path.default.join(process.env.APPDATA || "", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
70
|
-
{ filePath: import_node_path.default.join(process.env.APPDATA || "", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
71
|
-
],
|
|
72
|
-
windsurf: [
|
|
73
|
-
{ filePath: import_node_path.default.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
|
|
74
|
-
],
|
|
75
|
-
roo: [
|
|
76
|
-
{ filePath: import_node_path.default.join(process.env.APPDATA || "", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
77
|
-
{ filePath: import_node_path.default.join(process.env.APPDATA || "", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
78
|
-
],
|
|
79
|
-
"intellij-github-copilot": [
|
|
80
|
-
{ filePath: import_node_path.default.join(process.env.LOCALAPPDATA || "", "github-copilot", "intellij", "mcp.json"), type: "global" }
|
|
81
|
-
],
|
|
82
|
-
junie: [
|
|
83
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".junie", "mcp", "mcp.json"), type: "global" }
|
|
84
|
-
],
|
|
85
|
-
zed: [
|
|
86
|
-
{ filePath: import_node_path.default.join(process.env.LOCALAPPDATA || "", "zed", "settings.json"), type: "global" },
|
|
87
|
-
{ filePath: import_node_path.default.join(".zed", "settings.json"), type: "local" }
|
|
88
|
-
],
|
|
89
|
-
gemini: [
|
|
90
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
|
|
91
|
-
{ filePath: import_node_path.default.join(".gemini", "settings.json"), type: "local" }
|
|
92
|
-
]
|
|
93
|
-
};
|
|
94
|
-
static DARWIN_PATHS = {
|
|
95
|
-
claude: [
|
|
96
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Claude", "claude_desktop_config.json"), type: "global" }
|
|
97
|
-
],
|
|
98
|
-
claude_code: [
|
|
99
|
-
{ filePath: ".mcp.json", type: "local" }
|
|
100
|
-
],
|
|
101
|
-
cursor: [
|
|
102
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
|
|
103
|
-
{ filePath: import_node_path.default.join(".cursor", "mcp.json"), type: "local" }
|
|
104
|
-
],
|
|
105
|
-
vscode: [
|
|
106
|
-
{ filePath: import_node_path.default.join(".vscode", "mcp.json"), type: "local" },
|
|
107
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "settings.json"), type: "global" },
|
|
108
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "mcp.json"), type: "global" },
|
|
109
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "settings.json"), type: "global" },
|
|
110
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "mcp.json"), type: "global" }
|
|
111
|
-
],
|
|
112
|
-
cline: [
|
|
113
|
-
{ 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" },
|
|
114
|
-
{ 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" }
|
|
115
|
-
],
|
|
116
|
-
windsurf: [
|
|
117
|
-
{ filePath: import_node_path.default.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
|
|
118
|
-
],
|
|
119
|
-
roo: [
|
|
120
|
-
{ 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" },
|
|
121
|
-
{ 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" }
|
|
122
|
-
],
|
|
123
|
-
"intellij-github-copilot": [
|
|
124
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
|
|
125
|
-
],
|
|
126
|
-
junie: [
|
|
127
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".junie", "mcp", "mcp.json"), type: "global" },
|
|
128
|
-
{ filePath: import_node_path.default.join(".junie", "mcp", "mcp.json"), type: "local" }
|
|
129
|
-
],
|
|
130
|
-
zed: [
|
|
131
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "zed", "settings.json"), type: "global" },
|
|
132
|
-
{ filePath: import_node_path.default.join(".zed", "settings.json"), type: "local" }
|
|
133
|
-
],
|
|
134
|
-
gemini: [
|
|
135
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
|
|
136
|
-
{ filePath: import_node_path.default.join(".gemini", "settings.json"), type: "local" }
|
|
137
|
-
]
|
|
138
|
-
};
|
|
139
|
-
static LINUX_PATHS = {
|
|
140
|
-
claude: [
|
|
141
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Claude", "claude_desktop_config.json"), type: "global" }
|
|
142
|
-
],
|
|
143
|
-
claude_code: [
|
|
144
|
-
{ filePath: ".mcp.json", type: "local" }
|
|
145
|
-
],
|
|
146
|
-
cursor: [
|
|
147
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
|
|
148
|
-
{ filePath: import_node_path.default.join(".cursor", "mcp.json"), type: "local" }
|
|
149
|
-
],
|
|
150
|
-
vscode: [
|
|
151
|
-
{ filePath: import_node_path.default.join(".vscode", "mcp.json"), type: "local" },
|
|
152
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code", "User", "settings.json"), type: "global" },
|
|
153
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "settings.json"), type: "global" },
|
|
154
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code", "User", "mcp.json"), type: "global" },
|
|
155
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "mcp.json"), type: "global" },
|
|
156
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".mcp.json"), type: "global" }
|
|
157
|
-
],
|
|
158
|
-
cline: [
|
|
159
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
160
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
161
|
-
],
|
|
162
|
-
windsurf: [
|
|
163
|
-
{ filePath: import_node_path.default.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
|
|
164
|
-
],
|
|
165
|
-
roo: [
|
|
166
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
167
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
168
|
-
],
|
|
169
|
-
"intellij-github-copilot": [
|
|
170
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
|
|
171
|
-
],
|
|
172
|
-
junie: [
|
|
173
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".junie", "mcp.json"), type: "global" },
|
|
174
|
-
{ filePath: import_node_path.default.join(".junie", "mcp", "mcp.json"), type: "local" }
|
|
175
|
-
],
|
|
176
|
-
zed: [
|
|
177
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".config", "zed", "settings.json"), type: "global" },
|
|
178
|
-
{ filePath: import_node_path.default.join(".zed", "settings.json"), type: "local" }
|
|
179
|
-
],
|
|
180
|
-
gemini: [
|
|
181
|
-
{ filePath: import_node_path.default.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
|
|
182
|
-
{ filePath: import_node_path.default.join(".gemini", "settings.json"), type: "local" }
|
|
183
|
-
]
|
|
184
|
-
};
|
|
185
|
-
customApps = /* @__PURE__ */ new Map();
|
|
186
|
-
/**
|
|
187
|
-
* Get all MCP configuration file paths for a specific operating system
|
|
188
|
-
*/
|
|
189
|
-
getPathsForOS(os) {
|
|
190
|
-
switch (os.toLowerCase()) {
|
|
191
|
-
case "win32":
|
|
192
|
-
case "windows":
|
|
193
|
-
return { ..._MCPPathRegistry.WINDOWS_PATHS };
|
|
194
|
-
case "darwin":
|
|
195
|
-
case "macos":
|
|
196
|
-
return { ..._MCPPathRegistry.DARWIN_PATHS };
|
|
197
|
-
case "linux":
|
|
198
|
-
return { ..._MCPPathRegistry.LINUX_PATHS };
|
|
199
|
-
default:
|
|
200
|
-
throw new Error(`Unsupported operating system: ${os}`);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Get MCP configuration file paths for a specific app on a specific OS
|
|
205
|
-
*/
|
|
206
|
-
getPathsForApp(os, appName) {
|
|
207
|
-
const osPaths = this.getPathsForOS(os);
|
|
208
|
-
const appPaths = osPaths[appName];
|
|
209
|
-
if (!appPaths) {
|
|
210
|
-
throw new Error(`App '${appName}' not found for OS '${os}'`);
|
|
211
|
-
}
|
|
212
|
-
return [...appPaths];
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Get all supported app names for a specific OS
|
|
216
|
-
*/
|
|
217
|
-
getSupportedApps(os) {
|
|
218
|
-
const osPaths = this.getPathsForOS(os);
|
|
219
|
-
return Object.keys(osPaths);
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Get all supported operating systems
|
|
223
|
-
*/
|
|
224
|
-
getSupportedOperatingSystems() {
|
|
225
|
-
return ["win32", "darwin", "linux"];
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Register a custom app with custom paths for a specific OS
|
|
229
|
-
*/
|
|
230
|
-
registerCustomApp(os, appName, paths) {
|
|
231
|
-
if (!this.customApps.has(os)) {
|
|
232
|
-
this.customApps.set(os, {});
|
|
233
|
-
}
|
|
234
|
-
const osCustomApps = this.customApps.get(os);
|
|
235
|
-
osCustomApps[appName] = [...paths];
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Get paths including custom registered apps
|
|
239
|
-
*/
|
|
240
|
-
getPathsForOSWithCustom(os) {
|
|
241
|
-
const basePaths = this.getPathsForOS(os);
|
|
242
|
-
const customPaths = this.customApps.get(os) || {};
|
|
243
|
-
return { ...basePaths, ...customPaths };
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
// src/services/mcp-config-parser.ts
|
|
248
41
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
249
|
-
var
|
|
250
|
-
var
|
|
251
|
-
static {
|
|
252
|
-
__name(this, "MCPConfigParser");
|
|
253
|
-
}
|
|
254
|
-
filePath;
|
|
255
|
-
fileContents = null;
|
|
256
|
-
parsed = false;
|
|
257
|
-
valid = false;
|
|
258
|
-
fileContentsData = null;
|
|
259
|
-
constructor(filePath) {
|
|
260
|
-
this.filePath = filePath;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Parse the configuration file and return structured data
|
|
264
|
-
*/
|
|
265
|
-
async parseConfigFile() {
|
|
266
|
-
if (this.parsed) {
|
|
267
|
-
return {
|
|
268
|
-
raw: this.fileContentsData,
|
|
269
|
-
parsed: this.parsed,
|
|
270
|
-
valid: this.valid,
|
|
271
|
-
servers: await this.extractMCPServers(this.fileContentsData)
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
this.parsed = true;
|
|
275
|
-
const fileContent = await this.getFileContent();
|
|
276
|
-
try {
|
|
277
|
-
this.fileContentsData = JSON.parse(fileContent);
|
|
278
|
-
if (typeof this.fileContentsData === "object") {
|
|
279
|
-
this.valid = true;
|
|
280
|
-
}
|
|
281
|
-
} catch (e) {
|
|
282
|
-
}
|
|
283
|
-
if (!this.valid) {
|
|
284
|
-
try {
|
|
285
|
-
this.fileContentsData = (0, import_jsonc_parser.parse)(fileContent);
|
|
286
|
-
if (typeof this.fileContentsData === "object") {
|
|
287
|
-
this.valid = true;
|
|
288
|
-
}
|
|
289
|
-
} catch (error) {
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
if (!this.valid) {
|
|
293
|
-
throw new Error(`Failed to parse configuration file: ${this.filePath}`);
|
|
294
|
-
}
|
|
295
|
-
return {
|
|
296
|
-
raw: this.fileContentsData,
|
|
297
|
-
parsed: this.parsed,
|
|
298
|
-
valid: this.valid,
|
|
299
|
-
servers: await this.extractMCPServers(this.fileContentsData)
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Extract MCP servers from parsed configuration data
|
|
304
|
-
*/
|
|
305
|
-
async extractMCPServers(configData) {
|
|
306
|
-
if (!configData || typeof configData !== "object") {
|
|
307
|
-
return {};
|
|
308
|
-
}
|
|
309
|
-
if (configData.servers && typeof configData.servers === "object") {
|
|
310
|
-
return this.normalizeServerConfigs(configData.servers);
|
|
311
|
-
}
|
|
312
|
-
if (configData.mcp?.servers && typeof configData.mcp.servers === "object") {
|
|
313
|
-
return this.normalizeServerConfigs(configData.mcp.servers);
|
|
314
|
-
}
|
|
315
|
-
if (configData.mcpServers && typeof configData.mcpServers === "object") {
|
|
316
|
-
return this.normalizeServerConfigs(configData.mcpServers);
|
|
317
|
-
}
|
|
318
|
-
if (configData.context_servers && typeof configData.context_servers === "object") {
|
|
319
|
-
return this.normalizeServerConfigs(configData.context_servers);
|
|
320
|
-
}
|
|
321
|
-
return {};
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Normalize server configurations to ensure consistent structure
|
|
325
|
-
*/
|
|
326
|
-
normalizeServerConfigs(servers) {
|
|
327
|
-
const normalized = {};
|
|
328
|
-
for (const [serverName, serverConfig] of Object.entries(servers)) {
|
|
329
|
-
if (serverConfig && typeof serverConfig === "object") {
|
|
330
|
-
const env = serverConfig.env && typeof serverConfig.env === "object" ? serverConfig.env : void 0;
|
|
331
|
-
normalized[serverName] = {
|
|
332
|
-
name: serverName,
|
|
333
|
-
command: serverConfig.command || "",
|
|
334
|
-
args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
|
|
335
|
-
type: this.validateType(serverConfig.type) ? serverConfig.type : this.inferTransportType(serverConfig),
|
|
336
|
-
url: serverConfig.url,
|
|
337
|
-
env
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
return normalized;
|
|
342
|
-
}
|
|
343
|
-
/**
|
|
344
|
-
* Validate type value
|
|
345
|
-
*/
|
|
346
|
-
validateType(type) {
|
|
347
|
-
return ["sse", "http", "stdio", "streamable-http"].includes(type);
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* Infer transport type from server configuration when type field is not explicitly set
|
|
351
|
-
*/
|
|
352
|
-
inferTransportType(serverConfig) {
|
|
353
|
-
if (serverConfig.url && typeof serverConfig.url === "string") {
|
|
354
|
-
return "http";
|
|
355
|
-
}
|
|
356
|
-
if (Array.isArray(serverConfig.args)) {
|
|
357
|
-
const argsString = serverConfig.args.join(" ").toLowerCase();
|
|
358
|
-
if (argsString.includes("stdio")) {
|
|
359
|
-
return "stdio";
|
|
360
|
-
}
|
|
361
|
-
if (argsString.includes("http")) {
|
|
362
|
-
return "http";
|
|
363
|
-
}
|
|
364
|
-
if (argsString.includes("sse")) {
|
|
365
|
-
return "sse";
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
if (serverConfig.command && typeof serverConfig.command === "string") {
|
|
369
|
-
return "stdio";
|
|
370
|
-
}
|
|
371
|
-
return void 0;
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Validate server configuration
|
|
375
|
-
*/
|
|
376
|
-
validateServerConfig(serverConfig) {
|
|
377
|
-
if (!serverConfig || typeof serverConfig !== "object") {
|
|
378
|
-
return false;
|
|
379
|
-
}
|
|
380
|
-
if (!serverConfig.name || typeof serverConfig.name !== "string") {
|
|
381
|
-
return false;
|
|
382
|
-
}
|
|
383
|
-
if (!serverConfig.command || typeof serverConfig.command !== "string") {
|
|
384
|
-
return false;
|
|
385
|
-
}
|
|
386
|
-
return true;
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* Get supported configuration keys that the parser recognizes
|
|
390
|
-
*/
|
|
391
|
-
getSupportedConfigKeys() {
|
|
392
|
-
return ["servers", "mcp.servers", "mcpServers", "context_servers"];
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Check if the configuration file has valid syntax
|
|
396
|
-
*/
|
|
397
|
-
async isValidSyntax() {
|
|
398
|
-
try {
|
|
399
|
-
const configData = await this.parseConfigFile();
|
|
400
|
-
return configData.valid;
|
|
401
|
-
} catch (error) {
|
|
402
|
-
return false;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
* Count the number of MCP servers in the configuration
|
|
407
|
-
*/
|
|
408
|
-
async countMCPServers() {
|
|
409
|
-
try {
|
|
410
|
-
const configData = await this.parseConfigFile();
|
|
411
|
-
return Object.keys(configData.servers).length;
|
|
412
|
-
} catch (error) {
|
|
413
|
-
return 0;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Get the raw file content
|
|
418
|
-
*/
|
|
419
|
-
async getFileContent() {
|
|
420
|
-
if (this.fileContents) {
|
|
421
|
-
return this.fileContents;
|
|
422
|
-
}
|
|
423
|
-
try {
|
|
424
|
-
this.fileContents = await import_promises.default.readFile(this.filePath, "utf-8");
|
|
425
|
-
return this.fileContents;
|
|
426
|
-
} catch (error) {
|
|
427
|
-
throw new Error(`Failed to read file: ${this.filePath}`);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
};
|
|
42
|
+
var import_node_util = __toESM(require("util"), 1);
|
|
43
|
+
var import_agent_files = require("agent-files");
|
|
431
44
|
|
|
432
45
|
// src/services/credential-detection-service.ts
|
|
433
46
|
var CredentialDetectionService = class {
|
|
@@ -710,77 +323,6 @@ var CredentialDetectionService = class {
|
|
|
710
323
|
}
|
|
711
324
|
};
|
|
712
325
|
|
|
713
|
-
// src/services/directory-bubble-service.ts
|
|
714
|
-
var import_node_path2 = __toESM(require("path"), 1);
|
|
715
|
-
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
716
|
-
var import_node_os = require("os");
|
|
717
|
-
var DirectoryBubbleService = class {
|
|
718
|
-
static {
|
|
719
|
-
__name(this, "DirectoryBubbleService");
|
|
720
|
-
}
|
|
721
|
-
/**
|
|
722
|
-
* Find a local MCP config file by bubbling up the directory tree
|
|
723
|
-
* @param localPath - The relative path to search for (e.g., '.vscode/mcp.json')
|
|
724
|
-
* @param startDir - The directory to start searching from
|
|
725
|
-
* @returns The absolute path to the found config file, or null if not found
|
|
726
|
-
*/
|
|
727
|
-
async findLocalConfigInParentDirectories(localPath, startDir) {
|
|
728
|
-
try {
|
|
729
|
-
let currentDir = import_node_path2.default.resolve(startDir);
|
|
730
|
-
const homeDir = (0, import_node_os.homedir)();
|
|
731
|
-
const rootDir = "/";
|
|
732
|
-
let iterationCount = 0;
|
|
733
|
-
const maxIterations = 100;
|
|
734
|
-
const startDirResult = await this.checkDirectoryForConfig(currentDir, localPath);
|
|
735
|
-
if (startDirResult) {
|
|
736
|
-
return import_node_path2.default.join(currentDir, localPath);
|
|
737
|
-
}
|
|
738
|
-
while (currentDir !== homeDir && currentDir !== rootDir && iterationCount < maxIterations) {
|
|
739
|
-
const parentDir = this.getParentDirectory(currentDir);
|
|
740
|
-
if (!parentDir || parentDir === currentDir) {
|
|
741
|
-
break;
|
|
742
|
-
}
|
|
743
|
-
if (parentDir === currentDir || parentDir.length >= currentDir.length) {
|
|
744
|
-
break;
|
|
745
|
-
}
|
|
746
|
-
currentDir = parentDir;
|
|
747
|
-
iterationCount++;
|
|
748
|
-
const found = await this.checkDirectoryForConfig(currentDir, localPath);
|
|
749
|
-
if (found) {
|
|
750
|
-
return import_node_path2.default.join(currentDir, localPath);
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
return null;
|
|
754
|
-
} catch (error) {
|
|
755
|
-
return null;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
/**
|
|
759
|
-
* Check if a config file exists in the specified directory
|
|
760
|
-
* @param dir - The directory to check
|
|
761
|
-
* @param configPath - The relative path to the config file
|
|
762
|
-
* @returns True if the config file exists and is accessible
|
|
763
|
-
*/
|
|
764
|
-
async checkDirectoryForConfig(dir, configPath) {
|
|
765
|
-
try {
|
|
766
|
-
const fullPath = import_node_path2.default.join(dir, configPath);
|
|
767
|
-
await import_promises2.default.access(fullPath);
|
|
768
|
-
return true;
|
|
769
|
-
} catch (error) {
|
|
770
|
-
return false;
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
/**
|
|
774
|
-
* Get the parent directory of the specified directory
|
|
775
|
-
* @param dir - The directory to get the parent of
|
|
776
|
-
* @returns The parent directory path, or null if already at root
|
|
777
|
-
*/
|
|
778
|
-
getParentDirectory(dir) {
|
|
779
|
-
const parent = import_node_path2.default.dirname(dir);
|
|
780
|
-
return parent === dir ? null : parent;
|
|
781
|
-
}
|
|
782
|
-
};
|
|
783
|
-
|
|
784
326
|
// src/services/mcp-version-detection-service.ts
|
|
785
327
|
var MCPVersionDetectionService = class {
|
|
786
328
|
static {
|
|
@@ -959,10 +501,10 @@ var MCPConfigService = class {
|
|
|
959
501
|
versionDetectionService;
|
|
960
502
|
enableDirectoryBubbling;
|
|
961
503
|
constructor(options = {}) {
|
|
962
|
-
this.pathRegistry = new MCPPathRegistry();
|
|
963
|
-
this.currentOS = (0,
|
|
504
|
+
this.pathRegistry = new import_agent_files.MCPPathRegistry();
|
|
505
|
+
this.currentOS = (0, import_node_os.platform)();
|
|
964
506
|
this.debug = import_node_util.default.debuglog("ls-mcp");
|
|
965
|
-
this.directoryBubbleService = new DirectoryBubbleService();
|
|
507
|
+
this.directoryBubbleService = new import_agent_files.DirectoryBubbleService();
|
|
966
508
|
this.versionDetectionService = new MCPVersionDetectionService();
|
|
967
509
|
this.enableDirectoryBubbling = options.enableDirectoryBubbling ?? false;
|
|
968
510
|
}
|
|
@@ -1049,7 +591,7 @@ var MCPConfigService = class {
|
|
|
1049
591
|
*/
|
|
1050
592
|
async validateConfigFile(filePath) {
|
|
1051
593
|
try {
|
|
1052
|
-
await
|
|
594
|
+
await import_promises.default.access(filePath);
|
|
1053
595
|
const parser = this.createParser(filePath);
|
|
1054
596
|
return await parser.isValidSyntax();
|
|
1055
597
|
} catch (error) {
|
|
@@ -1060,7 +602,7 @@ var MCPConfigService = class {
|
|
|
1060
602
|
* Create a parser instance (can be overridden for testing)
|
|
1061
603
|
*/
|
|
1062
604
|
createParser(filePath) {
|
|
1063
|
-
return new MCPConfigParser(filePath);
|
|
605
|
+
return new import_agent_files.MCPConfigParser(filePath);
|
|
1064
606
|
}
|
|
1065
607
|
/**
|
|
1066
608
|
* Get MCP file groups with resolved paths and server information
|
|
@@ -1069,7 +611,8 @@ var MCPConfigService = class {
|
|
|
1069
611
|
try {
|
|
1070
612
|
const appPaths = this.getAllConfigFiles();
|
|
1071
613
|
const mcpFilesPathsData = {};
|
|
1072
|
-
for (const
|
|
614
|
+
for (const groupName of Object.keys(appPaths)) {
|
|
615
|
+
const paths = appPaths[groupName];
|
|
1073
616
|
mcpFilesPathsData[groupName] = {
|
|
1074
617
|
name: groupName,
|
|
1075
618
|
friendlyName: this.getFriendlyName(groupName),
|
|
@@ -1080,10 +623,10 @@ var MCPConfigService = class {
|
|
|
1080
623
|
let totalServersCount = 0;
|
|
1081
624
|
for (const filePathData of paths) {
|
|
1082
625
|
let resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
1083
|
-
let absolutePath =
|
|
626
|
+
let absolutePath = import_node_path.default.resolve(resolvedPath);
|
|
1084
627
|
if (filePathData.type === "local" && this.enableDirectoryBubbling) {
|
|
1085
628
|
try {
|
|
1086
|
-
await
|
|
629
|
+
await import_promises.default.access(resolvedPath);
|
|
1087
630
|
} catch (error) {
|
|
1088
631
|
const bubbledPath = await this.directoryBubbleService.findLocalConfigInParentDirectories(
|
|
1089
632
|
filePathData.filePath,
|
|
@@ -1091,7 +634,7 @@ var MCPConfigService = class {
|
|
|
1091
634
|
);
|
|
1092
635
|
if (bubbledPath) {
|
|
1093
636
|
resolvedPath = bubbledPath;
|
|
1094
|
-
absolutePath =
|
|
637
|
+
absolutePath = import_node_path.default.resolve(resolvedPath);
|
|
1095
638
|
}
|
|
1096
639
|
}
|
|
1097
640
|
}
|
|
@@ -1100,7 +643,7 @@ var MCPConfigService = class {
|
|
|
1100
643
|
}
|
|
1101
644
|
uniqueFilePaths.add(absolutePath);
|
|
1102
645
|
try {
|
|
1103
|
-
await
|
|
646
|
+
await import_promises.default.access(resolvedPath);
|
|
1104
647
|
const parser = this.createParser(resolvedPath);
|
|
1105
648
|
const parsable = await parser.isValidSyntax();
|
|
1106
649
|
filePathData.parsable = parsable;
|
|
@@ -1209,9 +752,9 @@ var MCPConfigService = class {
|
|
|
1209
752
|
};
|
|
1210
753
|
|
|
1211
754
|
// src/services/mcp-server-manager-service.ts
|
|
1212
|
-
var
|
|
755
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
1213
756
|
var import_node_child_process = require("child_process");
|
|
1214
|
-
var
|
|
757
|
+
var import_node_os2 = require("os");
|
|
1215
758
|
var MCPServerManagerService = class {
|
|
1216
759
|
static {
|
|
1217
760
|
__name(this, "MCPServerManagerService");
|
|
@@ -1267,7 +810,7 @@ var MCPServerManagerService = class {
|
|
|
1267
810
|
isRunning() {
|
|
1268
811
|
try {
|
|
1269
812
|
let psOutput;
|
|
1270
|
-
if ((0,
|
|
813
|
+
if ((0, import_node_os2.platform)() === "win32") {
|
|
1271
814
|
psOutput = (0, import_node_child_process.execSync)('powershell -Command "Get-CimInstance -ClassName Win32_Process | Select-Object ProcessId,Name,CommandLine,ParentProcessId | ConvertTo-Csv -NoTypeInformation"', {
|
|
1272
815
|
encoding: "utf8",
|
|
1273
816
|
timeout: 5e3
|
|
@@ -1285,7 +828,7 @@ var MCPServerManagerService = class {
|
|
|
1285
828
|
let pid;
|
|
1286
829
|
let ppid;
|
|
1287
830
|
let commandLine;
|
|
1288
|
-
if ((0,
|
|
831
|
+
if ((0, import_node_os2.platform)() === "win32") {
|
|
1289
832
|
if (processLine.startsWith('"ProcessId"') || processLine.startsWith("ProcessId")) continue;
|
|
1290
833
|
const parts = this.parseCSVLine(processLine);
|
|
1291
834
|
if (parts.length < 4) continue;
|
|
@@ -1308,7 +851,7 @@ var MCPServerManagerService = class {
|
|
|
1308
851
|
for (const [pid, processData] of processMap) {
|
|
1309
852
|
const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid);
|
|
1310
853
|
let commandMatchWin32 = false;
|
|
1311
|
-
if ((0,
|
|
854
|
+
if ((0, import_node_os2.platform)() === "win32") {
|
|
1312
855
|
let commandTokensOnWin32 = processData.commandTokens;
|
|
1313
856
|
if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith("cmd")) {
|
|
1314
857
|
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
@@ -1419,9 +962,9 @@ var MCPServerManagerService = class {
|
|
|
1419
962
|
return true;
|
|
1420
963
|
}
|
|
1421
964
|
getBaseCommand(fullCommandPath) {
|
|
1422
|
-
let baseCommand =
|
|
1423
|
-
if ((0,
|
|
1424
|
-
baseCommand =
|
|
965
|
+
let baseCommand = import_node_path2.default.basename(fullCommandPath);
|
|
966
|
+
if ((0, import_node_os2.platform)() === "win32") {
|
|
967
|
+
baseCommand = import_node_path2.default.basename(fullCommandPath, ".exe");
|
|
1425
968
|
}
|
|
1426
969
|
baseCommand = baseCommand.toLowerCase();
|
|
1427
970
|
return baseCommand;
|
package/dist/main.d.cts
CHANGED
|
@@ -1,27 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
parsed: boolean;
|
|
4
|
-
valid: boolean;
|
|
5
|
-
servers: Record<string, MCPServerConfig>;
|
|
6
|
-
}
|
|
7
|
-
interface MCPServerConfig {
|
|
8
|
-
name: string;
|
|
9
|
-
command: string;
|
|
10
|
-
args?: string[];
|
|
11
|
-
transport?: 'stdio' | 'sse' | 'http';
|
|
12
|
-
type?: 'sse' | 'http' | 'stdio' | 'streamable-http';
|
|
13
|
-
url?: string;
|
|
14
|
-
env?: Record<string, string>;
|
|
15
|
-
headers?: Record<string, string>;
|
|
16
|
-
}
|
|
1
|
+
import { MCPFilePath as MCPFilePath$1, MCPConfigParser } from 'agent-files';
|
|
2
|
+
|
|
17
3
|
interface MCPAppMetadata {
|
|
18
4
|
name: string;
|
|
19
5
|
friendlyName: string;
|
|
20
6
|
paths: MCPFilePath[];
|
|
21
7
|
}
|
|
22
|
-
interface MCPFilePath {
|
|
23
|
-
filePath: string;
|
|
24
|
-
type: 'local' | 'global';
|
|
8
|
+
interface MCPFilePath extends MCPFilePath$1 {
|
|
25
9
|
parsable?: boolean;
|
|
26
10
|
servers?: MCPServerInfo[];
|
|
27
11
|
}
|
|
@@ -66,25 +50,6 @@ interface CredentialAnalysisResult {
|
|
|
66
50
|
riskLevel: 'none' | 'low' | 'high';
|
|
67
51
|
}
|
|
68
52
|
|
|
69
|
-
declare class MCPConfigParser {
|
|
70
|
-
private filePath;
|
|
71
|
-
private fileContents;
|
|
72
|
-
private parsed;
|
|
73
|
-
private valid;
|
|
74
|
-
private fileContentsData;
|
|
75
|
-
constructor(filePath: string);
|
|
76
|
-
parseConfigFile(): Promise<MCPConfigData>;
|
|
77
|
-
extractMCPServers(configData: any): Promise<Record<string, MCPServerConfig>>;
|
|
78
|
-
private normalizeServerConfigs;
|
|
79
|
-
private validateType;
|
|
80
|
-
private inferTransportType;
|
|
81
|
-
validateServerConfig(serverConfig: MCPServerConfig): boolean;
|
|
82
|
-
getSupportedConfigKeys(): string[];
|
|
83
|
-
isValidSyntax(): Promise<boolean>;
|
|
84
|
-
countMCPServers(): Promise<number>;
|
|
85
|
-
private getFileContent;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
53
|
interface MCPConfigServiceOptions {
|
|
89
54
|
enableDirectoryBubbling?: boolean;
|
|
90
55
|
}
|