ls-mcp 1.9.1 → 1.11.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 +29 -3
- package/dist/bin/cli.cjs +952 -289
- package/dist/bin/cli.mjs +935 -272
- package/dist/main.cjs +814 -263
- package/dist/main.d.cts +82 -14
- package/dist/main.d.ts +82 -14
- package/dist/main.mjs +814 -265
- package/package.json +3 -1
- package/src/bin/cli.ts +37 -5
- package/src/components/credential-warning.ts +37 -0
- package/src/components/summary.ts +57 -0
- package/src/main.ts +50 -140
- package/src/services/credential-detection-service.ts +166 -0
- package/src/services/directory-bubble-service.ts +82 -0
- package/src/services/mcp-config-linter-service.ts +13 -74
- package/src/services/mcp-config-parser.ts +234 -0
- package/src/services/mcp-config-service.ts +304 -0
- package/src/services/mcp-path-registry.ts +164 -0
- package/src/services/mcp-server-manager-service.ts +5 -4
- package/src/services/render-service.ts +46 -2
- package/src/types/mcp-config-service.types.ts +76 -0
- package/src/types.ts +1 -1
- package/src/utils/url-utils.ts +24 -0
- package/src/utils/os-paths.ts +0 -102
package/dist/main.cjs
CHANGED
|
@@ -34,16 +34,174 @@ __export(main_exports, {
|
|
|
34
34
|
MCPFiles: () => MCPFiles
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(main_exports);
|
|
37
|
-
|
|
37
|
+
|
|
38
|
+
// src/services/mcp-config-service.ts
|
|
38
39
|
var import_node_os2 = require("os");
|
|
39
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);
|
|
40
43
|
|
|
41
|
-
// src/services/mcp-
|
|
44
|
+
// src/services/mcp-path-registry.ts
|
|
45
|
+
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
|
+
customApps = /* @__PURE__ */ new Map();
|
|
140
|
+
/**
|
|
141
|
+
* Get all MCP configuration file paths for a specific operating system
|
|
142
|
+
*/
|
|
143
|
+
getPathsForOS(os) {
|
|
144
|
+
switch (os.toLowerCase()) {
|
|
145
|
+
case "win32":
|
|
146
|
+
case "windows":
|
|
147
|
+
return { ..._MCPPathRegistry.WINDOWS_PATHS };
|
|
148
|
+
case "darwin":
|
|
149
|
+
case "macos":
|
|
150
|
+
return { ..._MCPPathRegistry.DARWIN_PATHS };
|
|
151
|
+
default:
|
|
152
|
+
throw new Error(`Unsupported operating system: ${os}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get MCP configuration file paths for a specific app on a specific OS
|
|
157
|
+
*/
|
|
158
|
+
getPathsForApp(os, appName) {
|
|
159
|
+
const osPaths = this.getPathsForOS(os);
|
|
160
|
+
const appPaths = osPaths[appName];
|
|
161
|
+
if (!appPaths) {
|
|
162
|
+
throw new Error(`App '${appName}' not found for OS '${os}'`);
|
|
163
|
+
}
|
|
164
|
+
return [...appPaths];
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get all supported app names for a specific OS
|
|
168
|
+
*/
|
|
169
|
+
getSupportedApps(os) {
|
|
170
|
+
const osPaths = this.getPathsForOS(os);
|
|
171
|
+
return Object.keys(osPaths);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Get all supported operating systems
|
|
175
|
+
*/
|
|
176
|
+
getSupportedOperatingSystems() {
|
|
177
|
+
return ["win32", "darwin"];
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Register a custom app with custom paths for a specific OS
|
|
181
|
+
*/
|
|
182
|
+
registerCustomApp(os, appName, paths) {
|
|
183
|
+
if (!this.customApps.has(os)) {
|
|
184
|
+
this.customApps.set(os, {});
|
|
185
|
+
}
|
|
186
|
+
const osCustomApps = this.customApps.get(os);
|
|
187
|
+
osCustomApps[appName] = [...paths];
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Get paths including custom registered apps
|
|
191
|
+
*/
|
|
192
|
+
getPathsForOSWithCustom(os) {
|
|
193
|
+
const basePaths = this.getPathsForOS(os);
|
|
194
|
+
const customPaths = this.customApps.get(os) || {};
|
|
195
|
+
return { ...basePaths, ...customPaths };
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// src/services/mcp-config-parser.ts
|
|
42
200
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
43
201
|
var import_jsonc_parser = require("jsonc-parser");
|
|
44
|
-
var
|
|
202
|
+
var MCPConfigParser = class {
|
|
45
203
|
static {
|
|
46
|
-
__name(this, "
|
|
204
|
+
__name(this, "MCPConfigParser");
|
|
47
205
|
}
|
|
48
206
|
filePath;
|
|
49
207
|
fileContents = null;
|
|
@@ -53,9 +211,17 @@ var MCPConfigLinterService = class {
|
|
|
53
211
|
constructor(filePath) {
|
|
54
212
|
this.filePath = filePath;
|
|
55
213
|
}
|
|
56
|
-
|
|
214
|
+
/**
|
|
215
|
+
* Parse the configuration file and return structured data
|
|
216
|
+
*/
|
|
217
|
+
async parseConfigFile() {
|
|
57
218
|
if (this.parsed) {
|
|
58
|
-
return
|
|
219
|
+
return {
|
|
220
|
+
raw: this.fileContentsData,
|
|
221
|
+
parsed: this.parsed,
|
|
222
|
+
valid: this.valid,
|
|
223
|
+
servers: await this.extractMCPServers(this.fileContentsData)
|
|
224
|
+
};
|
|
59
225
|
}
|
|
60
226
|
this.parsed = true;
|
|
61
227
|
const fileContent = await this.getFileContent();
|
|
@@ -63,63 +229,630 @@ var MCPConfigLinterService = class {
|
|
|
63
229
|
this.fileContentsData = JSON.parse(fileContent);
|
|
64
230
|
if (typeof this.fileContentsData === "object") {
|
|
65
231
|
this.valid = true;
|
|
66
|
-
return;
|
|
67
232
|
}
|
|
68
233
|
} catch (e) {
|
|
69
234
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
this.
|
|
235
|
+
if (!this.valid) {
|
|
236
|
+
try {
|
|
237
|
+
this.fileContentsData = (0, import_jsonc_parser.parse)(fileContent);
|
|
238
|
+
if (typeof this.fileContentsData === "object") {
|
|
239
|
+
this.valid = true;
|
|
240
|
+
}
|
|
241
|
+
} catch (error) {
|
|
74
242
|
}
|
|
75
|
-
} catch (error) {
|
|
76
243
|
}
|
|
244
|
+
if (!this.valid) {
|
|
245
|
+
throw new Error(`Failed to parse configuration file: ${this.filePath}`);
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
raw: this.fileContentsData,
|
|
249
|
+
parsed: this.parsed,
|
|
250
|
+
valid: this.valid,
|
|
251
|
+
servers: await this.extractMCPServers(this.fileContentsData)
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Extract MCP servers from parsed configuration data
|
|
256
|
+
*/
|
|
257
|
+
async extractMCPServers(configData) {
|
|
258
|
+
if (!configData || typeof configData !== "object") {
|
|
259
|
+
return {};
|
|
260
|
+
}
|
|
261
|
+
if (configData.servers && typeof configData.servers === "object") {
|
|
262
|
+
return this.normalizeServerConfigs(configData.servers);
|
|
263
|
+
}
|
|
264
|
+
if (configData.mcp?.servers && typeof configData.mcp.servers === "object") {
|
|
265
|
+
return this.normalizeServerConfigs(configData.mcp.servers);
|
|
266
|
+
}
|
|
267
|
+
if (configData.mcpServers && typeof configData.mcpServers === "object") {
|
|
268
|
+
return this.normalizeServerConfigs(configData.mcpServers);
|
|
269
|
+
}
|
|
270
|
+
if (configData.context_servers && typeof configData.context_servers === "object") {
|
|
271
|
+
return this.normalizeServerConfigs(configData.context_servers);
|
|
272
|
+
}
|
|
273
|
+
return {};
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Normalize server configurations to ensure consistent structure
|
|
277
|
+
*/
|
|
278
|
+
normalizeServerConfigs(servers) {
|
|
279
|
+
const normalized = {};
|
|
280
|
+
for (const [serverName, serverConfig] of Object.entries(servers)) {
|
|
281
|
+
if (serverConfig && typeof serverConfig === "object") {
|
|
282
|
+
const env = serverConfig.env && typeof serverConfig.env === "object" ? serverConfig.env : void 0;
|
|
283
|
+
normalized[serverName] = {
|
|
284
|
+
name: serverName,
|
|
285
|
+
command: serverConfig.command || "",
|
|
286
|
+
args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
|
|
287
|
+
type: this.validateType(serverConfig.type) ? serverConfig.type : this.inferTransportType(serverConfig),
|
|
288
|
+
url: serverConfig.url,
|
|
289
|
+
env
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return normalized;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Validate type value
|
|
297
|
+
*/
|
|
298
|
+
validateType(type) {
|
|
299
|
+
return ["sse", "http", "stdio", "streamable-http"].includes(type);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Infer transport type from server configuration when type field is not explicitly set
|
|
303
|
+
*/
|
|
304
|
+
inferTransportType(serverConfig) {
|
|
305
|
+
if (serverConfig.url && typeof serverConfig.url === "string") {
|
|
306
|
+
return "http";
|
|
307
|
+
}
|
|
308
|
+
if (Array.isArray(serverConfig.args)) {
|
|
309
|
+
const argsString = serverConfig.args.join(" ").toLowerCase();
|
|
310
|
+
if (argsString.includes("stdio")) {
|
|
311
|
+
return "stdio";
|
|
312
|
+
}
|
|
313
|
+
if (argsString.includes("http")) {
|
|
314
|
+
return "http";
|
|
315
|
+
}
|
|
316
|
+
if (argsString.includes("sse")) {
|
|
317
|
+
return "sse";
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (serverConfig.command && typeof serverConfig.command === "string") {
|
|
321
|
+
return "stdio";
|
|
322
|
+
}
|
|
323
|
+
return void 0;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Validate server configuration
|
|
327
|
+
*/
|
|
328
|
+
validateServerConfig(serverConfig) {
|
|
329
|
+
if (!serverConfig || typeof serverConfig !== "object") {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
if (!serverConfig.name || typeof serverConfig.name !== "string") {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
if (!serverConfig.command || typeof serverConfig.command !== "string") {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
return true;
|
|
77
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* Get supported configuration keys that the parser recognizes
|
|
342
|
+
*/
|
|
343
|
+
getSupportedConfigKeys() {
|
|
344
|
+
return ["servers", "mcp.servers", "mcpServers", "context_servers"];
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Check if the configuration file has valid syntax
|
|
348
|
+
*/
|
|
78
349
|
async isValidSyntax() {
|
|
79
350
|
try {
|
|
80
|
-
await this.
|
|
81
|
-
return
|
|
351
|
+
const configData = await this.parseConfigFile();
|
|
352
|
+
return configData.valid;
|
|
82
353
|
} catch (error) {
|
|
83
354
|
return false;
|
|
84
355
|
}
|
|
85
356
|
}
|
|
357
|
+
/**
|
|
358
|
+
* Count the number of MCP servers in the configuration
|
|
359
|
+
*/
|
|
86
360
|
async countMCPServers() {
|
|
87
361
|
try {
|
|
88
|
-
const
|
|
89
|
-
return Object.keys(
|
|
362
|
+
const configData = await this.parseConfigFile();
|
|
363
|
+
return Object.keys(configData.servers).length;
|
|
90
364
|
} catch (error) {
|
|
91
365
|
return 0;
|
|
92
366
|
}
|
|
93
367
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
368
|
+
/**
|
|
369
|
+
* Get the raw file content
|
|
370
|
+
*/
|
|
371
|
+
async getFileContent() {
|
|
372
|
+
if (this.fileContents) {
|
|
373
|
+
return this.fileContents;
|
|
98
374
|
}
|
|
99
|
-
|
|
100
|
-
|
|
375
|
+
try {
|
|
376
|
+
this.fileContents = await import_promises.default.readFile(this.filePath, "utf-8");
|
|
377
|
+
return this.fileContents;
|
|
378
|
+
} catch (error) {
|
|
379
|
+
throw new Error(`Failed to read file: ${this.filePath}`);
|
|
101
380
|
}
|
|
102
|
-
|
|
103
|
-
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
// src/services/credential-detection-service.ts
|
|
385
|
+
var CredentialDetectionService = class {
|
|
386
|
+
static {
|
|
387
|
+
__name(this, "CredentialDetectionService");
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Credential patterns grouped by risk level for easier maintenance
|
|
391
|
+
*/
|
|
392
|
+
static CREDENTIAL_PATTERNS = {
|
|
393
|
+
high: [
|
|
394
|
+
// API Keys and Tokens
|
|
395
|
+
/api[_-]?key/i,
|
|
396
|
+
/api[_-]?token/i,
|
|
397
|
+
/access[_-]?token/i,
|
|
398
|
+
/secret[_-]?key/i,
|
|
399
|
+
/private[_-]?key/i,
|
|
400
|
+
// Authentication Tokens
|
|
401
|
+
/auth[_-]?token/i,
|
|
402
|
+
/bearer[_-]?token/i,
|
|
403
|
+
/jwt[_-]?token/i,
|
|
404
|
+
/oauth[_-]?token/i,
|
|
405
|
+
// Passwords
|
|
406
|
+
/password/i,
|
|
407
|
+
/passwd/i,
|
|
408
|
+
/pwd/i,
|
|
409
|
+
// Credentials
|
|
410
|
+
/credential/i,
|
|
411
|
+
/creds/i,
|
|
412
|
+
// Specific service patterns
|
|
413
|
+
/openai[_-]?api[_-]?key/i,
|
|
414
|
+
/anthropic[_-]?api[_-]?key/i,
|
|
415
|
+
/firecrawl[_-]?api[_-]?key/i,
|
|
416
|
+
/github[_-]?token/i,
|
|
417
|
+
/gitlab[_-]?token/i,
|
|
418
|
+
/bitbucket[_-]?token/i,
|
|
419
|
+
// Database passwords
|
|
420
|
+
/db[_-]?password/i,
|
|
421
|
+
/database[_-]?password/i,
|
|
422
|
+
/redis[_-]?password/i,
|
|
423
|
+
/postgres[_-]?password/i,
|
|
424
|
+
/mysql[_-]?password/i,
|
|
425
|
+
// Cloud services
|
|
426
|
+
/aws[_-]?secret[_-]?access[_-]?key/i,
|
|
427
|
+
/aws[_-]?access[_-]?key[_-]?id/i,
|
|
428
|
+
/azure[_-]?key/i,
|
|
429
|
+
/gcp[_-]?key/i,
|
|
430
|
+
/google[_-]?api[_-]?key/i,
|
|
431
|
+
/gemini[_-]?api[_-]?key/i,
|
|
432
|
+
/claude[_-]?api[_-]?key/i
|
|
433
|
+
],
|
|
434
|
+
low: [
|
|
435
|
+
// Organization and Account IDs
|
|
436
|
+
/org[_-]?id/i,
|
|
437
|
+
/organization[_-]?id/i,
|
|
438
|
+
/account[_-]?id/i,
|
|
439
|
+
/user[_-]?id/i,
|
|
440
|
+
/openai[_-]?org[_-]?id/i
|
|
441
|
+
]
|
|
442
|
+
};
|
|
443
|
+
/**
|
|
444
|
+
* Check if an environment variable name suggests it might contain credentials
|
|
445
|
+
*/
|
|
446
|
+
static isPotentialCredential(envVarName) {
|
|
447
|
+
return this.CREDENTIAL_PATTERNS.high.some((pattern) => pattern.test(envVarName)) || this.CREDENTIAL_PATTERNS.low.some((pattern) => pattern.test(envVarName));
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Analyze environment variables and return credential detection results
|
|
451
|
+
*/
|
|
452
|
+
static analyzeEnvironmentVariables(env) {
|
|
453
|
+
if (!env || typeof env !== "object") {
|
|
454
|
+
return {
|
|
455
|
+
hasCredentials: false,
|
|
456
|
+
credentialVars: [],
|
|
457
|
+
riskLevel: "none"
|
|
458
|
+
};
|
|
104
459
|
}
|
|
105
|
-
|
|
106
|
-
|
|
460
|
+
const credentialVars = [];
|
|
461
|
+
for (const [name, value] of Object.entries(env)) {
|
|
462
|
+
if (this.isPotentialCredential(name)) {
|
|
463
|
+
credentialVars.push({
|
|
464
|
+
name,
|
|
465
|
+
value: this.maskValue(value),
|
|
466
|
+
riskLevel: this.assessRiskLevel(name)
|
|
467
|
+
});
|
|
468
|
+
}
|
|
107
469
|
}
|
|
108
|
-
|
|
470
|
+
const hasCredentials = credentialVars.length > 0;
|
|
471
|
+
const riskLevel = this.calculateOverallRiskLevel(credentialVars);
|
|
472
|
+
return {
|
|
473
|
+
hasCredentials,
|
|
474
|
+
credentialVars,
|
|
475
|
+
riskLevel
|
|
476
|
+
};
|
|
109
477
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
478
|
+
/**
|
|
479
|
+
* Mask sensitive values for display (show only first and last character)
|
|
480
|
+
*/
|
|
481
|
+
static maskValue(value) {
|
|
482
|
+
if (!value || value.length <= 2) {
|
|
483
|
+
return value;
|
|
484
|
+
}
|
|
485
|
+
const first = value.charAt(0);
|
|
486
|
+
const last = value.charAt(value.length - 1);
|
|
487
|
+
const maskedLength = Math.min(value.length - 2, 8);
|
|
488
|
+
return `${first}${"*".repeat(maskedLength)}${last}`;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Assess risk level for a specific credential variable
|
|
492
|
+
*/
|
|
493
|
+
static assessRiskLevel(name) {
|
|
494
|
+
if (this.CREDENTIAL_PATTERNS.high.some((pattern) => pattern.test(name))) {
|
|
495
|
+
return "high";
|
|
496
|
+
}
|
|
497
|
+
if (this.CREDENTIAL_PATTERNS.low.some((pattern) => pattern.test(name))) {
|
|
498
|
+
return "low";
|
|
499
|
+
}
|
|
500
|
+
return "high";
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Calculate overall risk level based on all credential variables
|
|
504
|
+
*/
|
|
505
|
+
static calculateOverallRiskLevel(credentialVars) {
|
|
506
|
+
if (credentialVars.length === 0) {
|
|
507
|
+
return "none";
|
|
508
|
+
}
|
|
509
|
+
const hasHighRisk = credentialVars.some((v) => v.riskLevel === "high");
|
|
510
|
+
if (hasHighRisk) {
|
|
511
|
+
return "high";
|
|
512
|
+
}
|
|
513
|
+
return "low";
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
// src/services/directory-bubble-service.ts
|
|
518
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
519
|
+
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
520
|
+
var import_node_os = require("os");
|
|
521
|
+
var DirectoryBubbleService = class {
|
|
522
|
+
static {
|
|
523
|
+
__name(this, "DirectoryBubbleService");
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Find a local MCP config file by bubbling up the directory tree
|
|
527
|
+
* @param localPath - The relative path to search for (e.g., '.vscode/mcp.json')
|
|
528
|
+
* @param startDir - The directory to start searching from
|
|
529
|
+
* @returns The absolute path to the found config file, or null if not found
|
|
530
|
+
*/
|
|
531
|
+
async findLocalConfigInParentDirectories(localPath, startDir) {
|
|
532
|
+
try {
|
|
533
|
+
let currentDir = import_node_path2.default.resolve(startDir);
|
|
534
|
+
const homeDir = (0, import_node_os.homedir)();
|
|
535
|
+
const rootDir = "/";
|
|
536
|
+
let iterationCount = 0;
|
|
537
|
+
const maxIterations = 100;
|
|
538
|
+
const startDirResult = await this.checkDirectoryForConfig(currentDir, localPath);
|
|
539
|
+
if (startDirResult) {
|
|
540
|
+
return import_node_path2.default.join(currentDir, localPath);
|
|
541
|
+
}
|
|
542
|
+
while (currentDir !== homeDir && currentDir !== rootDir && iterationCount < maxIterations) {
|
|
543
|
+
const parentDir = this.getParentDirectory(currentDir);
|
|
544
|
+
if (!parentDir || parentDir === currentDir) {
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
if (parentDir === currentDir || parentDir.length >= currentDir.length) {
|
|
548
|
+
break;
|
|
549
|
+
}
|
|
550
|
+
currentDir = parentDir;
|
|
551
|
+
iterationCount++;
|
|
552
|
+
const found = await this.checkDirectoryForConfig(currentDir, localPath);
|
|
553
|
+
if (found) {
|
|
554
|
+
return import_node_path2.default.join(currentDir, localPath);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
return null;
|
|
558
|
+
} catch (error) {
|
|
559
|
+
return null;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Check if a config file exists in the specified directory
|
|
564
|
+
* @param dir - The directory to check
|
|
565
|
+
* @param configPath - The relative path to the config file
|
|
566
|
+
* @returns True if the config file exists and is accessible
|
|
567
|
+
*/
|
|
568
|
+
async checkDirectoryForConfig(dir, configPath) {
|
|
569
|
+
try {
|
|
570
|
+
const fullPath = import_node_path2.default.join(dir, configPath);
|
|
571
|
+
await import_promises2.default.access(fullPath);
|
|
572
|
+
return true;
|
|
573
|
+
} catch (error) {
|
|
574
|
+
return false;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Get the parent directory of the specified directory
|
|
579
|
+
* @param dir - The directory to get the parent of
|
|
580
|
+
* @returns The parent directory path, or null if already at root
|
|
581
|
+
*/
|
|
582
|
+
getParentDirectory(dir) {
|
|
583
|
+
const parent = import_node_path2.default.dirname(dir);
|
|
584
|
+
return parent === dir ? null : parent;
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
// src/utils/url-utils.ts
|
|
589
|
+
function extractHostname(urlString) {
|
|
590
|
+
try {
|
|
591
|
+
let urlToParse = urlString;
|
|
592
|
+
if (!urlToParse.includes("://")) {
|
|
593
|
+
urlToParse = `http://${urlToParse}`;
|
|
594
|
+
}
|
|
595
|
+
const url = new URL(urlToParse);
|
|
596
|
+
return url.hostname;
|
|
597
|
+
} catch (error) {
|
|
598
|
+
return urlString;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
__name(extractHostname, "extractHostname");
|
|
602
|
+
|
|
603
|
+
// src/services/mcp-config-service.ts
|
|
604
|
+
var MCPConfigService = class {
|
|
605
|
+
static {
|
|
606
|
+
__name(this, "MCPConfigService");
|
|
607
|
+
}
|
|
608
|
+
pathRegistry;
|
|
609
|
+
currentOS;
|
|
610
|
+
debug;
|
|
611
|
+
directoryBubbleService;
|
|
612
|
+
enableDirectoryBubbling;
|
|
613
|
+
constructor(options = {}) {
|
|
614
|
+
this.pathRegistry = new MCPPathRegistry();
|
|
615
|
+
this.currentOS = (0, import_node_os2.platform)();
|
|
616
|
+
this.debug = import_node_util.default.debuglog("ls-mcp");
|
|
617
|
+
this.directoryBubbleService = new DirectoryBubbleService();
|
|
618
|
+
this.enableDirectoryBubbling = options.enableDirectoryBubbling ?? false;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Get MCP configuration files for a specific AI application on the current OS
|
|
622
|
+
*/
|
|
623
|
+
getConfigFilesPerApp(appName) {
|
|
624
|
+
try {
|
|
625
|
+
return this.pathRegistry.getPathsForApp(this.currentOS, appName);
|
|
626
|
+
} catch (error) {
|
|
627
|
+
throw new Error(`Failed to get config files for app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Get MCP configuration files for all AI applications on the current OS
|
|
632
|
+
*/
|
|
633
|
+
getAllConfigFiles() {
|
|
634
|
+
try {
|
|
635
|
+
return this.pathRegistry.getPathsForOS(this.currentOS);
|
|
636
|
+
} catch (error) {
|
|
637
|
+
throw new Error(`Failed to get all config files: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Get MCP servers configured for a specific AI application on the current OS
|
|
642
|
+
*/
|
|
643
|
+
async getMCPServersPerApp(appName) {
|
|
644
|
+
try {
|
|
645
|
+
const appPaths = this.getConfigFilesPerApp(appName);
|
|
646
|
+
const allServers = [];
|
|
647
|
+
for (const filePath of appPaths) {
|
|
648
|
+
const servers = await this.parseConfigFileForServers(filePath.filePath);
|
|
649
|
+
allServers.push(...servers);
|
|
650
|
+
}
|
|
651
|
+
return allServers;
|
|
652
|
+
} catch (error) {
|
|
653
|
+
throw new Error(`Failed to get MCP servers for app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Get MCP servers configured for all AI applications on the current OS
|
|
658
|
+
*/
|
|
659
|
+
async getAllMCPServers() {
|
|
660
|
+
try {
|
|
661
|
+
const allApps = this.pathRegistry.getSupportedApps(this.currentOS);
|
|
662
|
+
const allServers = {};
|
|
663
|
+
for (const appName of allApps) {
|
|
664
|
+
try {
|
|
665
|
+
allServers[appName] = await this.getMCPServersPerApp(appName);
|
|
666
|
+
} catch (error) {
|
|
667
|
+
this.debug(`Failed to get servers for app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
668
|
+
allServers[appName] = [];
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
return allServers;
|
|
672
|
+
} catch (error) {
|
|
673
|
+
throw new Error(`Failed to get all MCP servers: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Get metadata for all supported AI applications on the current OS
|
|
678
|
+
*/
|
|
679
|
+
getSupportedApps() {
|
|
680
|
+
try {
|
|
681
|
+
const appNames = this.pathRegistry.getSupportedApps(this.currentOS);
|
|
682
|
+
const appPaths = this.pathRegistry.getPathsForOS(this.currentOS);
|
|
683
|
+
return appNames.map((appName) => ({
|
|
684
|
+
name: appName,
|
|
685
|
+
friendlyName: this.getFriendlyName(appName),
|
|
686
|
+
paths: appPaths[appName] || []
|
|
687
|
+
}));
|
|
688
|
+
} catch (error) {
|
|
689
|
+
throw new Error(`Failed to get supported apps: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Get all supported operating systems
|
|
694
|
+
*/
|
|
695
|
+
getSupportedOperatingSystems() {
|
|
696
|
+
return this.pathRegistry.getSupportedOperatingSystems();
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Validate if a configuration file exists and is parsable
|
|
700
|
+
*/
|
|
701
|
+
async validateConfigFile(filePath) {
|
|
702
|
+
try {
|
|
703
|
+
await import_promises3.default.access(filePath);
|
|
704
|
+
const parser = this.createParser(filePath);
|
|
705
|
+
return await parser.isValidSyntax();
|
|
706
|
+
} catch (error) {
|
|
707
|
+
return false;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Create a parser instance (can be overridden for testing)
|
|
712
|
+
*/
|
|
713
|
+
createParser(filePath) {
|
|
714
|
+
return new MCPConfigParser(filePath);
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Get MCP file groups with resolved paths and server information
|
|
718
|
+
*/
|
|
719
|
+
async getMCPFileGroups() {
|
|
720
|
+
try {
|
|
721
|
+
const appPaths = this.getAllConfigFiles();
|
|
722
|
+
const mcpFilesPathsData = {};
|
|
723
|
+
for (const [groupName, paths] of Object.entries(appPaths)) {
|
|
724
|
+
mcpFilesPathsData[groupName] = {
|
|
725
|
+
name: groupName,
|
|
726
|
+
friendlyName: this.getFriendlyName(groupName),
|
|
727
|
+
paths: [],
|
|
728
|
+
stats: { serversCount: 0 }
|
|
729
|
+
};
|
|
730
|
+
const uniqueFilePaths = /* @__PURE__ */ new Set();
|
|
731
|
+
let totalServersCount = 0;
|
|
732
|
+
for (const filePathData of paths) {
|
|
733
|
+
let resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
734
|
+
let absolutePath = import_node_path3.default.resolve(resolvedPath);
|
|
735
|
+
if (filePathData.type === "local" && this.enableDirectoryBubbling) {
|
|
736
|
+
try {
|
|
737
|
+
await import_promises3.default.access(resolvedPath);
|
|
738
|
+
} catch (error) {
|
|
739
|
+
const bubbledPath = await this.directoryBubbleService.findLocalConfigInParentDirectories(
|
|
740
|
+
filePathData.filePath,
|
|
741
|
+
process.cwd()
|
|
742
|
+
);
|
|
743
|
+
if (bubbledPath) {
|
|
744
|
+
resolvedPath = bubbledPath;
|
|
745
|
+
absolutePath = import_node_path3.default.resolve(resolvedPath);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
if (uniqueFilePaths.has(absolutePath)) {
|
|
750
|
+
continue;
|
|
751
|
+
}
|
|
752
|
+
uniqueFilePaths.add(absolutePath);
|
|
753
|
+
try {
|
|
754
|
+
await import_promises3.default.access(resolvedPath);
|
|
755
|
+
const parser = this.createParser(resolvedPath);
|
|
756
|
+
const parsable = await parser.isValidSyntax();
|
|
757
|
+
filePathData.parsable = parsable;
|
|
758
|
+
if (parsable) {
|
|
759
|
+
const configData = await parser.parseConfigFile();
|
|
760
|
+
const servers = await this.convertToMCPServerInfo(configData.servers || {});
|
|
761
|
+
filePathData.servers = servers;
|
|
762
|
+
totalServersCount += servers.length;
|
|
763
|
+
}
|
|
764
|
+
mcpFilesPathsData[groupName].paths.push(filePathData);
|
|
765
|
+
} catch (error) {
|
|
766
|
+
this.debug(`Skipping file ${resolvedPath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
if (mcpFilesPathsData[groupName] && mcpFilesPathsData[groupName].stats) {
|
|
770
|
+
mcpFilesPathsData[groupName].stats.serversCount = totalServersCount;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
return mcpFilesPathsData;
|
|
774
|
+
} catch (error) {
|
|
775
|
+
throw new Error(`Failed to get MCP file groups: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Register a custom app with custom paths for the current OS
|
|
780
|
+
*/
|
|
781
|
+
registerCustomApp(appName, paths) {
|
|
782
|
+
try {
|
|
783
|
+
this.pathRegistry.registerCustomApp(this.currentOS, appName, paths);
|
|
784
|
+
} catch (error) {
|
|
785
|
+
throw new Error(`Failed to register custom app '${appName}': ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Parse a configuration file and return server information
|
|
790
|
+
*/
|
|
791
|
+
async parseConfigFileForServers(filePath) {
|
|
792
|
+
try {
|
|
793
|
+
const parser = this.createParser(filePath);
|
|
794
|
+
const configData = await parser.parseConfigFile();
|
|
795
|
+
return await this.convertToMCPServerInfo(configData.servers || {});
|
|
796
|
+
} catch (error) {
|
|
797
|
+
this.debug(`Failed to parse config file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
798
|
+
return [];
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Convert parsed server configs to MCPServerInfo format
|
|
803
|
+
*/
|
|
804
|
+
async convertToMCPServerInfo(servers) {
|
|
805
|
+
const serverInfos = [];
|
|
806
|
+
for (const [serverName, serverConfig] of Object.entries(servers)) {
|
|
807
|
+
if (serverConfig && typeof serverConfig === "object") {
|
|
808
|
+
let source;
|
|
809
|
+
if (serverConfig.url) {
|
|
810
|
+
source = extractHostname(serverConfig.url);
|
|
811
|
+
} else {
|
|
812
|
+
source = serverConfig.command || "";
|
|
813
|
+
}
|
|
814
|
+
serverInfos.push({
|
|
815
|
+
name: serverName,
|
|
816
|
+
command: serverConfig.command || "",
|
|
817
|
+
args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
|
|
818
|
+
transport: serverConfig.type === "streamable-http" ? "http" : serverConfig.type,
|
|
819
|
+
// Map streamable-http to http
|
|
820
|
+
type: serverConfig.type,
|
|
821
|
+
source,
|
|
822
|
+
env: serverConfig.env,
|
|
823
|
+
status: "stopped",
|
|
824
|
+
// Default status, will be updated by server manager
|
|
825
|
+
credentials: CredentialDetectionService.analyzeEnvironmentVariables(serverConfig.env)
|
|
826
|
+
});
|
|
827
|
+
}
|
|
113
828
|
}
|
|
114
|
-
|
|
115
|
-
|
|
829
|
+
return serverInfos;
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Get friendly name for an app
|
|
833
|
+
*/
|
|
834
|
+
getFriendlyName(appName) {
|
|
835
|
+
const friendlyNames = {
|
|
836
|
+
claude: "Claude Desktop",
|
|
837
|
+
claude_code: "Claude Code",
|
|
838
|
+
cursor: "Cursor",
|
|
839
|
+
vscode: "VS Code",
|
|
840
|
+
cline: "Cline",
|
|
841
|
+
windsurf: "Windsurf",
|
|
842
|
+
roo: "Roo",
|
|
843
|
+
"intellij-github-copilot": "IntelliJ GitHub Copilot",
|
|
844
|
+
junie: "IntelliJ Junie",
|
|
845
|
+
zed: "Zed",
|
|
846
|
+
gemini: "Gemini CLI"
|
|
847
|
+
};
|
|
848
|
+
return friendlyNames[appName] || appName;
|
|
116
849
|
}
|
|
117
850
|
};
|
|
118
851
|
|
|
119
852
|
// src/services/mcp-server-manager-service.ts
|
|
120
|
-
var
|
|
853
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
121
854
|
var import_node_child_process = require("child_process");
|
|
122
|
-
var
|
|
855
|
+
var import_node_os3 = require("os");
|
|
123
856
|
var MCPServerManagerService = class {
|
|
124
857
|
static {
|
|
125
858
|
__name(this, "MCPServerManagerService");
|
|
@@ -139,14 +872,14 @@ var MCPServerManagerService = class {
|
|
|
139
872
|
if (serverConfig?.type && serverConfig.type === "sse") {
|
|
140
873
|
this.transport = "sse";
|
|
141
874
|
}
|
|
142
|
-
if (serverConfig?.type && serverConfig.type === "http") {
|
|
875
|
+
if (serverConfig?.type && (serverConfig.type === "http" || serverConfig.type === "streamable-http")) {
|
|
143
876
|
this.transport = "http";
|
|
144
877
|
}
|
|
145
878
|
if (serverConfig?.type && serverConfig.type === "stdio") {
|
|
146
879
|
this.transport = "stdio";
|
|
147
880
|
}
|
|
148
881
|
if (serverConfig.url) {
|
|
149
|
-
this.source = serverConfig.url;
|
|
882
|
+
this.source = extractHostname(serverConfig.url);
|
|
150
883
|
this.transport = "http";
|
|
151
884
|
} else {
|
|
152
885
|
const fullCommand = [serverConfig.command, ...serverConfig.args || []].join(" ");
|
|
@@ -175,7 +908,7 @@ var MCPServerManagerService = class {
|
|
|
175
908
|
isRunning() {
|
|
176
909
|
try {
|
|
177
910
|
let psOutput;
|
|
178
|
-
if ((0,
|
|
911
|
+
if ((0, import_node_os3.platform)() === "win32") {
|
|
179
912
|
psOutput = (0, import_node_child_process.execSync)('powershell -Command "Get-CimInstance -ClassName Win32_Process | Select-Object ProcessId,Name,CommandLine,ParentProcessId | ConvertTo-Csv -NoTypeInformation"', {
|
|
180
913
|
encoding: "utf8",
|
|
181
914
|
timeout: 5e3
|
|
@@ -193,7 +926,7 @@ var MCPServerManagerService = class {
|
|
|
193
926
|
let pid;
|
|
194
927
|
let ppid;
|
|
195
928
|
let commandLine;
|
|
196
|
-
if ((0,
|
|
929
|
+
if ((0, import_node_os3.platform)() === "win32") {
|
|
197
930
|
if (processLine.startsWith('"ProcessId"') || processLine.startsWith("ProcessId")) continue;
|
|
198
931
|
const parts = this.parseCSVLine(processLine);
|
|
199
932
|
if (parts.length < 4) continue;
|
|
@@ -216,7 +949,7 @@ var MCPServerManagerService = class {
|
|
|
216
949
|
for (const [pid, processData] of processMap) {
|
|
217
950
|
const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid);
|
|
218
951
|
let commandMatchWin32 = false;
|
|
219
|
-
if ((0,
|
|
952
|
+
if ((0, import_node_os3.platform)() === "win32") {
|
|
220
953
|
let commandTokensOnWin32 = processData.commandTokens;
|
|
221
954
|
if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith("cmd")) {
|
|
222
955
|
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
@@ -327,9 +1060,9 @@ var MCPServerManagerService = class {
|
|
|
327
1060
|
return true;
|
|
328
1061
|
}
|
|
329
1062
|
getBaseCommand(fullCommandPath) {
|
|
330
|
-
let baseCommand =
|
|
331
|
-
if ((0,
|
|
332
|
-
baseCommand =
|
|
1063
|
+
let baseCommand = import_node_path4.default.basename(fullCommandPath);
|
|
1064
|
+
if ((0, import_node_os3.platform)() === "win32") {
|
|
1065
|
+
baseCommand = import_node_path4.default.basename(fullCommandPath, ".exe");
|
|
333
1066
|
}
|
|
334
1067
|
baseCommand = baseCommand.toLowerCase();
|
|
335
1068
|
return baseCommand;
|
|
@@ -510,240 +1243,58 @@ var MCPServerManagerService = class {
|
|
|
510
1243
|
}
|
|
511
1244
|
};
|
|
512
1245
|
|
|
513
|
-
// src/utils/os-paths.ts
|
|
514
|
-
var import_node_path2 = __toESM(require("path"), 1);
|
|
515
|
-
var appData = process.env.APPDATA || "";
|
|
516
|
-
var localAppData = process.env.LOCALAPPDATA || "";
|
|
517
|
-
var homeDir = process.env.HOME || "";
|
|
518
|
-
function getWindowsPaths() {
|
|
519
|
-
return {
|
|
520
|
-
claude: [
|
|
521
|
-
{ filePath: import_node_path2.default.join(appData, "Claude", "claude_desktop_config.json"), type: "global" }
|
|
522
|
-
],
|
|
523
|
-
claude_code: [
|
|
524
|
-
{ filePath: ".mcp.json", type: "local" }
|
|
525
|
-
],
|
|
526
|
-
cursor: [
|
|
527
|
-
{ filePath: import_node_path2.default.join(homeDir, ".cursor", "mcp.json"), type: "global" },
|
|
528
|
-
{ filePath: import_node_path2.default.join(".cursor", "mcp.json"), type: "local" }
|
|
529
|
-
],
|
|
530
|
-
vscode: [
|
|
531
|
-
{ filePath: import_node_path2.default.join(".vscode", "mcp.json"), type: "local" },
|
|
532
|
-
{ filePath: import_node_path2.default.join(appData, "Code", "User", "settings.json"), type: "global" },
|
|
533
|
-
{ filePath: import_node_path2.default.join(appData, "Code - Insiders", "User", "settings.json"), type: "global" },
|
|
534
|
-
{ filePath: import_node_path2.default.join(appData, "Code", "User", "mcp.json"), type: "global" },
|
|
535
|
-
{ filePath: import_node_path2.default.join(appData, "Code - Insiders", "User", "mcp.json"), type: "global" }
|
|
536
|
-
],
|
|
537
|
-
cline: [
|
|
538
|
-
{ filePath: import_node_path2.default.join(appData, "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
539
|
-
{ filePath: import_node_path2.default.join(appData, "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
540
|
-
],
|
|
541
|
-
windsurf: [
|
|
542
|
-
{ filePath: import_node_path2.default.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
|
|
543
|
-
],
|
|
544
|
-
roo: [
|
|
545
|
-
{ filePath: import_node_path2.default.join(appData, "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
546
|
-
{ filePath: import_node_path2.default.join(appData, "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
547
|
-
],
|
|
548
|
-
"intellij-github-copilot": [
|
|
549
|
-
{ filePath: import_node_path2.default.join(localAppData, "github-copilot", "intellij", "mcp.json"), type: "global" }
|
|
550
|
-
],
|
|
551
|
-
junie: [
|
|
552
|
-
{ filePath: import_node_path2.default.join(homeDir, ".junie", "mcp", "mcp.json"), type: "global" }
|
|
553
|
-
],
|
|
554
|
-
zed: [
|
|
555
|
-
{ filePath: import_node_path2.default.join(localAppData, "zed", "settings.json"), type: "global" },
|
|
556
|
-
{ filePath: import_node_path2.default.join(".zed", "settings.json"), type: "local" }
|
|
557
|
-
],
|
|
558
|
-
gemini: [
|
|
559
|
-
{ filePath: import_node_path2.default.join(homeDir, ".gemini", "settings.json"), type: "global" },
|
|
560
|
-
{ filePath: import_node_path2.default.join(".gemini", "settings.json"), type: "local" }
|
|
561
|
-
]
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
__name(getWindowsPaths, "getWindowsPaths");
|
|
565
|
-
function getDarwinPaths() {
|
|
566
|
-
return {
|
|
567
|
-
claude: [
|
|
568
|
-
{ filePath: import_node_path2.default.join(homeDir, "Library", "Application Support", "Claude", "claude_desktop_config.json"), type: "global" }
|
|
569
|
-
],
|
|
570
|
-
claude_code: [
|
|
571
|
-
{ filePath: ".mcp.json", type: "local" }
|
|
572
|
-
],
|
|
573
|
-
cursor: [
|
|
574
|
-
{ filePath: import_node_path2.default.join(homeDir, ".cursor", "mcp.json"), type: "global" },
|
|
575
|
-
{ filePath: import_node_path2.default.join(".cursor", "mcp.json"), type: "local" }
|
|
576
|
-
],
|
|
577
|
-
vscode: [
|
|
578
|
-
{ filePath: import_node_path2.default.join(".vscode", "mcp.json"), type: "local" },
|
|
579
|
-
{ filePath: import_node_path2.default.join(homeDir, "Library", "Application Support", "Code", "User", "settings.json"), type: "global" },
|
|
580
|
-
{ filePath: import_node_path2.default.join(homeDir, "Library", "Application Support", "Code", "User", "mcp.json"), type: "global" },
|
|
581
|
-
{ filePath: import_node_path2.default.join(homeDir, "Library", "Application Support", "Code - Insiders", "User", "settings.json"), type: "global" },
|
|
582
|
-
{ filePath: import_node_path2.default.join(homeDir, "Library", "Application Support", "Code - Insiders", "User", "mcp.json"), type: "global" }
|
|
583
|
-
],
|
|
584
|
-
cline: [
|
|
585
|
-
{ filePath: import_node_path2.default.join(homeDir, "Library", "Application Support", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
586
|
-
{ filePath: import_node_path2.default.join(homeDir, "Library", "Application Support", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
587
|
-
],
|
|
588
|
-
windsurf: [
|
|
589
|
-
{ filePath: import_node_path2.default.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
|
|
590
|
-
],
|
|
591
|
-
roo: [
|
|
592
|
-
{ filePath: import_node_path2.default.join(homeDir, "Library", "Application Support", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
593
|
-
{ filePath: import_node_path2.default.join(homeDir, "Library", "Application Support", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
594
|
-
],
|
|
595
|
-
"intellij-github-copilot": [
|
|
596
|
-
{ filePath: import_node_path2.default.join(homeDir, ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
|
|
597
|
-
],
|
|
598
|
-
junie: [
|
|
599
|
-
{ filePath: import_node_path2.default.join(homeDir, ".junie", "mcp", "mcp.json"), type: "global" },
|
|
600
|
-
{ filePath: import_node_path2.default.join(".junie", "mcp", "mcp.json"), type: "local" }
|
|
601
|
-
],
|
|
602
|
-
zed: [
|
|
603
|
-
{ filePath: import_node_path2.default.join(homeDir, ".config", "zed", "settings.json"), type: "global" },
|
|
604
|
-
{ filePath: import_node_path2.default.join(".zed", "settings.json"), type: "local" }
|
|
605
|
-
],
|
|
606
|
-
gemini: [
|
|
607
|
-
{ filePath: import_node_path2.default.join(homeDir, ".gemini", "settings.json"), type: "global" },
|
|
608
|
-
{ filePath: import_node_path2.default.join(".gemini", "settings.json"), type: "local" }
|
|
609
|
-
]
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
__name(getDarwinPaths, "getDarwinPaths");
|
|
613
|
-
|
|
614
1246
|
// src/main.ts
|
|
615
|
-
var osSpecificPaths = {};
|
|
616
|
-
if ((0, import_node_os2.platform)() === "win32") {
|
|
617
|
-
osSpecificPaths = getWindowsPaths();
|
|
618
|
-
} else {
|
|
619
|
-
osSpecificPaths = getDarwinPaths();
|
|
620
|
-
}
|
|
621
1247
|
var MCPFiles = class {
|
|
622
1248
|
static {
|
|
623
1249
|
__name(this, "MCPFiles");
|
|
624
1250
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
friendlyName: "Claude Desktop",
|
|
629
|
-
paths: osSpecificPaths["claude"]
|
|
630
|
-
},
|
|
631
|
-
claude_code: {
|
|
632
|
-
name: "claude-code",
|
|
633
|
-
friendlyName: "Claude Code",
|
|
634
|
-
paths: osSpecificPaths["claude_code"]
|
|
635
|
-
},
|
|
636
|
-
cursor: {
|
|
637
|
-
name: "cursor",
|
|
638
|
-
friendlyName: "Cursor",
|
|
639
|
-
paths: osSpecificPaths["cursor"]
|
|
640
|
-
},
|
|
641
|
-
vscode: {
|
|
642
|
-
name: "vscode",
|
|
643
|
-
friendlyName: "VS Code",
|
|
644
|
-
paths: osSpecificPaths["vscode"]
|
|
645
|
-
},
|
|
646
|
-
cline: {
|
|
647
|
-
name: "cline",
|
|
648
|
-
friendlyName: "Cline",
|
|
649
|
-
paths: osSpecificPaths["cline"]
|
|
650
|
-
},
|
|
651
|
-
windsurf: {
|
|
652
|
-
name: "windsurf",
|
|
653
|
-
friendlyName: "Windsurf",
|
|
654
|
-
paths: osSpecificPaths["windsurf"]
|
|
655
|
-
},
|
|
656
|
-
roo: {
|
|
657
|
-
name: "roo",
|
|
658
|
-
friendlyName: "Roo",
|
|
659
|
-
paths: osSpecificPaths["roo"]
|
|
660
|
-
},
|
|
661
|
-
"intellij-github-copilot": {
|
|
662
|
-
name: "intellij-github-copilot",
|
|
663
|
-
friendlyName: "IntelliJ GitHub Copilot",
|
|
664
|
-
paths: osSpecificPaths["intellij-github-copilot"]
|
|
665
|
-
},
|
|
666
|
-
junie: {
|
|
667
|
-
name: "junie",
|
|
668
|
-
friendlyName: "IntelliJ Junie",
|
|
669
|
-
paths: osSpecificPaths["junie"]
|
|
670
|
-
},
|
|
671
|
-
zed: {
|
|
672
|
-
name: "zed",
|
|
673
|
-
friendlyName: "Zed",
|
|
674
|
-
paths: osSpecificPaths["zed"]
|
|
675
|
-
},
|
|
676
|
-
gemini: {
|
|
677
|
-
name: "gemini-cli",
|
|
678
|
-
friendlyName: "Gemini CLI",
|
|
679
|
-
paths: osSpecificPaths.gemini
|
|
680
|
-
}
|
|
681
|
-
};
|
|
682
|
-
constructor(mcpFilePathGroups) {
|
|
683
|
-
this.mcpFilePathGroups = mcpFilePathGroups || this.mcpFilePathGroups;
|
|
1251
|
+
mcpConfigService;
|
|
1252
|
+
constructor() {
|
|
1253
|
+
this.mcpConfigService = new MCPConfigService({ enableDirectoryBubbling: true });
|
|
684
1254
|
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Find and process all MCP configuration files
|
|
1257
|
+
*/
|
|
685
1258
|
async findFiles() {
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
const mcpServersFromConfig = await MCPConfigLinter.getMCPServers();
|
|
710
|
-
for (const serverName of Object.keys(mcpServersFromConfig)) {
|
|
711
|
-
const serverConfigRaw = mcpServersFromConfig[serverName];
|
|
712
|
-
const serverConfig = {
|
|
713
|
-
name: serverName,
|
|
714
|
-
command: serverConfigRaw.command || "",
|
|
715
|
-
args: serverConfigRaw.args,
|
|
716
|
-
url: serverConfigRaw.url,
|
|
717
|
-
transport: serverConfigRaw.transport,
|
|
718
|
-
type: serverConfigRaw.type,
|
|
719
|
-
env: serverConfigRaw.env
|
|
720
|
-
};
|
|
721
|
-
const MCPServerManager = new MCPServerManagerService(serverConfig);
|
|
722
|
-
const mcpServerProcessDetection = MCPServerManager.isRunning();
|
|
723
|
-
let mcpServerProcess = false;
|
|
724
|
-
if (mcpServerProcessDetection) {
|
|
725
|
-
if (typeof mcpServerProcessDetection === "object" && mcpServerProcessDetection.estimatedProduct === clientsGroup.name) {
|
|
726
|
-
mcpServerProcess = true;
|
|
1259
|
+
try {
|
|
1260
|
+
const mcpFilesPathsData = await this.mcpConfigService.getMCPFileGroups();
|
|
1261
|
+
for (const groupName of Object.keys(mcpFilesPathsData)) {
|
|
1262
|
+
const group = mcpFilesPathsData[groupName];
|
|
1263
|
+
for (const filePathData of group.paths) {
|
|
1264
|
+
if (filePathData.servers && filePathData.servers.length > 0) {
|
|
1265
|
+
for (const server of filePathData.servers) {
|
|
1266
|
+
const serverConfig = {
|
|
1267
|
+
name: server.name,
|
|
1268
|
+
command: server.command,
|
|
1269
|
+
args: server.args,
|
|
1270
|
+
transport: server.transport,
|
|
1271
|
+
// transport is always populated from type in the data layer
|
|
1272
|
+
type: server.type,
|
|
1273
|
+
env: server.env
|
|
1274
|
+
};
|
|
1275
|
+
const serverManager = new MCPServerManagerService(serverConfig);
|
|
1276
|
+
const processDetection = serverManager.isRunning();
|
|
1277
|
+
let isRunning = false;
|
|
1278
|
+
if (processDetection) {
|
|
1279
|
+
if (typeof processDetection === "object" && processDetection.estimatedProduct === group.name) {
|
|
1280
|
+
isRunning = true;
|
|
1281
|
+
}
|
|
727
1282
|
}
|
|
1283
|
+
server.status = isRunning ? "running" : "stopped";
|
|
728
1284
|
}
|
|
729
|
-
mcpServersData.push({
|
|
730
|
-
name: MCPServerManager.getName(),
|
|
731
|
-
command: MCPServerManager.getCmd(),
|
|
732
|
-
args: MCPServerManager.getArgs(),
|
|
733
|
-
source: MCPServerManager.getSource(),
|
|
734
|
-
transport: MCPServerManager.getTransport(),
|
|
735
|
-
env: MCPServerManager.getEnv(),
|
|
736
|
-
status: mcpServerProcess ? "running" : "stopped"
|
|
737
|
-
});
|
|
738
1285
|
}
|
|
739
|
-
filePathData.servers = mcpServersData;
|
|
740
|
-
mcpFilesPathsData[groupName]["stats"]["serversCount"] = await MCPConfigLinter.countMCPServers();
|
|
741
|
-
mcpFilesPathsData[groupName].paths.push(filePathData);
|
|
742
|
-
} catch (error) {
|
|
743
1286
|
}
|
|
744
1287
|
}
|
|
1288
|
+
return mcpFilesPathsData;
|
|
1289
|
+
} catch (error) {
|
|
1290
|
+
throw new Error(`Failed to find MCP files: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
745
1291
|
}
|
|
746
|
-
|
|
1292
|
+
}
|
|
1293
|
+
/**
|
|
1294
|
+
* Get MCP configuration service instance for advanced operations
|
|
1295
|
+
*/
|
|
1296
|
+
getMCPConfigService() {
|
|
1297
|
+
return this.mcpConfigService;
|
|
747
1298
|
}
|
|
748
1299
|
};
|
|
749
1300
|
// Annotate the CommonJS export names for ESM import in node:
|