ls-mcp 1.2.0 → 1.3.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 +337 -24
- package/dist/bin/cli.d.cts +1 -2
- package/dist/bin/cli.d.ts +1 -2
- package/dist/bin/cli.mjs +337 -24
- package/dist/main.cjs +294 -5
- package/dist/main.mjs +294 -5
- package/package.json +5 -3
- package/src/bin/cli.ts +7 -4
- package/src/components/mcp-server-status.ts +1 -1
- package/src/components/mcp-servers-config-parsable.ts +2 -2
- package/src/main.ts +11 -3
- package/src/services/mcp-server-manager-service.ts +414 -3
- package/src/services/render-service.ts +44 -19
package/dist/main.cjs
CHANGED
|
@@ -76,6 +76,8 @@ var MCPConfigLinterService = class {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
// src/services/mcp-server-manager-service.ts
|
|
79
|
+
var import_node_child_process = require("child_process");
|
|
80
|
+
var import_node_os = require("os");
|
|
79
81
|
var MCPServerManagerService = class {
|
|
80
82
|
static {
|
|
81
83
|
__name(this, "MCPServerManagerService");
|
|
@@ -109,7 +111,287 @@ var MCPServerManagerService = class {
|
|
|
109
111
|
return this.env;
|
|
110
112
|
}
|
|
111
113
|
isRunning() {
|
|
112
|
-
|
|
114
|
+
try {
|
|
115
|
+
let psOutput;
|
|
116
|
+
if ((0, import_node_os.platform)() === "win32") {
|
|
117
|
+
psOutput = (0, import_node_child_process.execSync)("wmic process get ProcessId,ParentProcessId,CommandLine /format:csv", {
|
|
118
|
+
encoding: "utf8",
|
|
119
|
+
timeout: 5e3
|
|
120
|
+
});
|
|
121
|
+
} else {
|
|
122
|
+
psOutput = (0, import_node_child_process.execSync)("ps -eao pid,ppid,args", {
|
|
123
|
+
encoding: "utf8",
|
|
124
|
+
timeout: 5e3
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const processMap = /* @__PURE__ */ new Map();
|
|
128
|
+
const processes = psOutput.trim().split("\n");
|
|
129
|
+
for (const processLine of processes) {
|
|
130
|
+
if (!processLine.trim()) continue;
|
|
131
|
+
let pid;
|
|
132
|
+
let ppid;
|
|
133
|
+
let commandLine;
|
|
134
|
+
if ((0, import_node_os.platform)() === "win32") {
|
|
135
|
+
const parts = processLine.split(",");
|
|
136
|
+
if (parts.length < 4) continue;
|
|
137
|
+
commandLine = parts[1] || "";
|
|
138
|
+
ppid = parts[2] || "";
|
|
139
|
+
pid = parts[3] || "";
|
|
140
|
+
} else {
|
|
141
|
+
const match = processLine.trim().match(/^\s*(\d+)\s+(\d+)\s+(.+)$/);
|
|
142
|
+
if (!match) continue;
|
|
143
|
+
pid = match[1];
|
|
144
|
+
ppid = match[2];
|
|
145
|
+
commandLine = match[3];
|
|
146
|
+
}
|
|
147
|
+
const commandTokens = this.parseCommandLine(commandLine);
|
|
148
|
+
if (commandTokens.length > 0) {
|
|
149
|
+
processMap.set(pid, { ppid, commandTokens });
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
let mcpServerDetection;
|
|
153
|
+
for (const [pid, processData] of processMap) {
|
|
154
|
+
if (this.isCommandMatch(processData.commandTokens, pid, processData.ppid)) {
|
|
155
|
+
mcpServerDetection = {
|
|
156
|
+
pid,
|
|
157
|
+
commandLine: processData.commandTokens.join(" "),
|
|
158
|
+
ppid: processData.ppid
|
|
159
|
+
};
|
|
160
|
+
const parentProcess = processMap.get(processData.ppid);
|
|
161
|
+
if (parentProcess) {
|
|
162
|
+
const { estimatedVendor, estimatedProduct } = this.getVendorFromCommand(parentProcess.commandTokens) || {};
|
|
163
|
+
if (estimatedProduct || estimatedVendor) {
|
|
164
|
+
mcpServerDetection = {
|
|
165
|
+
...mcpServerDetection,
|
|
166
|
+
parentCommandLine: parentProcess.commandTokens.join(" "),
|
|
167
|
+
estimatedVendor,
|
|
168
|
+
estimatedProduct
|
|
169
|
+
};
|
|
170
|
+
return mcpServerDetection;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (mcpServerDetection) {
|
|
176
|
+
return mcpServerDetection;
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
} catch (error) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
getVendorFromCommand(commandTokens) {
|
|
184
|
+
const commandString = commandTokens.join(" ").toLowerCase();
|
|
185
|
+
if (commandString.includes("claude.app")) {
|
|
186
|
+
return {
|
|
187
|
+
estimatedVendor: "anthropic",
|
|
188
|
+
estimatedProduct: "claude-desktop"
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
if (commandString.includes("claude")) {
|
|
192
|
+
return {
|
|
193
|
+
estimatedVendor: "anthropic",
|
|
194
|
+
estimatedProduct: "claude-desktop"
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
isCommandMatch(commandTokens, pid, ppid) {
|
|
199
|
+
if (commandTokens.length === 0) return false;
|
|
200
|
+
const baseCommand = this.getBaseCommand(commandTokens[0]);
|
|
201
|
+
if (this.command === "uvx" && baseCommand === "uv") {
|
|
202
|
+
return this.matchUvxProcess(commandTokens);
|
|
203
|
+
}
|
|
204
|
+
if (this.command === "npx" && baseCommand === "npm") {
|
|
205
|
+
return this.matchNpxProcess(commandTokens);
|
|
206
|
+
}
|
|
207
|
+
if (this.command === "uv" && baseCommand === "uv") {
|
|
208
|
+
return this.matchGenericArgsToArgs(commandTokens);
|
|
209
|
+
}
|
|
210
|
+
const commandConfigPythonBase = this.getBaseCommand(this.command);
|
|
211
|
+
const commandAliasesPython = ["python3", "python", "python3.10", "python3.11", "python3.12", "cpython3", "cpython", "python3", "python2"];
|
|
212
|
+
if (commandAliasesPython.includes(commandConfigPythonBase) && commandAliasesPython.includes(baseCommand)) {
|
|
213
|
+
return this.matchGenericArgsToArgs(commandTokens);
|
|
214
|
+
}
|
|
215
|
+
const commandGenericBase = this.getBaseCommand(this.command);
|
|
216
|
+
const commandGenericProcessBase = this.getBaseCommand(commandTokens[0]);
|
|
217
|
+
if (commandGenericBase === commandGenericProcessBase) {
|
|
218
|
+
return this.matchGenericArgsToArgs(commandTokens);
|
|
219
|
+
}
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
matchGenericArgsToArgs(commandTokens) {
|
|
223
|
+
if (this.args.length === 0) {
|
|
224
|
+
return commandTokens[0] === this.command;
|
|
225
|
+
}
|
|
226
|
+
if (commandTokens.length < 2) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
const commandWithoutArgs = commandTokens.slice(1);
|
|
230
|
+
for (let i = 0; i < this.args.length; i++) {
|
|
231
|
+
if (i >= commandWithoutArgs.length) return false;
|
|
232
|
+
const arg = this.args[i];
|
|
233
|
+
const token = commandWithoutArgs[i];
|
|
234
|
+
if (arg !== token && !token.includes(arg)) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
// @TODO refactor this to use path.basename or similar
|
|
241
|
+
// to extract the base command from the full command path
|
|
242
|
+
getBaseCommand(fullCommandPath) {
|
|
243
|
+
const parts = fullCommandPath.split(/[/\\]/);
|
|
244
|
+
return parts[parts.length - 1];
|
|
245
|
+
}
|
|
246
|
+
/*
|
|
247
|
+
example1:
|
|
248
|
+
```
|
|
249
|
+
"command": "uvx",
|
|
250
|
+
"args": ["--from", "mcp-alchemy==2025.5.2.210242", "--with", "oracledb",
|
|
251
|
+
"--refresh-package", "mcp-alchemy", "mcp-alchemy"],
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
example 2:
|
|
255
|
+
```
|
|
256
|
+
"command": "uvx",
|
|
257
|
+
"args": [
|
|
258
|
+
"mcp-neo4j-memory@0.1.4",
|
|
259
|
+
"--db-url",
|
|
260
|
+
"neo4j+s://xxxx.databases.neo4j.io",
|
|
261
|
+
"--username",
|
|
262
|
+
"<your-username>",
|
|
263
|
+
"--password",
|
|
264
|
+
"<your-password>"
|
|
265
|
+
]
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
example 3:
|
|
269
|
+
```
|
|
270
|
+
"vefaas": {
|
|
271
|
+
"command": "uvx",
|
|
272
|
+
"args": [
|
|
273
|
+
"--from",
|
|
274
|
+
"git+https://github.com/volcengine/mcp-server#subdirectory=server/mcp_server_vefaas_function",
|
|
275
|
+
"mcp-server-vefaas-function"
|
|
276
|
+
],
|
|
277
|
+
"env": {
|
|
278
|
+
"VOLC_ACCESSKEY": "xxx",
|
|
279
|
+
"VOLC_SECRETKEY": "xxx"
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
example 4:
|
|
286
|
+
```
|
|
287
|
+
"time": {
|
|
288
|
+
"command": "uvx",
|
|
289
|
+
"args": ["mcp-server-time", "--local-timezone=America/New_York"]
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
*/
|
|
293
|
+
getUvxMcpServerNameFromArgs() {
|
|
294
|
+
if (this.args.length === 0) return void 0;
|
|
295
|
+
let mcpServerName;
|
|
296
|
+
if (this.args.length === 1) {
|
|
297
|
+
mcpServerName = this.args[0];
|
|
298
|
+
return mcpServerName;
|
|
299
|
+
}
|
|
300
|
+
for (let i = 0; i < this.args.length; i++) {
|
|
301
|
+
if (this.args[i] === "--from" && i + 1 < this.args.length) {
|
|
302
|
+
mcpServerName = this.args[i + 1];
|
|
303
|
+
return mcpServerName;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
const firstArg = this.args[0];
|
|
307
|
+
if (firstArg.startsWith("-") || firstArg.startsWith("--")) {
|
|
308
|
+
const lastArg = this.args[this.args.length - 1];
|
|
309
|
+
mcpServerName = lastArg;
|
|
310
|
+
return mcpServerName;
|
|
311
|
+
}
|
|
312
|
+
mcpServerName = firstArg;
|
|
313
|
+
return mcpServerName;
|
|
314
|
+
}
|
|
315
|
+
matchUvxProcess(commandTokens) {
|
|
316
|
+
if (commandTokens.length === 0) return false;
|
|
317
|
+
const mcpServerName = this.getUvxMcpServerNameFromArgs();
|
|
318
|
+
if (!mcpServerName) return false;
|
|
319
|
+
return this.findMcpServerNameInProcessArguments(commandTokens, mcpServerName);
|
|
320
|
+
}
|
|
321
|
+
findMcpServerNameInProcessArguments(commandTokens, mcpServerName) {
|
|
322
|
+
for (let i = 0; i < commandTokens.length; i++) {
|
|
323
|
+
const token = commandTokens[i];
|
|
324
|
+
if (mcpServerName === token || token.includes(mcpServerName)) {
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
parseCommandLine(commandLine) {
|
|
331
|
+
const tokens = [];
|
|
332
|
+
let current = "";
|
|
333
|
+
let inQuotes = false;
|
|
334
|
+
let quoteChar = "";
|
|
335
|
+
for (let i = 0; i < commandLine.length; i++) {
|
|
336
|
+
const char = commandLine[i];
|
|
337
|
+
if (!inQuotes && (char === '"' || char === "'")) {
|
|
338
|
+
inQuotes = true;
|
|
339
|
+
quoteChar = char;
|
|
340
|
+
} else if (inQuotes && char === quoteChar) {
|
|
341
|
+
inQuotes = false;
|
|
342
|
+
quoteChar = "";
|
|
343
|
+
} else if (!inQuotes && char === " ") {
|
|
344
|
+
if (current.trim()) {
|
|
345
|
+
tokens.push(current.trim());
|
|
346
|
+
current = "";
|
|
347
|
+
}
|
|
348
|
+
} else {
|
|
349
|
+
current += char;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (current.trim()) {
|
|
353
|
+
tokens.push(current.trim());
|
|
354
|
+
}
|
|
355
|
+
return tokens;
|
|
356
|
+
}
|
|
357
|
+
/*
|
|
358
|
+
example to match:
|
|
359
|
+
```
|
|
360
|
+
"command": "npx",
|
|
361
|
+
"args": [
|
|
362
|
+
"-y",
|
|
363
|
+
"@modelcontextprotocol/server-postgres",
|
|
364
|
+
"postgresql://localhost/mydb"
|
|
365
|
+
]
|
|
366
|
+
}
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
with a process command like:
|
|
370
|
+
```
|
|
371
|
+
npm exec @modelcontextprotocol/server-postgres postgresql://localhost/mydb
|
|
372
|
+
```
|
|
373
|
+
*/
|
|
374
|
+
matchNpxProcess(commandTokens) {
|
|
375
|
+
if (commandTokens.length < 3) return false;
|
|
376
|
+
if (commandTokens[1] !== "exec") return false;
|
|
377
|
+
let argsToMatch = [];
|
|
378
|
+
const yIndex = this.args.indexOf("-y");
|
|
379
|
+
if (yIndex !== -1 && yIndex + 1 < this.args.length) {
|
|
380
|
+
argsToMatch = this.args.slice(yIndex + 1);
|
|
381
|
+
} else {
|
|
382
|
+
argsToMatch = this.args;
|
|
383
|
+
}
|
|
384
|
+
if (commandTokens.length - 2 !== argsToMatch.length) {
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
for (let i = 0; i < argsToMatch.length; i++) {
|
|
388
|
+
const commandToken = commandTokens[i + 2];
|
|
389
|
+
const expectedArg = argsToMatch[i];
|
|
390
|
+
if (commandToken !== expectedArg) {
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return true;
|
|
113
395
|
}
|
|
114
396
|
};
|
|
115
397
|
|
|
@@ -120,7 +402,7 @@ var MCPFiles = class {
|
|
|
120
402
|
}
|
|
121
403
|
mcpFilePathGroups = {
|
|
122
404
|
claude: {
|
|
123
|
-
name: "claude",
|
|
405
|
+
name: "claude-desktop",
|
|
124
406
|
friendlyName: "Claude Desktop",
|
|
125
407
|
paths: [
|
|
126
408
|
{ filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
|
|
@@ -130,8 +412,8 @@ var MCPFiles = class {
|
|
|
130
412
|
name: "cursor",
|
|
131
413
|
friendlyName: "Cursor",
|
|
132
414
|
paths: [
|
|
133
|
-
{ filePath: "
|
|
134
|
-
{ filePath: "
|
|
415
|
+
{ filePath: "~/.cursor/mcp.json", type: "global" },
|
|
416
|
+
{ filePath: ".cursor/mcp.json", type: "local" }
|
|
135
417
|
]
|
|
136
418
|
}
|
|
137
419
|
};
|
|
@@ -167,13 +449,20 @@ var MCPFiles = class {
|
|
|
167
449
|
env: serverConfigRaw.env
|
|
168
450
|
};
|
|
169
451
|
const MCPServerManager = new MCPServerManagerService(serverConfig);
|
|
452
|
+
const mcpServerProcessDetection = MCPServerManager.isRunning();
|
|
453
|
+
let mcpServerProcess = false;
|
|
454
|
+
if (mcpServerProcessDetection) {
|
|
455
|
+
if (typeof mcpServerProcessDetection === "object" && mcpServerProcessDetection.estimatedProduct === clientsGroup.name) {
|
|
456
|
+
mcpServerProcess = true;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
170
459
|
mcpServersData.push({
|
|
171
460
|
name: MCPServerManager.getName(),
|
|
172
461
|
command: MCPServerManager.getCmd(),
|
|
173
462
|
args: MCPServerManager.getArgs(),
|
|
174
463
|
transport: MCPServerManager.getTransport(),
|
|
175
464
|
env: MCPServerManager.getEnv(),
|
|
176
|
-
status:
|
|
465
|
+
status: mcpServerProcess ? "running" : "stopped"
|
|
177
466
|
});
|
|
178
467
|
}
|
|
179
468
|
filePathData.servers = mcpServersData;
|
package/dist/main.mjs
CHANGED
|
@@ -44,6 +44,8 @@ var MCPConfigLinterService = class {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
// src/services/mcp-server-manager-service.ts
|
|
47
|
+
import { execSync } from "child_process";
|
|
48
|
+
import { platform } from "os";
|
|
47
49
|
var MCPServerManagerService = class {
|
|
48
50
|
static {
|
|
49
51
|
__name(this, "MCPServerManagerService");
|
|
@@ -77,7 +79,287 @@ var MCPServerManagerService = class {
|
|
|
77
79
|
return this.env;
|
|
78
80
|
}
|
|
79
81
|
isRunning() {
|
|
80
|
-
|
|
82
|
+
try {
|
|
83
|
+
let psOutput;
|
|
84
|
+
if (platform() === "win32") {
|
|
85
|
+
psOutput = execSync("wmic process get ProcessId,ParentProcessId,CommandLine /format:csv", {
|
|
86
|
+
encoding: "utf8",
|
|
87
|
+
timeout: 5e3
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
psOutput = execSync("ps -eao pid,ppid,args", {
|
|
91
|
+
encoding: "utf8",
|
|
92
|
+
timeout: 5e3
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const processMap = /* @__PURE__ */ new Map();
|
|
96
|
+
const processes = psOutput.trim().split("\n");
|
|
97
|
+
for (const processLine of processes) {
|
|
98
|
+
if (!processLine.trim()) continue;
|
|
99
|
+
let pid;
|
|
100
|
+
let ppid;
|
|
101
|
+
let commandLine;
|
|
102
|
+
if (platform() === "win32") {
|
|
103
|
+
const parts = processLine.split(",");
|
|
104
|
+
if (parts.length < 4) continue;
|
|
105
|
+
commandLine = parts[1] || "";
|
|
106
|
+
ppid = parts[2] || "";
|
|
107
|
+
pid = parts[3] || "";
|
|
108
|
+
} else {
|
|
109
|
+
const match = processLine.trim().match(/^\s*(\d+)\s+(\d+)\s+(.+)$/);
|
|
110
|
+
if (!match) continue;
|
|
111
|
+
pid = match[1];
|
|
112
|
+
ppid = match[2];
|
|
113
|
+
commandLine = match[3];
|
|
114
|
+
}
|
|
115
|
+
const commandTokens = this.parseCommandLine(commandLine);
|
|
116
|
+
if (commandTokens.length > 0) {
|
|
117
|
+
processMap.set(pid, { ppid, commandTokens });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
let mcpServerDetection;
|
|
121
|
+
for (const [pid, processData] of processMap) {
|
|
122
|
+
if (this.isCommandMatch(processData.commandTokens, pid, processData.ppid)) {
|
|
123
|
+
mcpServerDetection = {
|
|
124
|
+
pid,
|
|
125
|
+
commandLine: processData.commandTokens.join(" "),
|
|
126
|
+
ppid: processData.ppid
|
|
127
|
+
};
|
|
128
|
+
const parentProcess = processMap.get(processData.ppid);
|
|
129
|
+
if (parentProcess) {
|
|
130
|
+
const { estimatedVendor, estimatedProduct } = this.getVendorFromCommand(parentProcess.commandTokens) || {};
|
|
131
|
+
if (estimatedProduct || estimatedVendor) {
|
|
132
|
+
mcpServerDetection = {
|
|
133
|
+
...mcpServerDetection,
|
|
134
|
+
parentCommandLine: parentProcess.commandTokens.join(" "),
|
|
135
|
+
estimatedVendor,
|
|
136
|
+
estimatedProduct
|
|
137
|
+
};
|
|
138
|
+
return mcpServerDetection;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (mcpServerDetection) {
|
|
144
|
+
return mcpServerDetection;
|
|
145
|
+
}
|
|
146
|
+
return false;
|
|
147
|
+
} catch (error) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
getVendorFromCommand(commandTokens) {
|
|
152
|
+
const commandString = commandTokens.join(" ").toLowerCase();
|
|
153
|
+
if (commandString.includes("claude.app")) {
|
|
154
|
+
return {
|
|
155
|
+
estimatedVendor: "anthropic",
|
|
156
|
+
estimatedProduct: "claude-desktop"
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (commandString.includes("claude")) {
|
|
160
|
+
return {
|
|
161
|
+
estimatedVendor: "anthropic",
|
|
162
|
+
estimatedProduct: "claude-desktop"
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
isCommandMatch(commandTokens, pid, ppid) {
|
|
167
|
+
if (commandTokens.length === 0) return false;
|
|
168
|
+
const baseCommand = this.getBaseCommand(commandTokens[0]);
|
|
169
|
+
if (this.command === "uvx" && baseCommand === "uv") {
|
|
170
|
+
return this.matchUvxProcess(commandTokens);
|
|
171
|
+
}
|
|
172
|
+
if (this.command === "npx" && baseCommand === "npm") {
|
|
173
|
+
return this.matchNpxProcess(commandTokens);
|
|
174
|
+
}
|
|
175
|
+
if (this.command === "uv" && baseCommand === "uv") {
|
|
176
|
+
return this.matchGenericArgsToArgs(commandTokens);
|
|
177
|
+
}
|
|
178
|
+
const commandConfigPythonBase = this.getBaseCommand(this.command);
|
|
179
|
+
const commandAliasesPython = ["python3", "python", "python3.10", "python3.11", "python3.12", "cpython3", "cpython", "python3", "python2"];
|
|
180
|
+
if (commandAliasesPython.includes(commandConfigPythonBase) && commandAliasesPython.includes(baseCommand)) {
|
|
181
|
+
return this.matchGenericArgsToArgs(commandTokens);
|
|
182
|
+
}
|
|
183
|
+
const commandGenericBase = this.getBaseCommand(this.command);
|
|
184
|
+
const commandGenericProcessBase = this.getBaseCommand(commandTokens[0]);
|
|
185
|
+
if (commandGenericBase === commandGenericProcessBase) {
|
|
186
|
+
return this.matchGenericArgsToArgs(commandTokens);
|
|
187
|
+
}
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
matchGenericArgsToArgs(commandTokens) {
|
|
191
|
+
if (this.args.length === 0) {
|
|
192
|
+
return commandTokens[0] === this.command;
|
|
193
|
+
}
|
|
194
|
+
if (commandTokens.length < 2) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
const commandWithoutArgs = commandTokens.slice(1);
|
|
198
|
+
for (let i = 0; i < this.args.length; i++) {
|
|
199
|
+
if (i >= commandWithoutArgs.length) return false;
|
|
200
|
+
const arg = this.args[i];
|
|
201
|
+
const token = commandWithoutArgs[i];
|
|
202
|
+
if (arg !== token && !token.includes(arg)) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
// @TODO refactor this to use path.basename or similar
|
|
209
|
+
// to extract the base command from the full command path
|
|
210
|
+
getBaseCommand(fullCommandPath) {
|
|
211
|
+
const parts = fullCommandPath.split(/[/\\]/);
|
|
212
|
+
return parts[parts.length - 1];
|
|
213
|
+
}
|
|
214
|
+
/*
|
|
215
|
+
example1:
|
|
216
|
+
```
|
|
217
|
+
"command": "uvx",
|
|
218
|
+
"args": ["--from", "mcp-alchemy==2025.5.2.210242", "--with", "oracledb",
|
|
219
|
+
"--refresh-package", "mcp-alchemy", "mcp-alchemy"],
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
example 2:
|
|
223
|
+
```
|
|
224
|
+
"command": "uvx",
|
|
225
|
+
"args": [
|
|
226
|
+
"mcp-neo4j-memory@0.1.4",
|
|
227
|
+
"--db-url",
|
|
228
|
+
"neo4j+s://xxxx.databases.neo4j.io",
|
|
229
|
+
"--username",
|
|
230
|
+
"<your-username>",
|
|
231
|
+
"--password",
|
|
232
|
+
"<your-password>"
|
|
233
|
+
]
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
example 3:
|
|
237
|
+
```
|
|
238
|
+
"vefaas": {
|
|
239
|
+
"command": "uvx",
|
|
240
|
+
"args": [
|
|
241
|
+
"--from",
|
|
242
|
+
"git+https://github.com/volcengine/mcp-server#subdirectory=server/mcp_server_vefaas_function",
|
|
243
|
+
"mcp-server-vefaas-function"
|
|
244
|
+
],
|
|
245
|
+
"env": {
|
|
246
|
+
"VOLC_ACCESSKEY": "xxx",
|
|
247
|
+
"VOLC_SECRETKEY": "xxx"
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
example 4:
|
|
254
|
+
```
|
|
255
|
+
"time": {
|
|
256
|
+
"command": "uvx",
|
|
257
|
+
"args": ["mcp-server-time", "--local-timezone=America/New_York"]
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
*/
|
|
261
|
+
getUvxMcpServerNameFromArgs() {
|
|
262
|
+
if (this.args.length === 0) return void 0;
|
|
263
|
+
let mcpServerName;
|
|
264
|
+
if (this.args.length === 1) {
|
|
265
|
+
mcpServerName = this.args[0];
|
|
266
|
+
return mcpServerName;
|
|
267
|
+
}
|
|
268
|
+
for (let i = 0; i < this.args.length; i++) {
|
|
269
|
+
if (this.args[i] === "--from" && i + 1 < this.args.length) {
|
|
270
|
+
mcpServerName = this.args[i + 1];
|
|
271
|
+
return mcpServerName;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const firstArg = this.args[0];
|
|
275
|
+
if (firstArg.startsWith("-") || firstArg.startsWith("--")) {
|
|
276
|
+
const lastArg = this.args[this.args.length - 1];
|
|
277
|
+
mcpServerName = lastArg;
|
|
278
|
+
return mcpServerName;
|
|
279
|
+
}
|
|
280
|
+
mcpServerName = firstArg;
|
|
281
|
+
return mcpServerName;
|
|
282
|
+
}
|
|
283
|
+
matchUvxProcess(commandTokens) {
|
|
284
|
+
if (commandTokens.length === 0) return false;
|
|
285
|
+
const mcpServerName = this.getUvxMcpServerNameFromArgs();
|
|
286
|
+
if (!mcpServerName) return false;
|
|
287
|
+
return this.findMcpServerNameInProcessArguments(commandTokens, mcpServerName);
|
|
288
|
+
}
|
|
289
|
+
findMcpServerNameInProcessArguments(commandTokens, mcpServerName) {
|
|
290
|
+
for (let i = 0; i < commandTokens.length; i++) {
|
|
291
|
+
const token = commandTokens[i];
|
|
292
|
+
if (mcpServerName === token || token.includes(mcpServerName)) {
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
parseCommandLine(commandLine) {
|
|
299
|
+
const tokens = [];
|
|
300
|
+
let current = "";
|
|
301
|
+
let inQuotes = false;
|
|
302
|
+
let quoteChar = "";
|
|
303
|
+
for (let i = 0; i < commandLine.length; i++) {
|
|
304
|
+
const char = commandLine[i];
|
|
305
|
+
if (!inQuotes && (char === '"' || char === "'")) {
|
|
306
|
+
inQuotes = true;
|
|
307
|
+
quoteChar = char;
|
|
308
|
+
} else if (inQuotes && char === quoteChar) {
|
|
309
|
+
inQuotes = false;
|
|
310
|
+
quoteChar = "";
|
|
311
|
+
} else if (!inQuotes && char === " ") {
|
|
312
|
+
if (current.trim()) {
|
|
313
|
+
tokens.push(current.trim());
|
|
314
|
+
current = "";
|
|
315
|
+
}
|
|
316
|
+
} else {
|
|
317
|
+
current += char;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (current.trim()) {
|
|
321
|
+
tokens.push(current.trim());
|
|
322
|
+
}
|
|
323
|
+
return tokens;
|
|
324
|
+
}
|
|
325
|
+
/*
|
|
326
|
+
example to match:
|
|
327
|
+
```
|
|
328
|
+
"command": "npx",
|
|
329
|
+
"args": [
|
|
330
|
+
"-y",
|
|
331
|
+
"@modelcontextprotocol/server-postgres",
|
|
332
|
+
"postgresql://localhost/mydb"
|
|
333
|
+
]
|
|
334
|
+
}
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
with a process command like:
|
|
338
|
+
```
|
|
339
|
+
npm exec @modelcontextprotocol/server-postgres postgresql://localhost/mydb
|
|
340
|
+
```
|
|
341
|
+
*/
|
|
342
|
+
matchNpxProcess(commandTokens) {
|
|
343
|
+
if (commandTokens.length < 3) return false;
|
|
344
|
+
if (commandTokens[1] !== "exec") return false;
|
|
345
|
+
let argsToMatch = [];
|
|
346
|
+
const yIndex = this.args.indexOf("-y");
|
|
347
|
+
if (yIndex !== -1 && yIndex + 1 < this.args.length) {
|
|
348
|
+
argsToMatch = this.args.slice(yIndex + 1);
|
|
349
|
+
} else {
|
|
350
|
+
argsToMatch = this.args;
|
|
351
|
+
}
|
|
352
|
+
if (commandTokens.length - 2 !== argsToMatch.length) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
for (let i = 0; i < argsToMatch.length; i++) {
|
|
356
|
+
const commandToken = commandTokens[i + 2];
|
|
357
|
+
const expectedArg = argsToMatch[i];
|
|
358
|
+
if (commandToken !== expectedArg) {
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return true;
|
|
81
363
|
}
|
|
82
364
|
};
|
|
83
365
|
|
|
@@ -88,7 +370,7 @@ var MCPFiles = class {
|
|
|
88
370
|
}
|
|
89
371
|
mcpFilePathGroups = {
|
|
90
372
|
claude: {
|
|
91
|
-
name: "claude",
|
|
373
|
+
name: "claude-desktop",
|
|
92
374
|
friendlyName: "Claude Desktop",
|
|
93
375
|
paths: [
|
|
94
376
|
{ filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
|
|
@@ -98,8 +380,8 @@ var MCPFiles = class {
|
|
|
98
380
|
name: "cursor",
|
|
99
381
|
friendlyName: "Cursor",
|
|
100
382
|
paths: [
|
|
101
|
-
{ filePath: "
|
|
102
|
-
{ filePath: "
|
|
383
|
+
{ filePath: "~/.cursor/mcp.json", type: "global" },
|
|
384
|
+
{ filePath: ".cursor/mcp.json", type: "local" }
|
|
103
385
|
]
|
|
104
386
|
}
|
|
105
387
|
};
|
|
@@ -135,13 +417,20 @@ var MCPFiles = class {
|
|
|
135
417
|
env: serverConfigRaw.env
|
|
136
418
|
};
|
|
137
419
|
const MCPServerManager = new MCPServerManagerService(serverConfig);
|
|
420
|
+
const mcpServerProcessDetection = MCPServerManager.isRunning();
|
|
421
|
+
let mcpServerProcess = false;
|
|
422
|
+
if (mcpServerProcessDetection) {
|
|
423
|
+
if (typeof mcpServerProcessDetection === "object" && mcpServerProcessDetection.estimatedProduct === clientsGroup.name) {
|
|
424
|
+
mcpServerProcess = true;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
138
427
|
mcpServersData.push({
|
|
139
428
|
name: MCPServerManager.getName(),
|
|
140
429
|
command: MCPServerManager.getCmd(),
|
|
141
430
|
args: MCPServerManager.getArgs(),
|
|
142
431
|
transport: MCPServerManager.getTransport(),
|
|
143
432
|
env: MCPServerManager.getEnv(),
|
|
144
|
-
status:
|
|
433
|
+
status: mcpServerProcess ? "running" : "stopped"
|
|
145
434
|
});
|
|
146
435
|
}
|
|
147
436
|
filePathData.servers = mcpServersData;
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ls-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "list and detect MCP servers and configurations",
|
|
5
5
|
"types": "dist/main.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"bin":
|
|
7
|
+
"bin": {
|
|
8
|
+
"ls-mcp": "./dist/bin/cli.cjs"
|
|
9
|
+
},
|
|
8
10
|
"exports": {
|
|
9
11
|
".": {
|
|
10
12
|
"import": {
|
|
@@ -33,7 +35,7 @@
|
|
|
33
35
|
"bin"
|
|
34
36
|
],
|
|
35
37
|
"scripts": {
|
|
36
|
-
"start": "node --import tsx src/bin/cli.ts",
|
|
38
|
+
"start": "npm run build && node --import tsx src/bin/cli.ts",
|
|
37
39
|
"build": "tsc && tsup",
|
|
38
40
|
"lint": "eslint . && npm run lint:lockfile",
|
|
39
41
|
"lint:fix": "eslint . --fix",
|