ls-mcp 1.3.1 → 1.4.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 +78 -33
- package/dist/bin/cli.mjs +78 -33
- package/dist/main.cjs +62 -27
- package/dist/main.mjs +62 -27
- package/package.json +1 -1
- package/src/bin/cli.ts +16 -8
- package/src/main.ts +26 -7
- 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,12 @@ 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");
|
|
29
33
|
|
|
30
34
|
// src/services/mcp-config-linter-service.ts
|
|
31
35
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
@@ -67,6 +71,7 @@ var MCPConfigLinterService = class {
|
|
|
67
71
|
};
|
|
68
72
|
|
|
69
73
|
// src/services/mcp-server-manager-service.ts
|
|
74
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
70
75
|
var import_node_child_process = require("child_process");
|
|
71
76
|
var import_node_os = require("os");
|
|
72
77
|
var MCPServerManagerService = class {
|
|
@@ -126,15 +131,15 @@ var MCPServerManagerService = class {
|
|
|
126
131
|
if (processLine.startsWith('"ProcessId"') || processLine.startsWith("ProcessId")) continue;
|
|
127
132
|
const parts = this.parseCSVLine(processLine);
|
|
128
133
|
if (parts.length < 4) continue;
|
|
129
|
-
pid = parts[0] || "";
|
|
130
|
-
commandLine = parts[2] || "";
|
|
131
|
-
ppid = parts[3] || "";
|
|
134
|
+
pid = parts[0].trim() || "";
|
|
135
|
+
commandLine = parts[2].trim() || "";
|
|
136
|
+
ppid = parts[3].trim() || "";
|
|
132
137
|
} else {
|
|
133
138
|
const match = processLine.trim().match(/^\s*(\d+)\s+(\d+)\s+(.+)$/);
|
|
134
139
|
if (!match) continue;
|
|
135
|
-
pid = match[1];
|
|
136
|
-
ppid = match[2];
|
|
137
|
-
commandLine = match[3];
|
|
140
|
+
pid = match[1].trim() || "";
|
|
141
|
+
ppid = match[2].trim() || "";
|
|
142
|
+
commandLine = match[3].trim() || "";
|
|
138
143
|
}
|
|
139
144
|
const commandTokens = this.parseCommandLine(commandLine);
|
|
140
145
|
if (commandTokens.length > 0) {
|
|
@@ -143,7 +148,20 @@ var MCPServerManagerService = class {
|
|
|
143
148
|
}
|
|
144
149
|
let mcpServerDetection;
|
|
145
150
|
for (const [pid, processData] of processMap) {
|
|
146
|
-
|
|
151
|
+
const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid);
|
|
152
|
+
let commandMatchWin32 = false;
|
|
153
|
+
if ((0, import_node_os.platform)() === "win32") {
|
|
154
|
+
let commandTokensOnWin32 = processData.commandTokens;
|
|
155
|
+
if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith("cmd")) {
|
|
156
|
+
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
157
|
+
while (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].startsWith("/")) {
|
|
158
|
+
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
commandMatchWin32 = this.isCommandMatch(commandTokensOnWin32, pid, processData.ppid);
|
|
162
|
+
}
|
|
163
|
+
const commandMatch = commandMatchLinux || commandMatchWin32;
|
|
164
|
+
if (commandMatch) {
|
|
147
165
|
mcpServerDetection = {
|
|
148
166
|
pid,
|
|
149
167
|
commandLine: processData.commandTokens.join(" "),
|
|
@@ -190,13 +208,14 @@ var MCPServerManagerService = class {
|
|
|
190
208
|
isCommandMatch(commandTokens, pid, ppid) {
|
|
191
209
|
if (commandTokens.length === 0) return false;
|
|
192
210
|
const baseCommand = this.getBaseCommand(commandTokens[0]);
|
|
193
|
-
|
|
211
|
+
const commandInConfig = this.getBaseCommand(this.command);
|
|
212
|
+
if (commandInConfig === "uvx" && baseCommand === "uv") {
|
|
194
213
|
return this.matchUvxProcess(commandTokens);
|
|
195
214
|
}
|
|
196
|
-
if (
|
|
215
|
+
if (commandInConfig === "npx" && baseCommand === "npm") {
|
|
197
216
|
return this.matchNpxProcess(commandTokens);
|
|
198
217
|
}
|
|
199
|
-
if (
|
|
218
|
+
if (commandInConfig === "uv" && baseCommand === "uv") {
|
|
200
219
|
return this.matchGenericArgsToArgs(commandTokens);
|
|
201
220
|
}
|
|
202
221
|
const commandConfigPythonBase = this.getBaseCommand(this.command);
|
|
@@ -221,19 +240,21 @@ var MCPServerManagerService = class {
|
|
|
221
240
|
const commandWithoutArgs = commandTokens.slice(1);
|
|
222
241
|
for (let i = 0; i < this.args.length; i++) {
|
|
223
242
|
if (i >= commandWithoutArgs.length) return false;
|
|
224
|
-
const arg = this.args[i];
|
|
225
|
-
const token = commandWithoutArgs[i];
|
|
243
|
+
const arg = this.args[i].toLowerCase();
|
|
244
|
+
const token = commandWithoutArgs[i].toLowerCase();
|
|
226
245
|
if (arg !== token && !token.includes(arg)) {
|
|
227
246
|
return false;
|
|
228
247
|
}
|
|
229
248
|
}
|
|
230
249
|
return true;
|
|
231
250
|
}
|
|
232
|
-
// @TODO refactor this to use path.basename or similar
|
|
233
|
-
// to extract the base command from the full command path
|
|
234
251
|
getBaseCommand(fullCommandPath) {
|
|
235
|
-
|
|
236
|
-
|
|
252
|
+
let baseCommand = import_node_path.default.basename(fullCommandPath);
|
|
253
|
+
if ((0, import_node_os.platform)() === "win32") {
|
|
254
|
+
baseCommand = import_node_path.default.basename(fullCommandPath, ".exe");
|
|
255
|
+
}
|
|
256
|
+
baseCommand = baseCommand.toLowerCase();
|
|
257
|
+
return baseCommand;
|
|
237
258
|
}
|
|
238
259
|
/*
|
|
239
260
|
example1:
|
|
@@ -312,8 +333,9 @@ var MCPServerManagerService = class {
|
|
|
312
333
|
}
|
|
313
334
|
findMcpServerNameInProcessArguments(commandTokens, mcpServerName) {
|
|
314
335
|
for (let i = 0; i < commandTokens.length; i++) {
|
|
315
|
-
const token = commandTokens[i];
|
|
316
|
-
|
|
336
|
+
const token = commandTokens[i].toLowerCase();
|
|
337
|
+
const normalizedMcpServerName = mcpServerName.toLowerCase();
|
|
338
|
+
if (normalizedMcpServerName === token || token.includes(normalizedMcpServerName)) {
|
|
317
339
|
return true;
|
|
318
340
|
}
|
|
319
341
|
}
|
|
@@ -400,8 +422,8 @@ var MCPServerManagerService = class {
|
|
|
400
422
|
return false;
|
|
401
423
|
}
|
|
402
424
|
for (let i = 0; i < argsToMatch.length; i++) {
|
|
403
|
-
const commandToken = commandTokens[i + 2];
|
|
404
|
-
const expectedArg = argsToMatch[i];
|
|
425
|
+
const commandToken = commandTokens[i + 2].toLowerCase();
|
|
426
|
+
const expectedArg = argsToMatch[i].toLowerCase();
|
|
405
427
|
if (commandToken !== expectedArg) {
|
|
406
428
|
return false;
|
|
407
429
|
}
|
|
@@ -411,6 +433,27 @@ var MCPServerManagerService = class {
|
|
|
411
433
|
};
|
|
412
434
|
|
|
413
435
|
// src/main.ts
|
|
436
|
+
var osSpecificPaths = {
|
|
437
|
+
claude: [],
|
|
438
|
+
cursor: []
|
|
439
|
+
};
|
|
440
|
+
if ((0, import_node_os2.platform)() === "win32") {
|
|
441
|
+
osSpecificPaths["claude"] = [
|
|
442
|
+
{ filePath: `${process.env.APPDATA}\\Claude\\claude_desktop_config.json`, type: "global" }
|
|
443
|
+
];
|
|
444
|
+
osSpecificPaths["cursor"] = [
|
|
445
|
+
{ filePath: `${process.env.HOME}\\.cursor\\mcp.json`, type: "global" },
|
|
446
|
+
{ filePath: ".cursor\\mcp.json", type: "local" }
|
|
447
|
+
];
|
|
448
|
+
} else {
|
|
449
|
+
osSpecificPaths["claude"] = [
|
|
450
|
+
{ filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
|
|
451
|
+
];
|
|
452
|
+
osSpecificPaths["cursor"] = [
|
|
453
|
+
{ filePath: "~/.cursor/mcp.json", type: "global" },
|
|
454
|
+
{ filePath: ".cursor/mcp.json", type: "local" }
|
|
455
|
+
];
|
|
456
|
+
}
|
|
414
457
|
var MCPFiles = class {
|
|
415
458
|
static {
|
|
416
459
|
__name(this, "MCPFiles");
|
|
@@ -419,17 +462,12 @@ var MCPFiles = class {
|
|
|
419
462
|
claude: {
|
|
420
463
|
name: "claude-desktop",
|
|
421
464
|
friendlyName: "Claude Desktop",
|
|
422
|
-
paths: [
|
|
423
|
-
{ filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
|
|
424
|
-
]
|
|
465
|
+
paths: osSpecificPaths["claude"]
|
|
425
466
|
},
|
|
426
467
|
cursor: {
|
|
427
468
|
name: "cursor",
|
|
428
469
|
friendlyName: "Cursor",
|
|
429
|
-
paths: [
|
|
430
|
-
{ filePath: "~/.cursor/mcp.json", type: "global" },
|
|
431
|
-
{ filePath: ".cursor/mcp.json", type: "local" }
|
|
432
|
-
]
|
|
470
|
+
paths: osSpecificPaths["cursor"]
|
|
433
471
|
}
|
|
434
472
|
};
|
|
435
473
|
constructor(mcpFilePathGroups) {
|
|
@@ -717,18 +755,18 @@ var RenderService = class {
|
|
|
717
755
|
};
|
|
718
756
|
|
|
719
757
|
// src/bin/cli.ts
|
|
720
|
-
console.log();
|
|
721
758
|
async function init() {
|
|
759
|
+
console.log();
|
|
760
|
+
console.log("[+] Detecting MCP Server configurations...");
|
|
722
761
|
const mcpFilesManager = new MCPFiles();
|
|
723
762
|
const mcpFilesList = await mcpFilesManager.findFiles();
|
|
724
763
|
if (Object.keys(mcpFilesList).length === 0) {
|
|
725
|
-
|
|
726
|
-
return;
|
|
764
|
+
exitWithError("No configuration for MCP Server applications found.");
|
|
727
765
|
}
|
|
728
766
|
let pathIndex = 0;
|
|
729
767
|
for (const groupName of Object.keys(mcpFilesList)) {
|
|
730
768
|
const group = mcpFilesList[groupName];
|
|
731
|
-
if (group.paths.length
|
|
769
|
+
if (group.paths.length > 0) {
|
|
732
770
|
for (const filePathData of group.paths) {
|
|
733
771
|
pathIndex++;
|
|
734
772
|
const filePath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
@@ -750,12 +788,19 @@ async function init() {
|
|
|
750
788
|
RenderService.printMcpGroup(pathIndex, mcpGroupData, groupMetadata);
|
|
751
789
|
RenderService.printMcpServers(mcpServers);
|
|
752
790
|
}
|
|
753
|
-
} else {
|
|
754
|
-
console.log("No files found in this group.");
|
|
755
791
|
}
|
|
756
792
|
}
|
|
793
|
+
if (pathIndex === 0) {
|
|
794
|
+
exitWithError("No MCP servers found in known configuration files.");
|
|
795
|
+
}
|
|
757
796
|
}
|
|
758
797
|
__name(init, "init");
|
|
759
798
|
init().then(() => {
|
|
760
799
|
console.log("\n");
|
|
761
800
|
});
|
|
801
|
+
function exitWithError(message) {
|
|
802
|
+
console.error(`${(0, import_node_util8.styleText)(["red"], "\u25CF")} ${message}
|
|
803
|
+
`);
|
|
804
|
+
process.exit(1);
|
|
805
|
+
}
|
|
806
|
+
__name(exitWithError, "exitWithError");
|
package/dist/bin/cli.mjs
CHANGED
|
@@ -2,8 +2,12 @@
|
|
|
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";
|
|
7
11
|
|
|
8
12
|
// src/services/mcp-config-linter-service.ts
|
|
9
13
|
import fs from "fs/promises";
|
|
@@ -45,6 +49,7 @@ var MCPConfigLinterService = class {
|
|
|
45
49
|
};
|
|
46
50
|
|
|
47
51
|
// src/services/mcp-server-manager-service.ts
|
|
52
|
+
import path from "path";
|
|
48
53
|
import { execSync } from "child_process";
|
|
49
54
|
import { platform } from "os";
|
|
50
55
|
var MCPServerManagerService = class {
|
|
@@ -104,15 +109,15 @@ var MCPServerManagerService = class {
|
|
|
104
109
|
if (processLine.startsWith('"ProcessId"') || processLine.startsWith("ProcessId")) continue;
|
|
105
110
|
const parts = this.parseCSVLine(processLine);
|
|
106
111
|
if (parts.length < 4) continue;
|
|
107
|
-
pid = parts[0] || "";
|
|
108
|
-
commandLine = parts[2] || "";
|
|
109
|
-
ppid = parts[3] || "";
|
|
112
|
+
pid = parts[0].trim() || "";
|
|
113
|
+
commandLine = parts[2].trim() || "";
|
|
114
|
+
ppid = parts[3].trim() || "";
|
|
110
115
|
} else {
|
|
111
116
|
const match = processLine.trim().match(/^\s*(\d+)\s+(\d+)\s+(.+)$/);
|
|
112
117
|
if (!match) continue;
|
|
113
|
-
pid = match[1];
|
|
114
|
-
ppid = match[2];
|
|
115
|
-
commandLine = match[3];
|
|
118
|
+
pid = match[1].trim() || "";
|
|
119
|
+
ppid = match[2].trim() || "";
|
|
120
|
+
commandLine = match[3].trim() || "";
|
|
116
121
|
}
|
|
117
122
|
const commandTokens = this.parseCommandLine(commandLine);
|
|
118
123
|
if (commandTokens.length > 0) {
|
|
@@ -121,7 +126,20 @@ var MCPServerManagerService = class {
|
|
|
121
126
|
}
|
|
122
127
|
let mcpServerDetection;
|
|
123
128
|
for (const [pid, processData] of processMap) {
|
|
124
|
-
|
|
129
|
+
const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid);
|
|
130
|
+
let commandMatchWin32 = false;
|
|
131
|
+
if (platform() === "win32") {
|
|
132
|
+
let commandTokensOnWin32 = processData.commandTokens;
|
|
133
|
+
if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith("cmd")) {
|
|
134
|
+
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
135
|
+
while (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].startsWith("/")) {
|
|
136
|
+
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
commandMatchWin32 = this.isCommandMatch(commandTokensOnWin32, pid, processData.ppid);
|
|
140
|
+
}
|
|
141
|
+
const commandMatch = commandMatchLinux || commandMatchWin32;
|
|
142
|
+
if (commandMatch) {
|
|
125
143
|
mcpServerDetection = {
|
|
126
144
|
pid,
|
|
127
145
|
commandLine: processData.commandTokens.join(" "),
|
|
@@ -168,13 +186,14 @@ var MCPServerManagerService = class {
|
|
|
168
186
|
isCommandMatch(commandTokens, pid, ppid) {
|
|
169
187
|
if (commandTokens.length === 0) return false;
|
|
170
188
|
const baseCommand = this.getBaseCommand(commandTokens[0]);
|
|
171
|
-
|
|
189
|
+
const commandInConfig = this.getBaseCommand(this.command);
|
|
190
|
+
if (commandInConfig === "uvx" && baseCommand === "uv") {
|
|
172
191
|
return this.matchUvxProcess(commandTokens);
|
|
173
192
|
}
|
|
174
|
-
if (
|
|
193
|
+
if (commandInConfig === "npx" && baseCommand === "npm") {
|
|
175
194
|
return this.matchNpxProcess(commandTokens);
|
|
176
195
|
}
|
|
177
|
-
if (
|
|
196
|
+
if (commandInConfig === "uv" && baseCommand === "uv") {
|
|
178
197
|
return this.matchGenericArgsToArgs(commandTokens);
|
|
179
198
|
}
|
|
180
199
|
const commandConfigPythonBase = this.getBaseCommand(this.command);
|
|
@@ -199,19 +218,21 @@ var MCPServerManagerService = class {
|
|
|
199
218
|
const commandWithoutArgs = commandTokens.slice(1);
|
|
200
219
|
for (let i = 0; i < this.args.length; i++) {
|
|
201
220
|
if (i >= commandWithoutArgs.length) return false;
|
|
202
|
-
const arg = this.args[i];
|
|
203
|
-
const token = commandWithoutArgs[i];
|
|
221
|
+
const arg = this.args[i].toLowerCase();
|
|
222
|
+
const token = commandWithoutArgs[i].toLowerCase();
|
|
204
223
|
if (arg !== token && !token.includes(arg)) {
|
|
205
224
|
return false;
|
|
206
225
|
}
|
|
207
226
|
}
|
|
208
227
|
return true;
|
|
209
228
|
}
|
|
210
|
-
// @TODO refactor this to use path.basename or similar
|
|
211
|
-
// to extract the base command from the full command path
|
|
212
229
|
getBaseCommand(fullCommandPath) {
|
|
213
|
-
|
|
214
|
-
|
|
230
|
+
let baseCommand = path.basename(fullCommandPath);
|
|
231
|
+
if (platform() === "win32") {
|
|
232
|
+
baseCommand = path.basename(fullCommandPath, ".exe");
|
|
233
|
+
}
|
|
234
|
+
baseCommand = baseCommand.toLowerCase();
|
|
235
|
+
return baseCommand;
|
|
215
236
|
}
|
|
216
237
|
/*
|
|
217
238
|
example1:
|
|
@@ -290,8 +311,9 @@ var MCPServerManagerService = class {
|
|
|
290
311
|
}
|
|
291
312
|
findMcpServerNameInProcessArguments(commandTokens, mcpServerName) {
|
|
292
313
|
for (let i = 0; i < commandTokens.length; i++) {
|
|
293
|
-
const token = commandTokens[i];
|
|
294
|
-
|
|
314
|
+
const token = commandTokens[i].toLowerCase();
|
|
315
|
+
const normalizedMcpServerName = mcpServerName.toLowerCase();
|
|
316
|
+
if (normalizedMcpServerName === token || token.includes(normalizedMcpServerName)) {
|
|
295
317
|
return true;
|
|
296
318
|
}
|
|
297
319
|
}
|
|
@@ -378,8 +400,8 @@ var MCPServerManagerService = class {
|
|
|
378
400
|
return false;
|
|
379
401
|
}
|
|
380
402
|
for (let i = 0; i < argsToMatch.length; i++) {
|
|
381
|
-
const commandToken = commandTokens[i + 2];
|
|
382
|
-
const expectedArg = argsToMatch[i];
|
|
403
|
+
const commandToken = commandTokens[i + 2].toLowerCase();
|
|
404
|
+
const expectedArg = argsToMatch[i].toLowerCase();
|
|
383
405
|
if (commandToken !== expectedArg) {
|
|
384
406
|
return false;
|
|
385
407
|
}
|
|
@@ -389,6 +411,27 @@ var MCPServerManagerService = class {
|
|
|
389
411
|
};
|
|
390
412
|
|
|
391
413
|
// src/main.ts
|
|
414
|
+
var osSpecificPaths = {
|
|
415
|
+
claude: [],
|
|
416
|
+
cursor: []
|
|
417
|
+
};
|
|
418
|
+
if (platform2() === "win32") {
|
|
419
|
+
osSpecificPaths["claude"] = [
|
|
420
|
+
{ filePath: `${process.env.APPDATA}\\Claude\\claude_desktop_config.json`, type: "global" }
|
|
421
|
+
];
|
|
422
|
+
osSpecificPaths["cursor"] = [
|
|
423
|
+
{ filePath: `${process.env.HOME}\\.cursor\\mcp.json`, type: "global" },
|
|
424
|
+
{ filePath: ".cursor\\mcp.json", type: "local" }
|
|
425
|
+
];
|
|
426
|
+
} else {
|
|
427
|
+
osSpecificPaths["claude"] = [
|
|
428
|
+
{ filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
|
|
429
|
+
];
|
|
430
|
+
osSpecificPaths["cursor"] = [
|
|
431
|
+
{ filePath: "~/.cursor/mcp.json", type: "global" },
|
|
432
|
+
{ filePath: ".cursor/mcp.json", type: "local" }
|
|
433
|
+
];
|
|
434
|
+
}
|
|
392
435
|
var MCPFiles = class {
|
|
393
436
|
static {
|
|
394
437
|
__name(this, "MCPFiles");
|
|
@@ -397,17 +440,12 @@ var MCPFiles = class {
|
|
|
397
440
|
claude: {
|
|
398
441
|
name: "claude-desktop",
|
|
399
442
|
friendlyName: "Claude Desktop",
|
|
400
|
-
paths: [
|
|
401
|
-
{ filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
|
|
402
|
-
]
|
|
443
|
+
paths: osSpecificPaths["claude"]
|
|
403
444
|
},
|
|
404
445
|
cursor: {
|
|
405
446
|
name: "cursor",
|
|
406
447
|
friendlyName: "Cursor",
|
|
407
|
-
paths: [
|
|
408
|
-
{ filePath: "~/.cursor/mcp.json", type: "global" },
|
|
409
|
-
{ filePath: ".cursor/mcp.json", type: "local" }
|
|
410
|
-
]
|
|
448
|
+
paths: osSpecificPaths["cursor"]
|
|
411
449
|
}
|
|
412
450
|
};
|
|
413
451
|
constructor(mcpFilePathGroups) {
|
|
@@ -695,18 +733,18 @@ var RenderService = class {
|
|
|
695
733
|
};
|
|
696
734
|
|
|
697
735
|
// src/bin/cli.ts
|
|
698
|
-
console.log();
|
|
699
736
|
async function init() {
|
|
737
|
+
console.log();
|
|
738
|
+
console.log("[+] Detecting MCP Server configurations...");
|
|
700
739
|
const mcpFilesManager = new MCPFiles();
|
|
701
740
|
const mcpFilesList = await mcpFilesManager.findFiles();
|
|
702
741
|
if (Object.keys(mcpFilesList).length === 0) {
|
|
703
|
-
|
|
704
|
-
return;
|
|
742
|
+
exitWithError("No configuration for MCP Server applications found.");
|
|
705
743
|
}
|
|
706
744
|
let pathIndex = 0;
|
|
707
745
|
for (const groupName of Object.keys(mcpFilesList)) {
|
|
708
746
|
const group = mcpFilesList[groupName];
|
|
709
|
-
if (group.paths.length
|
|
747
|
+
if (group.paths.length > 0) {
|
|
710
748
|
for (const filePathData of group.paths) {
|
|
711
749
|
pathIndex++;
|
|
712
750
|
const filePath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
@@ -728,12 +766,19 @@ async function init() {
|
|
|
728
766
|
RenderService.printMcpGroup(pathIndex, mcpGroupData, groupMetadata);
|
|
729
767
|
RenderService.printMcpServers(mcpServers);
|
|
730
768
|
}
|
|
731
|
-
} else {
|
|
732
|
-
console.log("No files found in this group.");
|
|
733
769
|
}
|
|
734
770
|
}
|
|
771
|
+
if (pathIndex === 0) {
|
|
772
|
+
exitWithError("No MCP servers found in known configuration files.");
|
|
773
|
+
}
|
|
735
774
|
}
|
|
736
775
|
__name(init, "init");
|
|
737
776
|
init().then(() => {
|
|
738
777
|
console.log("\n");
|
|
739
778
|
});
|
|
779
|
+
function exitWithError(message) {
|
|
780
|
+
console.error(`${styleText8(["red"], "\u25CF")} ${message}
|
|
781
|
+
`);
|
|
782
|
+
process.exit(1);
|
|
783
|
+
}
|
|
784
|
+
__name(exitWithError, "exitWithError");
|
package/dist/main.cjs
CHANGED
|
@@ -35,6 +35,7 @@ __export(main_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(main_exports);
|
|
37
37
|
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
38
|
+
var import_node_os2 = require("os");
|
|
38
39
|
|
|
39
40
|
// src/services/mcp-config-linter-service.ts
|
|
40
41
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
@@ -76,6 +77,7 @@ var MCPConfigLinterService = class {
|
|
|
76
77
|
};
|
|
77
78
|
|
|
78
79
|
// src/services/mcp-server-manager-service.ts
|
|
80
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
79
81
|
var import_node_child_process = require("child_process");
|
|
80
82
|
var import_node_os = require("os");
|
|
81
83
|
var MCPServerManagerService = class {
|
|
@@ -135,15 +137,15 @@ var MCPServerManagerService = class {
|
|
|
135
137
|
if (processLine.startsWith('"ProcessId"') || processLine.startsWith("ProcessId")) continue;
|
|
136
138
|
const parts = this.parseCSVLine(processLine);
|
|
137
139
|
if (parts.length < 4) continue;
|
|
138
|
-
pid = parts[0] || "";
|
|
139
|
-
commandLine = parts[2] || "";
|
|
140
|
-
ppid = parts[3] || "";
|
|
140
|
+
pid = parts[0].trim() || "";
|
|
141
|
+
commandLine = parts[2].trim() || "";
|
|
142
|
+
ppid = parts[3].trim() || "";
|
|
141
143
|
} else {
|
|
142
144
|
const match = processLine.trim().match(/^\s*(\d+)\s+(\d+)\s+(.+)$/);
|
|
143
145
|
if (!match) continue;
|
|
144
|
-
pid = match[1];
|
|
145
|
-
ppid = match[2];
|
|
146
|
-
commandLine = match[3];
|
|
146
|
+
pid = match[1].trim() || "";
|
|
147
|
+
ppid = match[2].trim() || "";
|
|
148
|
+
commandLine = match[3].trim() || "";
|
|
147
149
|
}
|
|
148
150
|
const commandTokens = this.parseCommandLine(commandLine);
|
|
149
151
|
if (commandTokens.length > 0) {
|
|
@@ -152,7 +154,20 @@ var MCPServerManagerService = class {
|
|
|
152
154
|
}
|
|
153
155
|
let mcpServerDetection;
|
|
154
156
|
for (const [pid, processData] of processMap) {
|
|
155
|
-
|
|
157
|
+
const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid);
|
|
158
|
+
let commandMatchWin32 = false;
|
|
159
|
+
if ((0, import_node_os.platform)() === "win32") {
|
|
160
|
+
let commandTokensOnWin32 = processData.commandTokens;
|
|
161
|
+
if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith("cmd")) {
|
|
162
|
+
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
163
|
+
while (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].startsWith("/")) {
|
|
164
|
+
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
commandMatchWin32 = this.isCommandMatch(commandTokensOnWin32, pid, processData.ppid);
|
|
168
|
+
}
|
|
169
|
+
const commandMatch = commandMatchLinux || commandMatchWin32;
|
|
170
|
+
if (commandMatch) {
|
|
156
171
|
mcpServerDetection = {
|
|
157
172
|
pid,
|
|
158
173
|
commandLine: processData.commandTokens.join(" "),
|
|
@@ -199,13 +214,14 @@ var MCPServerManagerService = class {
|
|
|
199
214
|
isCommandMatch(commandTokens, pid, ppid) {
|
|
200
215
|
if (commandTokens.length === 0) return false;
|
|
201
216
|
const baseCommand = this.getBaseCommand(commandTokens[0]);
|
|
202
|
-
|
|
217
|
+
const commandInConfig = this.getBaseCommand(this.command);
|
|
218
|
+
if (commandInConfig === "uvx" && baseCommand === "uv") {
|
|
203
219
|
return this.matchUvxProcess(commandTokens);
|
|
204
220
|
}
|
|
205
|
-
if (
|
|
221
|
+
if (commandInConfig === "npx" && baseCommand === "npm") {
|
|
206
222
|
return this.matchNpxProcess(commandTokens);
|
|
207
223
|
}
|
|
208
|
-
if (
|
|
224
|
+
if (commandInConfig === "uv" && baseCommand === "uv") {
|
|
209
225
|
return this.matchGenericArgsToArgs(commandTokens);
|
|
210
226
|
}
|
|
211
227
|
const commandConfigPythonBase = this.getBaseCommand(this.command);
|
|
@@ -230,19 +246,21 @@ var MCPServerManagerService = class {
|
|
|
230
246
|
const commandWithoutArgs = commandTokens.slice(1);
|
|
231
247
|
for (let i = 0; i < this.args.length; i++) {
|
|
232
248
|
if (i >= commandWithoutArgs.length) return false;
|
|
233
|
-
const arg = this.args[i];
|
|
234
|
-
const token = commandWithoutArgs[i];
|
|
249
|
+
const arg = this.args[i].toLowerCase();
|
|
250
|
+
const token = commandWithoutArgs[i].toLowerCase();
|
|
235
251
|
if (arg !== token && !token.includes(arg)) {
|
|
236
252
|
return false;
|
|
237
253
|
}
|
|
238
254
|
}
|
|
239
255
|
return true;
|
|
240
256
|
}
|
|
241
|
-
// @TODO refactor this to use path.basename or similar
|
|
242
|
-
// to extract the base command from the full command path
|
|
243
257
|
getBaseCommand(fullCommandPath) {
|
|
244
|
-
|
|
245
|
-
|
|
258
|
+
let baseCommand = import_node_path.default.basename(fullCommandPath);
|
|
259
|
+
if ((0, import_node_os.platform)() === "win32") {
|
|
260
|
+
baseCommand = import_node_path.default.basename(fullCommandPath, ".exe");
|
|
261
|
+
}
|
|
262
|
+
baseCommand = baseCommand.toLowerCase();
|
|
263
|
+
return baseCommand;
|
|
246
264
|
}
|
|
247
265
|
/*
|
|
248
266
|
example1:
|
|
@@ -321,8 +339,9 @@ var MCPServerManagerService = class {
|
|
|
321
339
|
}
|
|
322
340
|
findMcpServerNameInProcessArguments(commandTokens, mcpServerName) {
|
|
323
341
|
for (let i = 0; i < commandTokens.length; i++) {
|
|
324
|
-
const token = commandTokens[i];
|
|
325
|
-
|
|
342
|
+
const token = commandTokens[i].toLowerCase();
|
|
343
|
+
const normalizedMcpServerName = mcpServerName.toLowerCase();
|
|
344
|
+
if (normalizedMcpServerName === token || token.includes(normalizedMcpServerName)) {
|
|
326
345
|
return true;
|
|
327
346
|
}
|
|
328
347
|
}
|
|
@@ -409,8 +428,8 @@ var MCPServerManagerService = class {
|
|
|
409
428
|
return false;
|
|
410
429
|
}
|
|
411
430
|
for (let i = 0; i < argsToMatch.length; i++) {
|
|
412
|
-
const commandToken = commandTokens[i + 2];
|
|
413
|
-
const expectedArg = argsToMatch[i];
|
|
431
|
+
const commandToken = commandTokens[i + 2].toLowerCase();
|
|
432
|
+
const expectedArg = argsToMatch[i].toLowerCase();
|
|
414
433
|
if (commandToken !== expectedArg) {
|
|
415
434
|
return false;
|
|
416
435
|
}
|
|
@@ -420,6 +439,27 @@ var MCPServerManagerService = class {
|
|
|
420
439
|
};
|
|
421
440
|
|
|
422
441
|
// src/main.ts
|
|
442
|
+
var osSpecificPaths = {
|
|
443
|
+
claude: [],
|
|
444
|
+
cursor: []
|
|
445
|
+
};
|
|
446
|
+
if ((0, import_node_os2.platform)() === "win32") {
|
|
447
|
+
osSpecificPaths["claude"] = [
|
|
448
|
+
{ filePath: `${process.env.APPDATA}\\Claude\\claude_desktop_config.json`, type: "global" }
|
|
449
|
+
];
|
|
450
|
+
osSpecificPaths["cursor"] = [
|
|
451
|
+
{ filePath: `${process.env.HOME}\\.cursor\\mcp.json`, type: "global" },
|
|
452
|
+
{ filePath: ".cursor\\mcp.json", type: "local" }
|
|
453
|
+
];
|
|
454
|
+
} else {
|
|
455
|
+
osSpecificPaths["claude"] = [
|
|
456
|
+
{ filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
|
|
457
|
+
];
|
|
458
|
+
osSpecificPaths["cursor"] = [
|
|
459
|
+
{ filePath: "~/.cursor/mcp.json", type: "global" },
|
|
460
|
+
{ filePath: ".cursor/mcp.json", type: "local" }
|
|
461
|
+
];
|
|
462
|
+
}
|
|
423
463
|
var MCPFiles = class {
|
|
424
464
|
static {
|
|
425
465
|
__name(this, "MCPFiles");
|
|
@@ -428,17 +468,12 @@ var MCPFiles = class {
|
|
|
428
468
|
claude: {
|
|
429
469
|
name: "claude-desktop",
|
|
430
470
|
friendlyName: "Claude Desktop",
|
|
431
|
-
paths: [
|
|
432
|
-
{ filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
|
|
433
|
-
]
|
|
471
|
+
paths: osSpecificPaths["claude"]
|
|
434
472
|
},
|
|
435
473
|
cursor: {
|
|
436
474
|
name: "cursor",
|
|
437
475
|
friendlyName: "Cursor",
|
|
438
|
-
paths: [
|
|
439
|
-
{ filePath: "~/.cursor/mcp.json", type: "global" },
|
|
440
|
-
{ filePath: ".cursor/mcp.json", type: "local" }
|
|
441
|
-
]
|
|
476
|
+
paths: osSpecificPaths["cursor"]
|
|
442
477
|
}
|
|
443
478
|
};
|
|
444
479
|
constructor(mcpFilePathGroups) {
|
package/dist/main.mjs
CHANGED
|
@@ -3,6 +3,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/main.ts
|
|
5
5
|
import fs2 from "fs/promises";
|
|
6
|
+
import { platform as platform2 } from "os";
|
|
6
7
|
|
|
7
8
|
// src/services/mcp-config-linter-service.ts
|
|
8
9
|
import fs from "fs/promises";
|
|
@@ -44,6 +45,7 @@ var MCPConfigLinterService = class {
|
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
// src/services/mcp-server-manager-service.ts
|
|
48
|
+
import path from "path";
|
|
47
49
|
import { execSync } from "child_process";
|
|
48
50
|
import { platform } from "os";
|
|
49
51
|
var MCPServerManagerService = class {
|
|
@@ -103,15 +105,15 @@ var MCPServerManagerService = class {
|
|
|
103
105
|
if (processLine.startsWith('"ProcessId"') || processLine.startsWith("ProcessId")) continue;
|
|
104
106
|
const parts = this.parseCSVLine(processLine);
|
|
105
107
|
if (parts.length < 4) continue;
|
|
106
|
-
pid = parts[0] || "";
|
|
107
|
-
commandLine = parts[2] || "";
|
|
108
|
-
ppid = parts[3] || "";
|
|
108
|
+
pid = parts[0].trim() || "";
|
|
109
|
+
commandLine = parts[2].trim() || "";
|
|
110
|
+
ppid = parts[3].trim() || "";
|
|
109
111
|
} else {
|
|
110
112
|
const match = processLine.trim().match(/^\s*(\d+)\s+(\d+)\s+(.+)$/);
|
|
111
113
|
if (!match) continue;
|
|
112
|
-
pid = match[1];
|
|
113
|
-
ppid = match[2];
|
|
114
|
-
commandLine = match[3];
|
|
114
|
+
pid = match[1].trim() || "";
|
|
115
|
+
ppid = match[2].trim() || "";
|
|
116
|
+
commandLine = match[3].trim() || "";
|
|
115
117
|
}
|
|
116
118
|
const commandTokens = this.parseCommandLine(commandLine);
|
|
117
119
|
if (commandTokens.length > 0) {
|
|
@@ -120,7 +122,20 @@ var MCPServerManagerService = class {
|
|
|
120
122
|
}
|
|
121
123
|
let mcpServerDetection;
|
|
122
124
|
for (const [pid, processData] of processMap) {
|
|
123
|
-
|
|
125
|
+
const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid);
|
|
126
|
+
let commandMatchWin32 = false;
|
|
127
|
+
if (platform() === "win32") {
|
|
128
|
+
let commandTokensOnWin32 = processData.commandTokens;
|
|
129
|
+
if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith("cmd")) {
|
|
130
|
+
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
131
|
+
while (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].startsWith("/")) {
|
|
132
|
+
commandTokensOnWin32 = commandTokensOnWin32.slice(1);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
commandMatchWin32 = this.isCommandMatch(commandTokensOnWin32, pid, processData.ppid);
|
|
136
|
+
}
|
|
137
|
+
const commandMatch = commandMatchLinux || commandMatchWin32;
|
|
138
|
+
if (commandMatch) {
|
|
124
139
|
mcpServerDetection = {
|
|
125
140
|
pid,
|
|
126
141
|
commandLine: processData.commandTokens.join(" "),
|
|
@@ -167,13 +182,14 @@ var MCPServerManagerService = class {
|
|
|
167
182
|
isCommandMatch(commandTokens, pid, ppid) {
|
|
168
183
|
if (commandTokens.length === 0) return false;
|
|
169
184
|
const baseCommand = this.getBaseCommand(commandTokens[0]);
|
|
170
|
-
|
|
185
|
+
const commandInConfig = this.getBaseCommand(this.command);
|
|
186
|
+
if (commandInConfig === "uvx" && baseCommand === "uv") {
|
|
171
187
|
return this.matchUvxProcess(commandTokens);
|
|
172
188
|
}
|
|
173
|
-
if (
|
|
189
|
+
if (commandInConfig === "npx" && baseCommand === "npm") {
|
|
174
190
|
return this.matchNpxProcess(commandTokens);
|
|
175
191
|
}
|
|
176
|
-
if (
|
|
192
|
+
if (commandInConfig === "uv" && baseCommand === "uv") {
|
|
177
193
|
return this.matchGenericArgsToArgs(commandTokens);
|
|
178
194
|
}
|
|
179
195
|
const commandConfigPythonBase = this.getBaseCommand(this.command);
|
|
@@ -198,19 +214,21 @@ var MCPServerManagerService = class {
|
|
|
198
214
|
const commandWithoutArgs = commandTokens.slice(1);
|
|
199
215
|
for (let i = 0; i < this.args.length; i++) {
|
|
200
216
|
if (i >= commandWithoutArgs.length) return false;
|
|
201
|
-
const arg = this.args[i];
|
|
202
|
-
const token = commandWithoutArgs[i];
|
|
217
|
+
const arg = this.args[i].toLowerCase();
|
|
218
|
+
const token = commandWithoutArgs[i].toLowerCase();
|
|
203
219
|
if (arg !== token && !token.includes(arg)) {
|
|
204
220
|
return false;
|
|
205
221
|
}
|
|
206
222
|
}
|
|
207
223
|
return true;
|
|
208
224
|
}
|
|
209
|
-
// @TODO refactor this to use path.basename or similar
|
|
210
|
-
// to extract the base command from the full command path
|
|
211
225
|
getBaseCommand(fullCommandPath) {
|
|
212
|
-
|
|
213
|
-
|
|
226
|
+
let baseCommand = path.basename(fullCommandPath);
|
|
227
|
+
if (platform() === "win32") {
|
|
228
|
+
baseCommand = path.basename(fullCommandPath, ".exe");
|
|
229
|
+
}
|
|
230
|
+
baseCommand = baseCommand.toLowerCase();
|
|
231
|
+
return baseCommand;
|
|
214
232
|
}
|
|
215
233
|
/*
|
|
216
234
|
example1:
|
|
@@ -289,8 +307,9 @@ var MCPServerManagerService = class {
|
|
|
289
307
|
}
|
|
290
308
|
findMcpServerNameInProcessArguments(commandTokens, mcpServerName) {
|
|
291
309
|
for (let i = 0; i < commandTokens.length; i++) {
|
|
292
|
-
const token = commandTokens[i];
|
|
293
|
-
|
|
310
|
+
const token = commandTokens[i].toLowerCase();
|
|
311
|
+
const normalizedMcpServerName = mcpServerName.toLowerCase();
|
|
312
|
+
if (normalizedMcpServerName === token || token.includes(normalizedMcpServerName)) {
|
|
294
313
|
return true;
|
|
295
314
|
}
|
|
296
315
|
}
|
|
@@ -377,8 +396,8 @@ var MCPServerManagerService = class {
|
|
|
377
396
|
return false;
|
|
378
397
|
}
|
|
379
398
|
for (let i = 0; i < argsToMatch.length; i++) {
|
|
380
|
-
const commandToken = commandTokens[i + 2];
|
|
381
|
-
const expectedArg = argsToMatch[i];
|
|
399
|
+
const commandToken = commandTokens[i + 2].toLowerCase();
|
|
400
|
+
const expectedArg = argsToMatch[i].toLowerCase();
|
|
382
401
|
if (commandToken !== expectedArg) {
|
|
383
402
|
return false;
|
|
384
403
|
}
|
|
@@ -388,6 +407,27 @@ var MCPServerManagerService = class {
|
|
|
388
407
|
};
|
|
389
408
|
|
|
390
409
|
// src/main.ts
|
|
410
|
+
var osSpecificPaths = {
|
|
411
|
+
claude: [],
|
|
412
|
+
cursor: []
|
|
413
|
+
};
|
|
414
|
+
if (platform2() === "win32") {
|
|
415
|
+
osSpecificPaths["claude"] = [
|
|
416
|
+
{ filePath: `${process.env.APPDATA}\\Claude\\claude_desktop_config.json`, type: "global" }
|
|
417
|
+
];
|
|
418
|
+
osSpecificPaths["cursor"] = [
|
|
419
|
+
{ filePath: `${process.env.HOME}\\.cursor\\mcp.json`, type: "global" },
|
|
420
|
+
{ filePath: ".cursor\\mcp.json", type: "local" }
|
|
421
|
+
];
|
|
422
|
+
} else {
|
|
423
|
+
osSpecificPaths["claude"] = [
|
|
424
|
+
{ filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
|
|
425
|
+
];
|
|
426
|
+
osSpecificPaths["cursor"] = [
|
|
427
|
+
{ filePath: "~/.cursor/mcp.json", type: "global" },
|
|
428
|
+
{ filePath: ".cursor/mcp.json", type: "local" }
|
|
429
|
+
];
|
|
430
|
+
}
|
|
391
431
|
var MCPFiles = class {
|
|
392
432
|
static {
|
|
393
433
|
__name(this, "MCPFiles");
|
|
@@ -396,17 +436,12 @@ var MCPFiles = class {
|
|
|
396
436
|
claude: {
|
|
397
437
|
name: "claude-desktop",
|
|
398
438
|
friendlyName: "Claude Desktop",
|
|
399
|
-
paths: [
|
|
400
|
-
{ filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
|
|
401
|
-
]
|
|
439
|
+
paths: osSpecificPaths["claude"]
|
|
402
440
|
},
|
|
403
441
|
cursor: {
|
|
404
442
|
name: "cursor",
|
|
405
443
|
friendlyName: "Cursor",
|
|
406
|
-
paths: [
|
|
407
|
-
{ filePath: "~/.cursor/mcp.json", type: "global" },
|
|
408
|
-
{ filePath: ".cursor/mcp.json", type: "local" }
|
|
409
|
-
]
|
|
444
|
+
paths: osSpecificPaths["cursor"]
|
|
410
445
|
}
|
|
411
446
|
};
|
|
412
447
|
constructor(mcpFilePathGroups) {
|
package/package.json
CHANGED
package/src/bin/cli.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// import { debuglog } from 'node:util'
|
|
4
|
+
import { styleText } from 'node:util'
|
|
4
5
|
import { MCPFiles } from '../main.ts'
|
|
5
6
|
import { RenderService } from '../services/render-service.ts'
|
|
6
7
|
|
|
@@ -13,26 +14,26 @@ interface MCPServerInfo {
|
|
|
13
14
|
status?: 'running' | 'stopped'
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
// Start the CLI with a new line for better readability
|
|
17
|
-
console.log()
|
|
18
|
-
|
|
19
17
|
// @TODO add debug logging
|
|
20
18
|
// const debug = debuglog('ls-mcp')
|
|
21
19
|
|
|
22
20
|
async function init () {
|
|
21
|
+
// Start the CLI with a new line for better readability
|
|
22
|
+
console.log()
|
|
23
|
+
console.log('[+] Detecting MCP Server configurations...')
|
|
24
|
+
|
|
23
25
|
const mcpFilesManager = new MCPFiles()
|
|
24
26
|
const mcpFilesList = await mcpFilesManager.findFiles()
|
|
25
27
|
|
|
26
28
|
if (Object.keys(mcpFilesList).length === 0) {
|
|
27
|
-
|
|
28
|
-
return
|
|
29
|
+
exitWithError('No configuration for MCP Server applications found.')
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
let pathIndex = 0
|
|
32
33
|
for (const groupName of Object.keys(mcpFilesList)) {
|
|
33
34
|
const group = mcpFilesList[groupName]
|
|
34
35
|
|
|
35
|
-
if (group.paths.length
|
|
36
|
+
if (group.paths.length > 0) {
|
|
36
37
|
// handle file path list of MCP Servers
|
|
37
38
|
for (const filePathData of group.paths) {
|
|
38
39
|
pathIndex++
|
|
@@ -60,12 +61,19 @@ async function init () {
|
|
|
60
61
|
RenderService.printMcpGroup(pathIndex, mcpGroupData, groupMetadata)
|
|
61
62
|
RenderService.printMcpServers(mcpServers)
|
|
62
63
|
}
|
|
63
|
-
} else {
|
|
64
|
-
console.log('No files found in this group.')
|
|
65
64
|
}
|
|
66
65
|
}
|
|
66
|
+
|
|
67
|
+
if (pathIndex === 0) {
|
|
68
|
+
exitWithError('No MCP servers found in known configuration files.')
|
|
69
|
+
}
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
init().then(() => {
|
|
70
73
|
console.log('\n')
|
|
71
74
|
})
|
|
75
|
+
|
|
76
|
+
function exitWithError (message: string) {
|
|
77
|
+
console.error(`${styleText(['red'], '●')} ${message}\n`)
|
|
78
|
+
process.exit(1)
|
|
79
|
+
}
|
package/src/main.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from 'node:fs/promises'
|
|
2
|
+
import { platform } from 'node:os'
|
|
2
3
|
import { MCPConfigLinterService } from './services/mcp-config-linter-service.ts'
|
|
3
4
|
import { MCPServerManagerService } from './services/mcp-server-manager-service.ts'
|
|
4
5
|
|
|
@@ -39,22 +40,40 @@ interface MCPFileGroupsResult {
|
|
|
39
40
|
type MCPFilePathGroupsRecord = Record<string, MCPFileGroups>
|
|
40
41
|
type MCPFileGroupsResultRecord = Record<string, MCPFileGroupsResult>
|
|
41
42
|
|
|
43
|
+
const osSpecificPaths: { [key: string]: MCPFilePath[] } = {
|
|
44
|
+
claude: [],
|
|
45
|
+
cursor: []
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (platform() === 'win32') {
|
|
49
|
+
osSpecificPaths['claude'] = [
|
|
50
|
+
{ filePath: `${process.env.APPDATA}\\Claude\\claude_desktop_config.json`, type: 'global' }
|
|
51
|
+
]
|
|
52
|
+
osSpecificPaths['cursor'] = [
|
|
53
|
+
{ filePath: `${process.env.HOME}\\.cursor\\mcp.json`, type: 'global' },
|
|
54
|
+
{ filePath: '.cursor\\mcp.json', type: 'local' }
|
|
55
|
+
]
|
|
56
|
+
} else {
|
|
57
|
+
osSpecificPaths['claude'] = [
|
|
58
|
+
{ filePath: '~/Library/Application Support/Claude/claude_desktop_config.json', type: 'global' }
|
|
59
|
+
]
|
|
60
|
+
osSpecificPaths['cursor'] = [
|
|
61
|
+
{ filePath: '~/.cursor/mcp.json', type: 'global' },
|
|
62
|
+
{ filePath: '.cursor/mcp.json', type: 'local' }
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
|
|
42
66
|
export class MCPFiles {
|
|
43
67
|
private mcpFilePathGroups: MCPFilePathGroupsRecord = {
|
|
44
68
|
claude: {
|
|
45
69
|
name: 'claude-desktop',
|
|
46
70
|
friendlyName: 'Claude Desktop',
|
|
47
|
-
paths: [
|
|
48
|
-
{ filePath: '~/Library/Application Support/Claude/claude_desktop_config.json', type: 'global' },
|
|
49
|
-
]
|
|
71
|
+
paths: osSpecificPaths['claude']
|
|
50
72
|
},
|
|
51
73
|
cursor: {
|
|
52
74
|
name: 'cursor',
|
|
53
75
|
friendlyName: 'Cursor',
|
|
54
|
-
paths: [
|
|
55
|
-
{ filePath: '~/.cursor/mcp.json', type: 'global' },
|
|
56
|
-
{ filePath: '.cursor/mcp.json', type: 'local' },
|
|
57
|
-
]
|
|
76
|
+
paths: osSpecificPaths['cursor']
|
|
58
77
|
}
|
|
59
78
|
}
|
|
60
79
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
1
2
|
import { execSync } from 'node:child_process'
|
|
2
3
|
import { platform } from 'node:os'
|
|
3
4
|
|
|
@@ -89,17 +90,17 @@ export class MCPServerManagerService {
|
|
|
89
90
|
|
|
90
91
|
const parts = this.parseCSVLine(processLine)
|
|
91
92
|
if (parts.length < 4) continue
|
|
92
|
-
pid = parts[0] || ''
|
|
93
|
+
pid = parts[0].trim() || ''
|
|
93
94
|
// Skip Name (parts[1])
|
|
94
|
-
commandLine = parts[2] || ''
|
|
95
|
-
ppid = parts[3] || ''
|
|
95
|
+
commandLine = parts[2].trim() || ''
|
|
96
|
+
ppid = parts[3].trim() || ''
|
|
96
97
|
} else {
|
|
97
98
|
// Parse Unix ps output: PID PPID COMMAND
|
|
98
99
|
const match = processLine.trim().match(/^\s*(\d+)\s+(\d+)\s+(.+)$/)
|
|
99
100
|
if (!match) continue
|
|
100
|
-
pid = match[1]
|
|
101
|
-
ppid = match[2]
|
|
102
|
-
commandLine = match[3]
|
|
101
|
+
pid = match[1].trim() || ''
|
|
102
|
+
ppid = match[2].trim() || ''
|
|
103
|
+
commandLine = match[3].trim() || ''
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
// Parse command line and store in map
|
|
@@ -111,8 +112,34 @@ export class MCPServerManagerService {
|
|
|
111
112
|
|
|
112
113
|
// Then iterate the map to check for matches
|
|
113
114
|
let mcpServerDetection: MatchedProcess | undefined
|
|
115
|
+
|
|
114
116
|
for (const [pid, processData] of processMap) {
|
|
115
|
-
|
|
117
|
+
const commandMatchLinux = this.isCommandMatch(processData.commandTokens, pid, processData.ppid)
|
|
118
|
+
let commandMatchWin32 = false
|
|
119
|
+
if (platform() === 'win32') {
|
|
120
|
+
// for Windows, we need to change commandTokens to also match another pattern
|
|
121
|
+
// where the command starts with `cmd` then follows potentially several command-line
|
|
122
|
+
// flags like /c /d and then the actual command.
|
|
123
|
+
// This is because Claude Desktop on Windows automatically starts MCP Servers like that
|
|
124
|
+
// even if the command specified in the MCP config is just `uvx` or `npx`.
|
|
125
|
+
|
|
126
|
+
let commandTokensOnWin32 = processData.commandTokens
|
|
127
|
+
if (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].toLowerCase().startsWith('cmd')) {
|
|
128
|
+
// If the first token is 'cmd', we need to skip it and check the next tokens
|
|
129
|
+
commandTokensOnWin32 = commandTokensOnWin32.slice(1)
|
|
130
|
+
|
|
131
|
+
// Skip any additional flags like /c, /d, etc.
|
|
132
|
+
while (commandTokensOnWin32.length > 0 && commandTokensOnWin32[0].startsWith('/')) {
|
|
133
|
+
commandTokensOnWin32 = commandTokensOnWin32.slice(1)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
commandMatchWin32 = this.isCommandMatch(commandTokensOnWin32, pid, processData.ppid)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const commandMatch = commandMatchLinux || commandMatchWin32
|
|
141
|
+
|
|
142
|
+
if (commandMatch) {
|
|
116
143
|
mcpServerDetection = {
|
|
117
144
|
pid,
|
|
118
145
|
commandLine: processData.commandTokens.join(' '),
|
|
@@ -174,13 +201,15 @@ export class MCPServerManagerService {
|
|
|
174
201
|
// e.g. "/usr/homebrew/bin/uv" extracted to "uv"
|
|
175
202
|
const baseCommand = this.getBaseCommand(commandTokens[0])
|
|
176
203
|
|
|
204
|
+
const commandInConfig: string = this.getBaseCommand(this.command)
|
|
205
|
+
|
|
177
206
|
// Map configured command to actual process command for uvx case
|
|
178
|
-
if (
|
|
207
|
+
if (commandInConfig === 'uvx' && baseCommand === 'uv') {
|
|
179
208
|
return this.matchUvxProcess(commandTokens)
|
|
180
209
|
}
|
|
181
210
|
|
|
182
211
|
// Map configured command to actual process command for npx case
|
|
183
|
-
if (
|
|
212
|
+
if (commandInConfig === 'npx' && baseCommand === 'npm') {
|
|
184
213
|
return this.matchNpxProcess(commandTokens)
|
|
185
214
|
}
|
|
186
215
|
|
|
@@ -196,7 +225,7 @@ export class MCPServerManagerService {
|
|
|
196
225
|
]
|
|
197
226
|
},
|
|
198
227
|
*/
|
|
199
|
-
if (
|
|
228
|
+
if (commandInConfig === 'uv' && baseCommand === 'uv') {
|
|
200
229
|
return this.matchGenericArgsToArgs(commandTokens)
|
|
201
230
|
}
|
|
202
231
|
|
|
@@ -245,8 +274,8 @@ export class MCPServerManagerService {
|
|
|
245
274
|
// If we reach the end of command tokens, we cannot match
|
|
246
275
|
if (i >= commandWithoutArgs.length) return false
|
|
247
276
|
|
|
248
|
-
const arg = this.args[i]
|
|
249
|
-
const token = commandWithoutArgs[i]
|
|
277
|
+
const arg = this.args[i].toLowerCase()
|
|
278
|
+
const token = commandWithoutArgs[i].toLowerCase()
|
|
250
279
|
|
|
251
280
|
// Check if the argument matches the command token
|
|
252
281
|
if (arg !== token && !token.includes(arg)) {
|
|
@@ -258,12 +287,17 @@ export class MCPServerManagerService {
|
|
|
258
287
|
return true
|
|
259
288
|
}
|
|
260
289
|
|
|
261
|
-
// @TODO refactor this to use path.basename or similar
|
|
262
|
-
// to extract the base command from the full command path
|
|
263
290
|
private getBaseCommand (fullCommandPath: string): string {
|
|
264
291
|
// Extract base command name from full path
|
|
265
|
-
|
|
266
|
-
|
|
292
|
+
let baseCommand = path.basename(fullCommandPath)
|
|
293
|
+
// Detect if we're on Windows and if so we omit the .exe extension
|
|
294
|
+
if (platform() === 'win32') {
|
|
295
|
+
baseCommand = path.basename(fullCommandPath, '.exe')
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// In any case, we want to return the base command as lowercase
|
|
299
|
+
baseCommand = baseCommand.toLowerCase()
|
|
300
|
+
return baseCommand
|
|
267
301
|
}
|
|
268
302
|
|
|
269
303
|
/*
|
|
@@ -362,8 +396,10 @@ export class MCPServerManagerService {
|
|
|
362
396
|
private findMcpServerNameInProcessArguments (commandTokens: string[], mcpServerName: string): boolean {
|
|
363
397
|
// Check if the command tokens contain the MCP server name
|
|
364
398
|
for (let i = 0; i < commandTokens.length; i++) {
|
|
365
|
-
const token = commandTokens[i]
|
|
366
|
-
|
|
399
|
+
const token = commandTokens[i].toLowerCase()
|
|
400
|
+
const normalizedMcpServerName = mcpServerName.toLowerCase()
|
|
401
|
+
|
|
402
|
+
if (normalizedMcpServerName === token || token.includes(normalizedMcpServerName)) {
|
|
367
403
|
// If we find the MCP server name in the command tokens, we consider it a match
|
|
368
404
|
return true
|
|
369
405
|
}
|
|
@@ -480,8 +516,9 @@ export class MCPServerManagerService {
|
|
|
480
516
|
|
|
481
517
|
// Compare each argument starting from position 2 in commandTokens
|
|
482
518
|
for (let i = 0; i < argsToMatch.length; i++) {
|
|
483
|
-
|
|
484
|
-
const
|
|
519
|
+
// Start from index 2 (after "npm exec")
|
|
520
|
+
const commandToken = commandTokens[i + 2].toLowerCase()
|
|
521
|
+
const expectedArg = argsToMatch[i].toLowerCase()
|
|
485
522
|
|
|
486
523
|
if (commandToken !== expectedArg) {
|
|
487
524
|
return false
|
|
@@ -180,9 +180,6 @@ export class RenderService {
|
|
|
180
180
|
const leftPadding = index === 0 ? leftPaddingGroupLead : leftPaddingGroupData
|
|
181
181
|
console.log(leftPadding + dataRow)
|
|
182
182
|
}
|
|
183
|
-
|
|
184
|
-
// Print bottom separator
|
|
185
|
-
// console.log('')
|
|
186
183
|
}
|
|
187
184
|
|
|
188
185
|
// draws progress bar components like this
|