ls-mcp 1.3.1 → 1.5.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/dist/bin/cli.cjs +151 -35
- package/dist/bin/cli.mjs +151 -35
- package/dist/main.cjs +135 -29
- package/dist/main.mjs +135 -29
- package/package.json +1 -1
- package/src/bin/cli.ts +16 -8
- package/src/main.ts +91 -7
- package/src/services/mcp-config-linter-service.ts +18 -2
- package/src/services/mcp-server-manager-service.ts +57 -20
- package/src/services/render-service.ts +0 -3
package/dist/bin/cli.cjs
CHANGED
|
@@ -24,8 +24,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
mod
|
|
25
25
|
));
|
|
26
26
|
|
|
27
|
+
// src/bin/cli.ts
|
|
28
|
+
var import_node_util8 = require("util");
|
|
29
|
+
|
|
27
30
|
// src/main.ts
|
|
28
31
|
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
32
|
+
var import_node_os2 = require("os");
|
|
33
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
29
34
|
|
|
30
35
|
// src/services/mcp-config-linter-service.ts
|
|
31
36
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
@@ -54,8 +59,16 @@ var MCPConfigLinterService = class {
|
|
|
54
59
|
async getMCPServers() {
|
|
55
60
|
const fileContentRaw = await this.getFileContent();
|
|
56
61
|
const fileContentsData = JSON.parse(fileContentRaw);
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
if (fileContentsData?.servers) {
|
|
63
|
+
return fileContentsData.servers;
|
|
64
|
+
}
|
|
65
|
+
if (fileContentsData?.mcp?.servers) {
|
|
66
|
+
return fileContentsData.mcp.servers;
|
|
67
|
+
}
|
|
68
|
+
if (fileContentsData?.mcpServers) {
|
|
69
|
+
return fileContentsData.mcpServers;
|
|
70
|
+
}
|
|
71
|
+
return {};
|
|
59
72
|
}
|
|
60
73
|
async getFileContent() {
|
|
61
74
|
if (this.fileContents) {
|
|
@@ -67,6 +80,7 @@ var MCPConfigLinterService = class {
|
|
|
67
80
|
};
|
|
68
81
|
|
|
69
82
|
// src/services/mcp-server-manager-service.ts
|
|
83
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
70
84
|
var import_node_child_process = require("child_process");
|
|
71
85
|
var import_node_os = require("os");
|
|
72
86
|
var MCPServerManagerService = class {
|
|
@@ -126,15 +140,15 @@ var MCPServerManagerService = class {
|
|
|
126
140
|
if (processLine.startsWith('"ProcessId"') || processLine.startsWith("ProcessId")) continue;
|
|
127
141
|
const parts = this.parseCSVLine(processLine);
|
|
128
142
|
if (parts.length < 4) continue;
|
|
129
|
-
pid = parts[0] || "";
|
|
130
|
-
commandLine = parts[2] || "";
|
|
131
|
-
ppid = parts[3] || "";
|
|
143
|
+
pid = parts[0].trim() || "";
|
|
144
|
+
commandLine = parts[2].trim() || "";
|
|
145
|
+
ppid = parts[3].trim() || "";
|
|
132
146
|
} else {
|
|
133
147
|
const match = processLine.trim().match(/^\s*(\d+)\s+(\d+)\s+(.+)$/);
|
|
134
148
|
if (!match) continue;
|
|
135
|
-
pid = match[1];
|
|
136
|
-
ppid = match[2];
|
|
137
|
-
commandLine = match[3];
|
|
149
|
+
pid = match[1].trim() || "";
|
|
150
|
+
ppid = match[2].trim() || "";
|
|
151
|
+
commandLine = match[3].trim() || "";
|
|
138
152
|
}
|
|
139
153
|
const commandTokens = this.parseCommandLine(commandLine);
|
|
140
154
|
if (commandTokens.length > 0) {
|
|
@@ -143,7 +157,20 @@ var MCPServerManagerService = class {
|
|
|
143
157
|
}
|
|
144
158
|
let mcpServerDetection;
|
|
145
159
|
for (const [pid, processData] of processMap) {
|
|
146
|
-
|
|
160
|
+
const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid);
|
|
161
|
+
let commandMatchWin32 = false;
|
|
162
|
+
if ((0, import_node_os.platform)() === "win32") {
|
|
163
|
+
let commandTokensOnWin32 = processData.commandTokens;
|
|
164
|
+
if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith("cmd")) {
|
|
165
|
+
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
166
|
+
while (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].startsWith("/")) {
|
|
167
|
+
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
commandMatchWin32 = this.isCommandMatch(commandTokensOnWin32, pid, processData.ppid);
|
|
171
|
+
}
|
|
172
|
+
const commandMatch = commandMatchLinux || commandMatchWin32;
|
|
173
|
+
if (commandMatch) {
|
|
147
174
|
mcpServerDetection = {
|
|
148
175
|
pid,
|
|
149
176
|
commandLine: processData.commandTokens.join(" "),
|
|
@@ -190,13 +217,14 @@ var MCPServerManagerService = class {
|
|
|
190
217
|
isCommandMatch(commandTokens, pid, ppid) {
|
|
191
218
|
if (commandTokens.length === 0) return false;
|
|
192
219
|
const baseCommand = this.getBaseCommand(commandTokens[0]);
|
|
193
|
-
|
|
220
|
+
const commandInConfig = this.getBaseCommand(this.command);
|
|
221
|
+
if (commandInConfig === "uvx" && baseCommand === "uv") {
|
|
194
222
|
return this.matchUvxProcess(commandTokens);
|
|
195
223
|
}
|
|
196
|
-
if (
|
|
224
|
+
if (commandInConfig === "npx" && baseCommand === "npm") {
|
|
197
225
|
return this.matchNpxProcess(commandTokens);
|
|
198
226
|
}
|
|
199
|
-
if (
|
|
227
|
+
if (commandInConfig === "uv" && baseCommand === "uv") {
|
|
200
228
|
return this.matchGenericArgsToArgs(commandTokens);
|
|
201
229
|
}
|
|
202
230
|
const commandConfigPythonBase = this.getBaseCommand(this.command);
|
|
@@ -221,19 +249,21 @@ var MCPServerManagerService = class {
|
|
|
221
249
|
const commandWithoutArgs = commandTokens.slice(1);
|
|
222
250
|
for (let i = 0; i < this.args.length; i++) {
|
|
223
251
|
if (i >= commandWithoutArgs.length) return false;
|
|
224
|
-
const arg = this.args[i];
|
|
225
|
-
const token = commandWithoutArgs[i];
|
|
252
|
+
const arg = this.args[i].toLowerCase();
|
|
253
|
+
const token = commandWithoutArgs[i].toLowerCase();
|
|
226
254
|
if (arg !== token && !token.includes(arg)) {
|
|
227
255
|
return false;
|
|
228
256
|
}
|
|
229
257
|
}
|
|
230
258
|
return true;
|
|
231
259
|
}
|
|
232
|
-
// @TODO refactor this to use path.basename or similar
|
|
233
|
-
// to extract the base command from the full command path
|
|
234
260
|
getBaseCommand(fullCommandPath) {
|
|
235
|
-
|
|
236
|
-
|
|
261
|
+
let baseCommand = import_node_path.default.basename(fullCommandPath);
|
|
262
|
+
if ((0, import_node_os.platform)() === "win32") {
|
|
263
|
+
baseCommand = import_node_path.default.basename(fullCommandPath, ".exe");
|
|
264
|
+
}
|
|
265
|
+
baseCommand = baseCommand.toLowerCase();
|
|
266
|
+
return baseCommand;
|
|
237
267
|
}
|
|
238
268
|
/*
|
|
239
269
|
example1:
|
|
@@ -312,8 +342,9 @@ var MCPServerManagerService = class {
|
|
|
312
342
|
}
|
|
313
343
|
findMcpServerNameInProcessArguments(commandTokens, mcpServerName) {
|
|
314
344
|
for (let i = 0; i < commandTokens.length; i++) {
|
|
315
|
-
const token = commandTokens[i];
|
|
316
|
-
|
|
345
|
+
const token = commandTokens[i].toLowerCase();
|
|
346
|
+
const normalizedMcpServerName = mcpServerName.toLowerCase();
|
|
347
|
+
if (normalizedMcpServerName === token || token.includes(normalizedMcpServerName)) {
|
|
317
348
|
return true;
|
|
318
349
|
}
|
|
319
350
|
}
|
|
@@ -400,8 +431,8 @@ var MCPServerManagerService = class {
|
|
|
400
431
|
return false;
|
|
401
432
|
}
|
|
402
433
|
for (let i = 0; i < argsToMatch.length; i++) {
|
|
403
|
-
const commandToken = commandTokens[i + 2];
|
|
404
|
-
const expectedArg = argsToMatch[i];
|
|
434
|
+
const commandToken = commandTokens[i + 2].toLowerCase();
|
|
435
|
+
const expectedArg = argsToMatch[i].toLowerCase();
|
|
405
436
|
if (commandToken !== expectedArg) {
|
|
406
437
|
return false;
|
|
407
438
|
}
|
|
@@ -411,6 +442,63 @@ var MCPServerManagerService = class {
|
|
|
411
442
|
};
|
|
412
443
|
|
|
413
444
|
// src/main.ts
|
|
445
|
+
var osSpecificPaths = {
|
|
446
|
+
claude: [],
|
|
447
|
+
cursor: [],
|
|
448
|
+
vscode: [],
|
|
449
|
+
cline: [],
|
|
450
|
+
windsurf: [],
|
|
451
|
+
roo: []
|
|
452
|
+
};
|
|
453
|
+
if ((0, import_node_os2.platform)() === "win32") {
|
|
454
|
+
osSpecificPaths["claude"] = [
|
|
455
|
+
{ filePath: `${process.env.APPDATA}\\Claude\\claude_desktop_config.json`, type: "global" }
|
|
456
|
+
];
|
|
457
|
+
osSpecificPaths["cursor"] = [
|
|
458
|
+
{ filePath: `${process.env.HOME}\\.cursor\\mcp.json`, type: "global" },
|
|
459
|
+
{ filePath: ".cursor\\mcp.json", type: "local" }
|
|
460
|
+
];
|
|
461
|
+
osSpecificPaths["vscode"] = [
|
|
462
|
+
{ filePath: ".vscode\\mcp.json", type: "local" },
|
|
463
|
+
{ filePath: `${process.env.APPDATA}\\Code\\User\\settings.json`, type: "global" },
|
|
464
|
+
{ filePath: `${process.env.APPDATA}\\Code - Insiders\\User\\settings.json`, type: "global" }
|
|
465
|
+
];
|
|
466
|
+
osSpecificPaths["cline"] = [
|
|
467
|
+
{ filePath: `${process.env.APPDATA}\\Code\\User\\globalStorage\\saoudrizwan.claude-dev\\settings\\cline_mcp_settings.json`, type: "global" },
|
|
468
|
+
{ filePath: `${process.env.APPDATA}\\Code - Insiders\\User\\globalStorage\\saoudrizwan.claude-dev\\settings\\cline_mcp_settings.json`, type: "global" }
|
|
469
|
+
];
|
|
470
|
+
osSpecificPaths["windsurf"] = [
|
|
471
|
+
{ filePath: ".codeium\\windsurf\\mcp_config.json", type: "local" }
|
|
472
|
+
];
|
|
473
|
+
osSpecificPaths["roo"] = [
|
|
474
|
+
{ filePath: `${process.env.APPDATA}\\Code\\User\\globalStorage\\rooveterinaryinc.roo-cline\\settings\\cline_mcp_settings.json`, type: "global" },
|
|
475
|
+
{ filePath: `${process.env.APPDATA}\\Code - Insiders\\User\\globalStorage\\rooveterinaryinc.roo-cline\\settings\\cline_mcp_settings.json`, type: "global" }
|
|
476
|
+
];
|
|
477
|
+
} else {
|
|
478
|
+
osSpecificPaths["claude"] = [
|
|
479
|
+
{ filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
|
|
480
|
+
];
|
|
481
|
+
osSpecificPaths["cursor"] = [
|
|
482
|
+
{ filePath: "~/.cursor/mcp.json", type: "global" },
|
|
483
|
+
{ filePath: ".cursor/mcp.json", type: "local" }
|
|
484
|
+
];
|
|
485
|
+
osSpecificPaths["vscode"] = [
|
|
486
|
+
{ filePath: ".vscode/mcp.json", type: "local" },
|
|
487
|
+
{ filePath: "~/Library/Application Support/Code/User/settings.json", type: "global" },
|
|
488
|
+
{ filePath: "~/Library/Application Support/Code - Insiders/User/settings.json", type: "global" }
|
|
489
|
+
];
|
|
490
|
+
osSpecificPaths["cline"] = [
|
|
491
|
+
{ filePath: "~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json", type: "global" },
|
|
492
|
+
{ filePath: "~/Library/Application Support/Code - Insiders/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json", type: "global" }
|
|
493
|
+
];
|
|
494
|
+
osSpecificPaths["windsurf"] = [
|
|
495
|
+
{ filePath: ".codeium/windsurf/mcp_config.json", type: "local" }
|
|
496
|
+
];
|
|
497
|
+
osSpecificPaths["roo"] = [
|
|
498
|
+
{ filePath: "~/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json", type: "global" },
|
|
499
|
+
{ filePath: "~/Library/Application Support/Code - Insiders/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json", type: "global" }
|
|
500
|
+
];
|
|
501
|
+
}
|
|
414
502
|
var MCPFiles = class {
|
|
415
503
|
static {
|
|
416
504
|
__name(this, "MCPFiles");
|
|
@@ -419,17 +507,32 @@ var MCPFiles = class {
|
|
|
419
507
|
claude: {
|
|
420
508
|
name: "claude-desktop",
|
|
421
509
|
friendlyName: "Claude Desktop",
|
|
422
|
-
paths: [
|
|
423
|
-
{ filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
|
|
424
|
-
]
|
|
510
|
+
paths: osSpecificPaths["claude"]
|
|
425
511
|
},
|
|
426
512
|
cursor: {
|
|
427
513
|
name: "cursor",
|
|
428
514
|
friendlyName: "Cursor",
|
|
429
|
-
paths: [
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
515
|
+
paths: osSpecificPaths["cursor"]
|
|
516
|
+
},
|
|
517
|
+
vscode: {
|
|
518
|
+
name: "vscode",
|
|
519
|
+
friendlyName: "VS Code",
|
|
520
|
+
paths: osSpecificPaths["vscode"]
|
|
521
|
+
},
|
|
522
|
+
cline: {
|
|
523
|
+
name: "cline",
|
|
524
|
+
friendlyName: "Cline",
|
|
525
|
+
paths: osSpecificPaths["cline"]
|
|
526
|
+
},
|
|
527
|
+
windsurf: {
|
|
528
|
+
name: "windsurf",
|
|
529
|
+
friendlyName: "Windsurf",
|
|
530
|
+
paths: osSpecificPaths["windsurf"]
|
|
531
|
+
},
|
|
532
|
+
roo: {
|
|
533
|
+
name: "roo",
|
|
534
|
+
friendlyName: "Roo",
|
|
535
|
+
paths: osSpecificPaths["roo"]
|
|
433
536
|
}
|
|
434
537
|
};
|
|
435
538
|
constructor(mcpFilePathGroups) {
|
|
@@ -445,8 +548,14 @@ var MCPFiles = class {
|
|
|
445
548
|
paths: [],
|
|
446
549
|
stats: {}
|
|
447
550
|
};
|
|
551
|
+
const uniqueFilePaths = /* @__PURE__ */ new Set();
|
|
448
552
|
for (const filePathData of clientsGroup.paths) {
|
|
449
553
|
const resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
554
|
+
const absolutePath = import_node_path2.default.resolve(resolvedPath);
|
|
555
|
+
if (uniqueFilePaths.has(absolutePath)) {
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
uniqueFilePaths.add(absolutePath);
|
|
450
559
|
try {
|
|
451
560
|
await import_promises2.default.access(resolvedPath);
|
|
452
561
|
const MCPConfigLinter = new MCPConfigLinterService(resolvedPath);
|
|
@@ -717,18 +826,18 @@ var RenderService = class {
|
|
|
717
826
|
};
|
|
718
827
|
|
|
719
828
|
// src/bin/cli.ts
|
|
720
|
-
console.log();
|
|
721
829
|
async function init() {
|
|
830
|
+
console.log();
|
|
831
|
+
console.log("[+] Detecting MCP Server configurations...");
|
|
722
832
|
const mcpFilesManager = new MCPFiles();
|
|
723
833
|
const mcpFilesList = await mcpFilesManager.findFiles();
|
|
724
834
|
if (Object.keys(mcpFilesList).length === 0) {
|
|
725
|
-
|
|
726
|
-
return;
|
|
835
|
+
exitWithError("No configuration for MCP Server applications found.");
|
|
727
836
|
}
|
|
728
837
|
let pathIndex = 0;
|
|
729
838
|
for (const groupName of Object.keys(mcpFilesList)) {
|
|
730
839
|
const group = mcpFilesList[groupName];
|
|
731
|
-
if (group.paths.length
|
|
840
|
+
if (group.paths.length > 0) {
|
|
732
841
|
for (const filePathData of group.paths) {
|
|
733
842
|
pathIndex++;
|
|
734
843
|
const filePath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
@@ -750,12 +859,19 @@ async function init() {
|
|
|
750
859
|
RenderService.printMcpGroup(pathIndex, mcpGroupData, groupMetadata);
|
|
751
860
|
RenderService.printMcpServers(mcpServers);
|
|
752
861
|
}
|
|
753
|
-
} else {
|
|
754
|
-
console.log("No files found in this group.");
|
|
755
862
|
}
|
|
756
863
|
}
|
|
864
|
+
if (pathIndex === 0) {
|
|
865
|
+
exitWithError("No MCP servers found in known configuration files.");
|
|
866
|
+
}
|
|
757
867
|
}
|
|
758
868
|
__name(init, "init");
|
|
759
869
|
init().then(() => {
|
|
760
870
|
console.log("\n");
|
|
761
871
|
});
|
|
872
|
+
function exitWithError(message) {
|
|
873
|
+
console.error(`${(0, import_node_util8.styleText)(["red"], "\u25CF")} ${message}
|
|
874
|
+
`);
|
|
875
|
+
process.exit(1);
|
|
876
|
+
}
|
|
877
|
+
__name(exitWithError, "exitWithError");
|
package/dist/bin/cli.mjs
CHANGED
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
4
|
|
|
5
|
+
// src/bin/cli.ts
|
|
6
|
+
import { styleText as styleText8 } from "util";
|
|
7
|
+
|
|
5
8
|
// src/main.ts
|
|
6
9
|
import fs2 from "fs/promises";
|
|
10
|
+
import { platform as platform2 } from "os";
|
|
11
|
+
import path2 from "path";
|
|
7
12
|
|
|
8
13
|
// src/services/mcp-config-linter-service.ts
|
|
9
14
|
import fs from "fs/promises";
|
|
@@ -32,8 +37,16 @@ var MCPConfigLinterService = class {
|
|
|
32
37
|
async getMCPServers() {
|
|
33
38
|
const fileContentRaw = await this.getFileContent();
|
|
34
39
|
const fileContentsData = JSON.parse(fileContentRaw);
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
if (fileContentsData?.servers) {
|
|
41
|
+
return fileContentsData.servers;
|
|
42
|
+
}
|
|
43
|
+
if (fileContentsData?.mcp?.servers) {
|
|
44
|
+
return fileContentsData.mcp.servers;
|
|
45
|
+
}
|
|
46
|
+
if (fileContentsData?.mcpServers) {
|
|
47
|
+
return fileContentsData.mcpServers;
|
|
48
|
+
}
|
|
49
|
+
return {};
|
|
37
50
|
}
|
|
38
51
|
async getFileContent() {
|
|
39
52
|
if (this.fileContents) {
|
|
@@ -45,6 +58,7 @@ var MCPConfigLinterService = class {
|
|
|
45
58
|
};
|
|
46
59
|
|
|
47
60
|
// src/services/mcp-server-manager-service.ts
|
|
61
|
+
import path from "path";
|
|
48
62
|
import { execSync } from "child_process";
|
|
49
63
|
import { platform } from "os";
|
|
50
64
|
var MCPServerManagerService = class {
|
|
@@ -104,15 +118,15 @@ var MCPServerManagerService = class {
|
|
|
104
118
|
if (processLine.startsWith('"ProcessId"') || processLine.startsWith("ProcessId")) continue;
|
|
105
119
|
const parts = this.parseCSVLine(processLine);
|
|
106
120
|
if (parts.length < 4) continue;
|
|
107
|
-
pid = parts[0] || "";
|
|
108
|
-
commandLine = parts[2] || "";
|
|
109
|
-
ppid = parts[3] || "";
|
|
121
|
+
pid = parts[0].trim() || "";
|
|
122
|
+
commandLine = parts[2].trim() || "";
|
|
123
|
+
ppid = parts[3].trim() || "";
|
|
110
124
|
} else {
|
|
111
125
|
const match = processLine.trim().match(/^\s*(\d+)\s+(\d+)\s+(.+)$/);
|
|
112
126
|
if (!match) continue;
|
|
113
|
-
pid = match[1];
|
|
114
|
-
ppid = match[2];
|
|
115
|
-
commandLine = match[3];
|
|
127
|
+
pid = match[1].trim() || "";
|
|
128
|
+
ppid = match[2].trim() || "";
|
|
129
|
+
commandLine = match[3].trim() || "";
|
|
116
130
|
}
|
|
117
131
|
const commandTokens = this.parseCommandLine(commandLine);
|
|
118
132
|
if (commandTokens.length > 0) {
|
|
@@ -121,7 +135,20 @@ var MCPServerManagerService = class {
|
|
|
121
135
|
}
|
|
122
136
|
let mcpServerDetection;
|
|
123
137
|
for (const [pid, processData] of processMap) {
|
|
124
|
-
|
|
138
|
+
const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid);
|
|
139
|
+
let commandMatchWin32 = false;
|
|
140
|
+
if (platform() === "win32") {
|
|
141
|
+
let commandTokensOnWin32 = processData.commandTokens;
|
|
142
|
+
if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith("cmd")) {
|
|
143
|
+
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
144
|
+
while (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].startsWith("/")) {
|
|
145
|
+
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
commandMatchWin32 = this.isCommandMatch(commandTokensOnWin32, pid, processData.ppid);
|
|
149
|
+
}
|
|
150
|
+
const commandMatch = commandMatchLinux || commandMatchWin32;
|
|
151
|
+
if (commandMatch) {
|
|
125
152
|
mcpServerDetection = {
|
|
126
153
|
pid,
|
|
127
154
|
commandLine: processData.commandTokens.join(" "),
|
|
@@ -168,13 +195,14 @@ var MCPServerManagerService = class {
|
|
|
168
195
|
isCommandMatch(commandTokens, pid, ppid) {
|
|
169
196
|
if (commandTokens.length === 0) return false;
|
|
170
197
|
const baseCommand = this.getBaseCommand(commandTokens[0]);
|
|
171
|
-
|
|
198
|
+
const commandInConfig = this.getBaseCommand(this.command);
|
|
199
|
+
if (commandInConfig === "uvx" && baseCommand === "uv") {
|
|
172
200
|
return this.matchUvxProcess(commandTokens);
|
|
173
201
|
}
|
|
174
|
-
if (
|
|
202
|
+
if (commandInConfig === "npx" && baseCommand === "npm") {
|
|
175
203
|
return this.matchNpxProcess(commandTokens);
|
|
176
204
|
}
|
|
177
|
-
if (
|
|
205
|
+
if (commandInConfig === "uv" && baseCommand === "uv") {
|
|
178
206
|
return this.matchGenericArgsToArgs(commandTokens);
|
|
179
207
|
}
|
|
180
208
|
const commandConfigPythonBase = this.getBaseCommand(this.command);
|
|
@@ -199,19 +227,21 @@ var MCPServerManagerService = class {
|
|
|
199
227
|
const commandWithoutArgs = commandTokens.slice(1);
|
|
200
228
|
for (let i = 0; i < this.args.length; i++) {
|
|
201
229
|
if (i >= commandWithoutArgs.length) return false;
|
|
202
|
-
const arg = this.args[i];
|
|
203
|
-
const token = commandWithoutArgs[i];
|
|
230
|
+
const arg = this.args[i].toLowerCase();
|
|
231
|
+
const token = commandWithoutArgs[i].toLowerCase();
|
|
204
232
|
if (arg !== token && !token.includes(arg)) {
|
|
205
233
|
return false;
|
|
206
234
|
}
|
|
207
235
|
}
|
|
208
236
|
return true;
|
|
209
237
|
}
|
|
210
|
-
// @TODO refactor this to use path.basename or similar
|
|
211
|
-
// to extract the base command from the full command path
|
|
212
238
|
getBaseCommand(fullCommandPath) {
|
|
213
|
-
|
|
214
|
-
|
|
239
|
+
let baseCommand = path.basename(fullCommandPath);
|
|
240
|
+
if (platform() === "win32") {
|
|
241
|
+
baseCommand = path.basename(fullCommandPath, ".exe");
|
|
242
|
+
}
|
|
243
|
+
baseCommand = baseCommand.toLowerCase();
|
|
244
|
+
return baseCommand;
|
|
215
245
|
}
|
|
216
246
|
/*
|
|
217
247
|
example1:
|
|
@@ -290,8 +320,9 @@ var MCPServerManagerService = class {
|
|
|
290
320
|
}
|
|
291
321
|
findMcpServerNameInProcessArguments(commandTokens, mcpServerName) {
|
|
292
322
|
for (let i = 0; i < commandTokens.length; i++) {
|
|
293
|
-
const token = commandTokens[i];
|
|
294
|
-
|
|
323
|
+
const token = commandTokens[i].toLowerCase();
|
|
324
|
+
const normalizedMcpServerName = mcpServerName.toLowerCase();
|
|
325
|
+
if (normalizedMcpServerName === token || token.includes(normalizedMcpServerName)) {
|
|
295
326
|
return true;
|
|
296
327
|
}
|
|
297
328
|
}
|
|
@@ -378,8 +409,8 @@ var MCPServerManagerService = class {
|
|
|
378
409
|
return false;
|
|
379
410
|
}
|
|
380
411
|
for (let i = 0; i < argsToMatch.length; i++) {
|
|
381
|
-
const commandToken = commandTokens[i + 2];
|
|
382
|
-
const expectedArg = argsToMatch[i];
|
|
412
|
+
const commandToken = commandTokens[i + 2].toLowerCase();
|
|
413
|
+
const expectedArg = argsToMatch[i].toLowerCase();
|
|
383
414
|
if (commandToken !== expectedArg) {
|
|
384
415
|
return false;
|
|
385
416
|
}
|
|
@@ -389,6 +420,63 @@ var MCPServerManagerService = class {
|
|
|
389
420
|
};
|
|
390
421
|
|
|
391
422
|
// src/main.ts
|
|
423
|
+
var osSpecificPaths = {
|
|
424
|
+
claude: [],
|
|
425
|
+
cursor: [],
|
|
426
|
+
vscode: [],
|
|
427
|
+
cline: [],
|
|
428
|
+
windsurf: [],
|
|
429
|
+
roo: []
|
|
430
|
+
};
|
|
431
|
+
if (platform2() === "win32") {
|
|
432
|
+
osSpecificPaths["claude"] = [
|
|
433
|
+
{ filePath: `${process.env.APPDATA}\\Claude\\claude_desktop_config.json`, type: "global" }
|
|
434
|
+
];
|
|
435
|
+
osSpecificPaths["cursor"] = [
|
|
436
|
+
{ filePath: `${process.env.HOME}\\.cursor\\mcp.json`, type: "global" },
|
|
437
|
+
{ filePath: ".cursor\\mcp.json", type: "local" }
|
|
438
|
+
];
|
|
439
|
+
osSpecificPaths["vscode"] = [
|
|
440
|
+
{ filePath: ".vscode\\mcp.json", type: "local" },
|
|
441
|
+
{ filePath: `${process.env.APPDATA}\\Code\\User\\settings.json`, type: "global" },
|
|
442
|
+
{ filePath: `${process.env.APPDATA}\\Code - Insiders\\User\\settings.json`, type: "global" }
|
|
443
|
+
];
|
|
444
|
+
osSpecificPaths["cline"] = [
|
|
445
|
+
{ filePath: `${process.env.APPDATA}\\Code\\User\\globalStorage\\saoudrizwan.claude-dev\\settings\\cline_mcp_settings.json`, type: "global" },
|
|
446
|
+
{ filePath: `${process.env.APPDATA}\\Code - Insiders\\User\\globalStorage\\saoudrizwan.claude-dev\\settings\\cline_mcp_settings.json`, type: "global" }
|
|
447
|
+
];
|
|
448
|
+
osSpecificPaths["windsurf"] = [
|
|
449
|
+
{ filePath: ".codeium\\windsurf\\mcp_config.json", type: "local" }
|
|
450
|
+
];
|
|
451
|
+
osSpecificPaths["roo"] = [
|
|
452
|
+
{ filePath: `${process.env.APPDATA}\\Code\\User\\globalStorage\\rooveterinaryinc.roo-cline\\settings\\cline_mcp_settings.json`, type: "global" },
|
|
453
|
+
{ filePath: `${process.env.APPDATA}\\Code - Insiders\\User\\globalStorage\\rooveterinaryinc.roo-cline\\settings\\cline_mcp_settings.json`, type: "global" }
|
|
454
|
+
];
|
|
455
|
+
} else {
|
|
456
|
+
osSpecificPaths["claude"] = [
|
|
457
|
+
{ filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
|
|
458
|
+
];
|
|
459
|
+
osSpecificPaths["cursor"] = [
|
|
460
|
+
{ filePath: "~/.cursor/mcp.json", type: "global" },
|
|
461
|
+
{ filePath: ".cursor/mcp.json", type: "local" }
|
|
462
|
+
];
|
|
463
|
+
osSpecificPaths["vscode"] = [
|
|
464
|
+
{ filePath: ".vscode/mcp.json", type: "local" },
|
|
465
|
+
{ filePath: "~/Library/Application Support/Code/User/settings.json", type: "global" },
|
|
466
|
+
{ filePath: "~/Library/Application Support/Code - Insiders/User/settings.json", type: "global" }
|
|
467
|
+
];
|
|
468
|
+
osSpecificPaths["cline"] = [
|
|
469
|
+
{ filePath: "~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json", type: "global" },
|
|
470
|
+
{ filePath: "~/Library/Application Support/Code - Insiders/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json", type: "global" }
|
|
471
|
+
];
|
|
472
|
+
osSpecificPaths["windsurf"] = [
|
|
473
|
+
{ filePath: ".codeium/windsurf/mcp_config.json", type: "local" }
|
|
474
|
+
];
|
|
475
|
+
osSpecificPaths["roo"] = [
|
|
476
|
+
{ filePath: "~/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json", type: "global" },
|
|
477
|
+
{ filePath: "~/Library/Application Support/Code - Insiders/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json", type: "global" }
|
|
478
|
+
];
|
|
479
|
+
}
|
|
392
480
|
var MCPFiles = class {
|
|
393
481
|
static {
|
|
394
482
|
__name(this, "MCPFiles");
|
|
@@ -397,17 +485,32 @@ var MCPFiles = class {
|
|
|
397
485
|
claude: {
|
|
398
486
|
name: "claude-desktop",
|
|
399
487
|
friendlyName: "Claude Desktop",
|
|
400
|
-
paths: [
|
|
401
|
-
{ filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
|
|
402
|
-
]
|
|
488
|
+
paths: osSpecificPaths["claude"]
|
|
403
489
|
},
|
|
404
490
|
cursor: {
|
|
405
491
|
name: "cursor",
|
|
406
492
|
friendlyName: "Cursor",
|
|
407
|
-
paths: [
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
493
|
+
paths: osSpecificPaths["cursor"]
|
|
494
|
+
},
|
|
495
|
+
vscode: {
|
|
496
|
+
name: "vscode",
|
|
497
|
+
friendlyName: "VS Code",
|
|
498
|
+
paths: osSpecificPaths["vscode"]
|
|
499
|
+
},
|
|
500
|
+
cline: {
|
|
501
|
+
name: "cline",
|
|
502
|
+
friendlyName: "Cline",
|
|
503
|
+
paths: osSpecificPaths["cline"]
|
|
504
|
+
},
|
|
505
|
+
windsurf: {
|
|
506
|
+
name: "windsurf",
|
|
507
|
+
friendlyName: "Windsurf",
|
|
508
|
+
paths: osSpecificPaths["windsurf"]
|
|
509
|
+
},
|
|
510
|
+
roo: {
|
|
511
|
+
name: "roo",
|
|
512
|
+
friendlyName: "Roo",
|
|
513
|
+
paths: osSpecificPaths["roo"]
|
|
411
514
|
}
|
|
412
515
|
};
|
|
413
516
|
constructor(mcpFilePathGroups) {
|
|
@@ -423,8 +526,14 @@ var MCPFiles = class {
|
|
|
423
526
|
paths: [],
|
|
424
527
|
stats: {}
|
|
425
528
|
};
|
|
529
|
+
const uniqueFilePaths = /* @__PURE__ */ new Set();
|
|
426
530
|
for (const filePathData of clientsGroup.paths) {
|
|
427
531
|
const resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
532
|
+
const absolutePath = path2.resolve(resolvedPath);
|
|
533
|
+
if (uniqueFilePaths.has(absolutePath)) {
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
uniqueFilePaths.add(absolutePath);
|
|
428
537
|
try {
|
|
429
538
|
await fs2.access(resolvedPath);
|
|
430
539
|
const MCPConfigLinter = new MCPConfigLinterService(resolvedPath);
|
|
@@ -695,18 +804,18 @@ var RenderService = class {
|
|
|
695
804
|
};
|
|
696
805
|
|
|
697
806
|
// src/bin/cli.ts
|
|
698
|
-
console.log();
|
|
699
807
|
async function init() {
|
|
808
|
+
console.log();
|
|
809
|
+
console.log("[+] Detecting MCP Server configurations...");
|
|
700
810
|
const mcpFilesManager = new MCPFiles();
|
|
701
811
|
const mcpFilesList = await mcpFilesManager.findFiles();
|
|
702
812
|
if (Object.keys(mcpFilesList).length === 0) {
|
|
703
|
-
|
|
704
|
-
return;
|
|
813
|
+
exitWithError("No configuration for MCP Server applications found.");
|
|
705
814
|
}
|
|
706
815
|
let pathIndex = 0;
|
|
707
816
|
for (const groupName of Object.keys(mcpFilesList)) {
|
|
708
817
|
const group = mcpFilesList[groupName];
|
|
709
|
-
if (group.paths.length
|
|
818
|
+
if (group.paths.length > 0) {
|
|
710
819
|
for (const filePathData of group.paths) {
|
|
711
820
|
pathIndex++;
|
|
712
821
|
const filePath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
@@ -728,12 +837,19 @@ async function init() {
|
|
|
728
837
|
RenderService.printMcpGroup(pathIndex, mcpGroupData, groupMetadata);
|
|
729
838
|
RenderService.printMcpServers(mcpServers);
|
|
730
839
|
}
|
|
731
|
-
} else {
|
|
732
|
-
console.log("No files found in this group.");
|
|
733
840
|
}
|
|
734
841
|
}
|
|
842
|
+
if (pathIndex === 0) {
|
|
843
|
+
exitWithError("No MCP servers found in known configuration files.");
|
|
844
|
+
}
|
|
735
845
|
}
|
|
736
846
|
__name(init, "init");
|
|
737
847
|
init().then(() => {
|
|
738
848
|
console.log("\n");
|
|
739
849
|
});
|
|
850
|
+
function exitWithError(message) {
|
|
851
|
+
console.error(`${styleText8(["red"], "\u25CF")} ${message}
|
|
852
|
+
`);
|
|
853
|
+
process.exit(1);
|
|
854
|
+
}
|
|
855
|
+
__name(exitWithError, "exitWithError");
|