ls-mcp 1.1.0 → 1.2.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 +377 -28
- package/dist/bin/cli.d.cts +2 -1
- package/dist/bin/cli.d.ts +2 -1
- package/dist/bin/cli.mjs +377 -28
- package/dist/main.cjs +140 -16
- package/dist/main.d.cts +35 -3
- package/dist/main.d.ts +35 -3
- package/dist/main.mjs +140 -16
- package/package.json +9 -8
- package/src/bin/cli.ts +60 -13
- package/src/components/column-name.ts +8 -0
- package/src/components/file-path.ts +8 -0
- package/src/components/mcp-server-name.ts +9 -0
- package/src/components/mcp-server-status.ts +13 -0
- package/src/components/mcp-servers-config-parsable.ts +13 -0
- package/src/components/transport.ts +15 -0
- package/src/main.ts +110 -22
- package/src/services/mcp-config-linter-service.ts +43 -0
- package/src/services/mcp-server-manager-service.ts +49 -0
- package/src/services/render-service.ts +188 -0
- package/src/utils/formatter-service.ts +7 -0
package/dist/bin/cli.mjs
CHANGED
|
@@ -1,53 +1,402 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
3
|
|
|
5
|
-
// src/bin/cli.ts
|
|
6
|
-
import { debuglog } from "util";
|
|
7
|
-
|
|
8
4
|
// src/main.ts
|
|
5
|
+
import fs2 from "fs/promises";
|
|
6
|
+
|
|
7
|
+
// src/services/mcp-config-linter-service.ts
|
|
9
8
|
import fs from "fs/promises";
|
|
9
|
+
var MCPConfigLinterService = class {
|
|
10
|
+
static {
|
|
11
|
+
__name(this, "MCPConfigLinterService");
|
|
12
|
+
}
|
|
13
|
+
filePath;
|
|
14
|
+
fileContents = null;
|
|
15
|
+
constructor(filePath) {
|
|
16
|
+
this.filePath = filePath;
|
|
17
|
+
}
|
|
18
|
+
async isValidSyntax() {
|
|
19
|
+
try {
|
|
20
|
+
const fileContent = await this.getFileContent();
|
|
21
|
+
JSON.parse(fileContent);
|
|
22
|
+
return true;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async countMCPServers() {
|
|
28
|
+
const mcpServers = await this.getMCPServers();
|
|
29
|
+
return Object.keys(mcpServers).length;
|
|
30
|
+
}
|
|
31
|
+
async getMCPServers() {
|
|
32
|
+
const fileContentRaw = await this.getFileContent();
|
|
33
|
+
const fileContentsData = JSON.parse(fileContentRaw);
|
|
34
|
+
const mcpServers = fileContentsData?.mcpServers;
|
|
35
|
+
return mcpServers;
|
|
36
|
+
}
|
|
37
|
+
async getFileContent() {
|
|
38
|
+
if (this.fileContents) {
|
|
39
|
+
return this.fileContents;
|
|
40
|
+
}
|
|
41
|
+
this.fileContents = await fs.readFile(this.filePath, "utf-8");
|
|
42
|
+
return this.fileContents;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// src/services/mcp-server-manager-service.ts
|
|
47
|
+
var MCPServerManagerService = class {
|
|
48
|
+
static {
|
|
49
|
+
__name(this, "MCPServerManagerService");
|
|
50
|
+
}
|
|
51
|
+
name;
|
|
52
|
+
command;
|
|
53
|
+
args;
|
|
54
|
+
transport;
|
|
55
|
+
env;
|
|
56
|
+
running = false;
|
|
57
|
+
constructor(serverConfig) {
|
|
58
|
+
this.name = serverConfig.name;
|
|
59
|
+
this.command = serverConfig.command;
|
|
60
|
+
this.args = serverConfig.args || [];
|
|
61
|
+
this.transport = serverConfig.transport || "stdio";
|
|
62
|
+
this.env = serverConfig.env || {};
|
|
63
|
+
}
|
|
64
|
+
getName() {
|
|
65
|
+
return this.name;
|
|
66
|
+
}
|
|
67
|
+
getCmd() {
|
|
68
|
+
return this.command;
|
|
69
|
+
}
|
|
70
|
+
getArgs() {
|
|
71
|
+
return this.args;
|
|
72
|
+
}
|
|
73
|
+
getTransport() {
|
|
74
|
+
return this.transport;
|
|
75
|
+
}
|
|
76
|
+
getEnv() {
|
|
77
|
+
return this.env;
|
|
78
|
+
}
|
|
79
|
+
isRunning() {
|
|
80
|
+
return this.running;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// src/main.ts
|
|
10
85
|
var MCPFiles = class {
|
|
11
86
|
static {
|
|
12
87
|
__name(this, "MCPFiles");
|
|
13
88
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
89
|
+
mcpFilePathGroups = {
|
|
90
|
+
claude: {
|
|
91
|
+
name: "claude",
|
|
92
|
+
friendlyName: "Claude Desktop",
|
|
93
|
+
paths: [
|
|
94
|
+
{ filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
cursor: {
|
|
98
|
+
name: "cursor",
|
|
99
|
+
friendlyName: "Cursor",
|
|
100
|
+
paths: [
|
|
101
|
+
{ filePath: ".cursor/mcp.json", type: "local" },
|
|
102
|
+
{ filePath: "~/.cursor/mcp.json", type: "global" }
|
|
103
|
+
]
|
|
22
104
|
}
|
|
105
|
+
};
|
|
106
|
+
constructor(mcpFilePathGroups) {
|
|
107
|
+
this.mcpFilePathGroups = mcpFilePathGroups || this.mcpFilePathGroups;
|
|
23
108
|
}
|
|
24
109
|
async findFiles() {
|
|
25
|
-
const
|
|
26
|
-
for (const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
110
|
+
const mcpFilesPathsData = {};
|
|
111
|
+
for (const groupName of Object.keys(this.mcpFilePathGroups)) {
|
|
112
|
+
const clientsGroup = this.mcpFilePathGroups[groupName];
|
|
113
|
+
mcpFilesPathsData[groupName] = {
|
|
114
|
+
name: clientsGroup.name,
|
|
115
|
+
friendlyName: clientsGroup.friendlyName,
|
|
116
|
+
paths: [],
|
|
117
|
+
stats: {}
|
|
118
|
+
};
|
|
119
|
+
for (const filePathData of clientsGroup.paths) {
|
|
120
|
+
const resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
121
|
+
try {
|
|
122
|
+
await fs2.access(resolvedPath);
|
|
123
|
+
const MCPConfigLinter = new MCPConfigLinterService(resolvedPath);
|
|
124
|
+
const parsable = await MCPConfigLinter.isValidSyntax();
|
|
125
|
+
filePathData.parsable = parsable;
|
|
126
|
+
const mcpServersData = [];
|
|
127
|
+
const mcpServersFromConfig = await MCPConfigLinter.getMCPServers();
|
|
128
|
+
for (const serverName of Object.keys(mcpServersFromConfig)) {
|
|
129
|
+
const serverConfigRaw = mcpServersFromConfig[serverName];
|
|
130
|
+
const serverConfig = {
|
|
131
|
+
name: serverName,
|
|
132
|
+
command: serverConfigRaw.command || "",
|
|
133
|
+
args: serverConfigRaw.args,
|
|
134
|
+
transport: serverConfigRaw.transport,
|
|
135
|
+
env: serverConfigRaw.env
|
|
136
|
+
};
|
|
137
|
+
const MCPServerManager = new MCPServerManagerService(serverConfig);
|
|
138
|
+
mcpServersData.push({
|
|
139
|
+
name: MCPServerManager.getName(),
|
|
140
|
+
command: MCPServerManager.getCmd(),
|
|
141
|
+
args: MCPServerManager.getArgs(),
|
|
142
|
+
transport: MCPServerManager.getTransport(),
|
|
143
|
+
env: MCPServerManager.getEnv(),
|
|
144
|
+
status: MCPServerManager.isRunning() ? "running" : "stopped"
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
filePathData.servers = mcpServersData;
|
|
148
|
+
mcpFilesPathsData[groupName]["stats"]["serversCount"] = await MCPConfigLinter.countMCPServers();
|
|
149
|
+
mcpFilesPathsData[groupName].paths.push(filePathData);
|
|
150
|
+
} catch (error) {
|
|
151
|
+
}
|
|
32
152
|
}
|
|
33
153
|
}
|
|
34
|
-
return
|
|
154
|
+
return mcpFilesPathsData;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// src/services/render-service.ts
|
|
159
|
+
import { styleText as styleText7 } from "util";
|
|
160
|
+
|
|
161
|
+
// src/components/transport.ts
|
|
162
|
+
import { styleText } from "util";
|
|
163
|
+
function render(text) {
|
|
164
|
+
const formattedText = text.toUpperCase();
|
|
165
|
+
let data = "";
|
|
166
|
+
if (formattedText === "STDIO") {
|
|
167
|
+
data = styleText(["magenta"], formattedText);
|
|
168
|
+
}
|
|
169
|
+
if (formattedText === "SSE") {
|
|
170
|
+
data = styleText(["blue"], formattedText);
|
|
171
|
+
}
|
|
172
|
+
return data;
|
|
173
|
+
}
|
|
174
|
+
__name(render, "render");
|
|
175
|
+
|
|
176
|
+
// src/components/column-name.ts
|
|
177
|
+
import { styleText as styleText2 } from "util";
|
|
178
|
+
function render2(text) {
|
|
179
|
+
const formattedText = String(text).toUpperCase();
|
|
180
|
+
const data = styleText2(["dim"], formattedText);
|
|
181
|
+
return data;
|
|
182
|
+
}
|
|
183
|
+
__name(render2, "render");
|
|
184
|
+
|
|
185
|
+
// src/components/mcp-server-status.ts
|
|
186
|
+
import { styleText as styleText3 } from "util";
|
|
187
|
+
function render3(text) {
|
|
188
|
+
const formattedText = text.toLowerCase();
|
|
189
|
+
let data = "";
|
|
190
|
+
if (formattedText === "running") {
|
|
191
|
+
data = styleText3(["green"], "\u25CF");
|
|
192
|
+
} else {
|
|
193
|
+
data = styleText3(["red"], "\u25CB");
|
|
194
|
+
}
|
|
195
|
+
return data;
|
|
196
|
+
}
|
|
197
|
+
__name(render3, "render");
|
|
198
|
+
|
|
199
|
+
// src/components/mcp-server-name.ts
|
|
200
|
+
import { styleText as styleText4 } from "util";
|
|
201
|
+
function render4(text) {
|
|
202
|
+
const formattedText = text.toLowerCase();
|
|
203
|
+
const data = styleText4(["bold", "white"], formattedText);
|
|
204
|
+
return data;
|
|
205
|
+
}
|
|
206
|
+
__name(render4, "render");
|
|
207
|
+
|
|
208
|
+
// src/components/file-path.ts
|
|
209
|
+
import { styleText as styleText5 } from "util";
|
|
210
|
+
function render5(text) {
|
|
211
|
+
const formattedText = text;
|
|
212
|
+
const data = styleText5(["underline"], formattedText);
|
|
213
|
+
return data;
|
|
214
|
+
}
|
|
215
|
+
__name(render5, "render");
|
|
216
|
+
|
|
217
|
+
// src/components/mcp-servers-config-parsable.ts
|
|
218
|
+
import { styleText as styleText6 } from "util";
|
|
219
|
+
function render6(text) {
|
|
220
|
+
const formattedText = text.toUpperCase().replace(/_/g, " ");
|
|
221
|
+
let data = formattedText;
|
|
222
|
+
if (formattedText === "VALID") {
|
|
223
|
+
data = styleText6(["green"], formattedText);
|
|
224
|
+
} else {
|
|
225
|
+
data = styleText6(["red"], formattedText);
|
|
226
|
+
}
|
|
227
|
+
return data;
|
|
228
|
+
}
|
|
229
|
+
__name(render6, "render");
|
|
230
|
+
|
|
231
|
+
// src/services/render-service.ts
|
|
232
|
+
var RenderService = class {
|
|
233
|
+
static {
|
|
234
|
+
__name(this, "RenderService");
|
|
235
|
+
}
|
|
236
|
+
// Example mocked data for rendering the servers information
|
|
237
|
+
// const mcpServersDataMock = [
|
|
238
|
+
// { status: '●', name: 'logging-server', type: 'SSE', version: '2.3.0', tools: '6', resources: '2' },
|
|
239
|
+
// { status: '●', name: 'git-logging-server', type: 'SSE', version: '2.3.0', tools: '6', resources: '2' },
|
|
240
|
+
// { status: '○', name: 'mcp-server', type: 'STDIO', version: '2.3.0', tools: '62', resources: '0' }
|
|
241
|
+
// ]
|
|
242
|
+
static getVisibleLength(text) {
|
|
243
|
+
return text.replace(/\u001b\[[0-9;]*m/g, "").length;
|
|
244
|
+
}
|
|
245
|
+
static printMcpServers(data) {
|
|
246
|
+
if (data.length === 0) return;
|
|
247
|
+
const headers = ["STATUS", "NAME", "TRANSPORT"];
|
|
248
|
+
const keys = ["status", "name", "transport"];
|
|
249
|
+
const centerColumns = [0, 2, 4, 5];
|
|
250
|
+
const leftPadding = " ";
|
|
251
|
+
const columnWidths = headers.map((header, index) => {
|
|
252
|
+
const dataWidth = Math.max(...data.map((row) => String(row[keys[index]]).length));
|
|
253
|
+
return Math.max(header.length, dataWidth);
|
|
254
|
+
});
|
|
255
|
+
const centerText = /* @__PURE__ */ __name((text, width) => {
|
|
256
|
+
const padding = width - this.getVisibleLength(text);
|
|
257
|
+
const leftPad = Math.floor(padding / 2);
|
|
258
|
+
const rightPad = padding - leftPad;
|
|
259
|
+
return " ".repeat(leftPad) + text + " ".repeat(rightPad);
|
|
260
|
+
}, "centerText");
|
|
261
|
+
const totalWidth = columnWidths.reduce((sum, width) => sum + width, 0) + (columnWidths.length - 1) * 2;
|
|
262
|
+
const separator = "\u2500".repeat(totalWidth);
|
|
263
|
+
console.log("\n" + leftPadding + separator);
|
|
264
|
+
const headerRow = headers.map((header, index) => {
|
|
265
|
+
const headerText = render2(header);
|
|
266
|
+
if (centerColumns.includes(index)) {
|
|
267
|
+
return centerText(headerText, columnWidths[index]);
|
|
268
|
+
}
|
|
269
|
+
const padding = columnWidths[index] - this.getVisibleLength(headerText);
|
|
270
|
+
return headerText + " ".repeat(Math.max(0, padding));
|
|
271
|
+
}).join(" ");
|
|
272
|
+
console.log(leftPadding + headerRow);
|
|
273
|
+
console.log(leftPadding + separator);
|
|
274
|
+
for (const row of data) {
|
|
275
|
+
const dataRow = keys.map((key, index) => {
|
|
276
|
+
let text = String(row[key]);
|
|
277
|
+
if (key === "transport") {
|
|
278
|
+
text = render(text);
|
|
279
|
+
}
|
|
280
|
+
if (key === "status") {
|
|
281
|
+
text = render3(text);
|
|
282
|
+
}
|
|
283
|
+
if (key === "name") {
|
|
284
|
+
text = render4(text);
|
|
285
|
+
}
|
|
286
|
+
if (centerColumns.includes(index)) {
|
|
287
|
+
return centerText(text, columnWidths[index]);
|
|
288
|
+
}
|
|
289
|
+
return text.padEnd(columnWidths[index]);
|
|
290
|
+
}).join(" ");
|
|
291
|
+
console.log(leftPadding + dataRow);
|
|
292
|
+
}
|
|
293
|
+
console.log("\n");
|
|
294
|
+
console.log(`${leftPadding}\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584`);
|
|
295
|
+
}
|
|
296
|
+
// Example mocked data for rendering the group information
|
|
297
|
+
// const mcpGroupDataMock = [
|
|
298
|
+
// { key: 'PROVIDER', value: 'Claude Desktop', },
|
|
299
|
+
// { key: 'FILE', value: '~/Library/Application Support/Claude/claude_desktop_config.json' },
|
|
300
|
+
// { key: 'STATUS', value: '[✓ VALID] [GLOBAL] [5 MCP SERVERS]' }
|
|
301
|
+
// ]
|
|
302
|
+
static printMcpGroup(id, data, groupMetadata = {}) {
|
|
303
|
+
if (data.length === 0) return;
|
|
304
|
+
console.log("\n");
|
|
305
|
+
const headers = ["KEY", "VALUE"];
|
|
306
|
+
const keys = ["key", "value"];
|
|
307
|
+
const indexText = `[${id}]`;
|
|
308
|
+
const leftPaddingGroupLead = indexText + " ".repeat(6 - indexText.length);
|
|
309
|
+
const leftPaddingGroupData = " ".repeat(6);
|
|
310
|
+
if (Object.keys(groupMetadata).length > 0) {
|
|
311
|
+
const runningCount = groupMetadata.mcpServersRunning || 0;
|
|
312
|
+
const totalCount = groupMetadata.mcpServersTotal || 0;
|
|
313
|
+
const metadataRow = this.renderProgressBar(runningCount, totalCount, "Running");
|
|
314
|
+
data.push({ key: "MCP SERVERS", value: metadataRow });
|
|
315
|
+
}
|
|
316
|
+
const columnWidths = headers.map((header, index) => {
|
|
317
|
+
const dataWidth = Math.max(...data.map((row) => {
|
|
318
|
+
const columnText = render2(row[keys[index]]);
|
|
319
|
+
const columnTextLength = this.getVisibleLength(columnText);
|
|
320
|
+
return columnTextLength;
|
|
321
|
+
}));
|
|
322
|
+
return Math.max(header.length, dataWidth);
|
|
323
|
+
});
|
|
324
|
+
for (const [index, row] of data.entries()) {
|
|
325
|
+
const dataRow = keys.map((key, index2) => {
|
|
326
|
+
const paddingNormalizer = render2(row[key]).length - row[key].length;
|
|
327
|
+
if (key === "key") {
|
|
328
|
+
return render2(row[key]).padEnd(columnWidths[index2] + paddingNormalizer);
|
|
329
|
+
}
|
|
330
|
+
if (row["key"] === "FILE") {
|
|
331
|
+
return render5(row[key]).padEnd(columnWidths[index2] + paddingNormalizer);
|
|
332
|
+
}
|
|
333
|
+
if (row["key"] === "PARSABLE") {
|
|
334
|
+
return render6(row[key]).padEnd(columnWidths[index2] + paddingNormalizer);
|
|
335
|
+
}
|
|
336
|
+
return String(row[key]).padEnd(columnWidths[index2] + paddingNormalizer);
|
|
337
|
+
}).join(" ");
|
|
338
|
+
const leftPadding = index === 0 ? leftPaddingGroupLead : leftPaddingGroupData;
|
|
339
|
+
console.log(leftPadding + dataRow);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
// draws progress bar components like this
|
|
343
|
+
// "███████░░░░░░░░░░░░░ 3 / 9 Running"
|
|
344
|
+
static renderProgressBar(count, total, label, width = 20) {
|
|
345
|
+
if (total === 0) {
|
|
346
|
+
const emptyBar = "\u2591".repeat(width);
|
|
347
|
+
return `${emptyBar} 0 / 0 ${label}`;
|
|
348
|
+
}
|
|
349
|
+
const progress = Math.min(count / total, 1);
|
|
350
|
+
const filledWidth = Math.round(progress * width);
|
|
351
|
+
const emptyWidth = width - filledWidth;
|
|
352
|
+
const colorRunning = count > 0 ? "greenBright" : "red";
|
|
353
|
+
const colorEmpty = count > 0 ? "green" : "red";
|
|
354
|
+
const filled = styleText7([colorRunning], "\u2588".repeat(filledWidth));
|
|
355
|
+
const empty = styleText7([colorEmpty], "\u2591".repeat(emptyWidth));
|
|
356
|
+
return `${filled}${empty} ${count} / ${total} ${label}`;
|
|
35
357
|
}
|
|
36
358
|
};
|
|
37
359
|
|
|
38
360
|
// src/bin/cli.ts
|
|
39
|
-
|
|
361
|
+
console.log();
|
|
40
362
|
async function init() {
|
|
41
363
|
const mcpFilesManager = new MCPFiles();
|
|
42
364
|
const mcpFilesList = await mcpFilesManager.findFiles();
|
|
43
|
-
if (mcpFilesList.length
|
|
44
|
-
console.log("MCP files found:");
|
|
45
|
-
mcpFilesList.forEach((file) => {
|
|
46
|
-
console.log(`- ${file}`);
|
|
47
|
-
});
|
|
48
|
-
} else {
|
|
365
|
+
if (Object.keys(mcpFilesList).length === 0) {
|
|
49
366
|
console.log("No MCP files found.");
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
let groupIndex = 0;
|
|
370
|
+
for (const groupName of Object.keys(mcpFilesList)) {
|
|
371
|
+
groupIndex++;
|
|
372
|
+
const group = mcpFilesList[groupName];
|
|
373
|
+
if (group.paths.length >= 0) {
|
|
374
|
+
for (const filePathData of group.paths) {
|
|
375
|
+
const filePath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
376
|
+
const filePathValid = filePathData.parsable ? "VALID" : "INVALID";
|
|
377
|
+
const filePathDataType = filePathData.type.toUpperCase();
|
|
378
|
+
const mcpServers = filePathData.servers || [];
|
|
379
|
+
const totalMCPServers = filePathData.servers ? filePathData.servers.length : 0;
|
|
380
|
+
const totalMCPServersRunning = mcpServers.filter((server) => server.status === "running").length;
|
|
381
|
+
const mcpGroupData = [
|
|
382
|
+
{ key: "PROVIDER", value: group.friendlyName },
|
|
383
|
+
{ key: "FILE", value: filePath },
|
|
384
|
+
{ key: "PARSABLE", value: filePathValid },
|
|
385
|
+
{ key: "TYPE", value: filePathDataType }
|
|
386
|
+
];
|
|
387
|
+
const groupMetadata = {
|
|
388
|
+
mcpServersTotal: totalMCPServers,
|
|
389
|
+
mcpServersRunning: totalMCPServersRunning
|
|
390
|
+
};
|
|
391
|
+
RenderService.printMcpGroup(groupIndex, mcpGroupData, groupMetadata);
|
|
392
|
+
RenderService.printMcpServers(mcpServers);
|
|
393
|
+
}
|
|
394
|
+
} else {
|
|
395
|
+
console.log("No files found in this group.");
|
|
396
|
+
}
|
|
50
397
|
}
|
|
51
398
|
}
|
|
52
399
|
__name(init, "init");
|
|
53
|
-
init()
|
|
400
|
+
init().then(() => {
|
|
401
|
+
console.log("\n");
|
|
402
|
+
});
|
package/dist/main.cjs
CHANGED
|
@@ -34,32 +34,156 @@ __export(main_exports, {
|
|
|
34
34
|
MCPFiles: () => MCPFiles
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(main_exports);
|
|
37
|
+
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
38
|
+
|
|
39
|
+
// src/services/mcp-config-linter-service.ts
|
|
37
40
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
41
|
+
var MCPConfigLinterService = class {
|
|
42
|
+
static {
|
|
43
|
+
__name(this, "MCPConfigLinterService");
|
|
44
|
+
}
|
|
45
|
+
filePath;
|
|
46
|
+
fileContents = null;
|
|
47
|
+
constructor(filePath) {
|
|
48
|
+
this.filePath = filePath;
|
|
49
|
+
}
|
|
50
|
+
async isValidSyntax() {
|
|
51
|
+
try {
|
|
52
|
+
const fileContent = await this.getFileContent();
|
|
53
|
+
JSON.parse(fileContent);
|
|
54
|
+
return true;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async countMCPServers() {
|
|
60
|
+
const mcpServers = await this.getMCPServers();
|
|
61
|
+
return Object.keys(mcpServers).length;
|
|
62
|
+
}
|
|
63
|
+
async getMCPServers() {
|
|
64
|
+
const fileContentRaw = await this.getFileContent();
|
|
65
|
+
const fileContentsData = JSON.parse(fileContentRaw);
|
|
66
|
+
const mcpServers = fileContentsData?.mcpServers;
|
|
67
|
+
return mcpServers;
|
|
68
|
+
}
|
|
69
|
+
async getFileContent() {
|
|
70
|
+
if (this.fileContents) {
|
|
71
|
+
return this.fileContents;
|
|
72
|
+
}
|
|
73
|
+
this.fileContents = await import_promises.default.readFile(this.filePath, "utf-8");
|
|
74
|
+
return this.fileContents;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// src/services/mcp-server-manager-service.ts
|
|
79
|
+
var MCPServerManagerService = class {
|
|
80
|
+
static {
|
|
81
|
+
__name(this, "MCPServerManagerService");
|
|
82
|
+
}
|
|
83
|
+
name;
|
|
84
|
+
command;
|
|
85
|
+
args;
|
|
86
|
+
transport;
|
|
87
|
+
env;
|
|
88
|
+
running = false;
|
|
89
|
+
constructor(serverConfig) {
|
|
90
|
+
this.name = serverConfig.name;
|
|
91
|
+
this.command = serverConfig.command;
|
|
92
|
+
this.args = serverConfig.args || [];
|
|
93
|
+
this.transport = serverConfig.transport || "stdio";
|
|
94
|
+
this.env = serverConfig.env || {};
|
|
95
|
+
}
|
|
96
|
+
getName() {
|
|
97
|
+
return this.name;
|
|
98
|
+
}
|
|
99
|
+
getCmd() {
|
|
100
|
+
return this.command;
|
|
101
|
+
}
|
|
102
|
+
getArgs() {
|
|
103
|
+
return this.args;
|
|
104
|
+
}
|
|
105
|
+
getTransport() {
|
|
106
|
+
return this.transport;
|
|
107
|
+
}
|
|
108
|
+
getEnv() {
|
|
109
|
+
return this.env;
|
|
110
|
+
}
|
|
111
|
+
isRunning() {
|
|
112
|
+
return this.running;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// src/main.ts
|
|
38
117
|
var MCPFiles = class {
|
|
39
118
|
static {
|
|
40
119
|
__name(this, "MCPFiles");
|
|
41
120
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
121
|
+
mcpFilePathGroups = {
|
|
122
|
+
claude: {
|
|
123
|
+
name: "claude",
|
|
124
|
+
friendlyName: "Claude Desktop",
|
|
125
|
+
paths: [
|
|
126
|
+
{ filePath: "~/Library/Application Support/Claude/claude_desktop_config.json", type: "global" }
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
cursor: {
|
|
130
|
+
name: "cursor",
|
|
131
|
+
friendlyName: "Cursor",
|
|
132
|
+
paths: [
|
|
133
|
+
{ filePath: ".cursor/mcp.json", type: "local" },
|
|
134
|
+
{ filePath: "~/.cursor/mcp.json", type: "global" }
|
|
135
|
+
]
|
|
50
136
|
}
|
|
137
|
+
};
|
|
138
|
+
constructor(mcpFilePathGroups) {
|
|
139
|
+
this.mcpFilePathGroups = mcpFilePathGroups || this.mcpFilePathGroups;
|
|
51
140
|
}
|
|
52
141
|
async findFiles() {
|
|
53
|
-
const
|
|
54
|
-
for (const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
142
|
+
const mcpFilesPathsData = {};
|
|
143
|
+
for (const groupName of Object.keys(this.mcpFilePathGroups)) {
|
|
144
|
+
const clientsGroup = this.mcpFilePathGroups[groupName];
|
|
145
|
+
mcpFilesPathsData[groupName] = {
|
|
146
|
+
name: clientsGroup.name,
|
|
147
|
+
friendlyName: clientsGroup.friendlyName,
|
|
148
|
+
paths: [],
|
|
149
|
+
stats: {}
|
|
150
|
+
};
|
|
151
|
+
for (const filePathData of clientsGroup.paths) {
|
|
152
|
+
const resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
153
|
+
try {
|
|
154
|
+
await import_promises2.default.access(resolvedPath);
|
|
155
|
+
const MCPConfigLinter = new MCPConfigLinterService(resolvedPath);
|
|
156
|
+
const parsable = await MCPConfigLinter.isValidSyntax();
|
|
157
|
+
filePathData.parsable = parsable;
|
|
158
|
+
const mcpServersData = [];
|
|
159
|
+
const mcpServersFromConfig = await MCPConfigLinter.getMCPServers();
|
|
160
|
+
for (const serverName of Object.keys(mcpServersFromConfig)) {
|
|
161
|
+
const serverConfigRaw = mcpServersFromConfig[serverName];
|
|
162
|
+
const serverConfig = {
|
|
163
|
+
name: serverName,
|
|
164
|
+
command: serverConfigRaw.command || "",
|
|
165
|
+
args: serverConfigRaw.args,
|
|
166
|
+
transport: serverConfigRaw.transport,
|
|
167
|
+
env: serverConfigRaw.env
|
|
168
|
+
};
|
|
169
|
+
const MCPServerManager = new MCPServerManagerService(serverConfig);
|
|
170
|
+
mcpServersData.push({
|
|
171
|
+
name: MCPServerManager.getName(),
|
|
172
|
+
command: MCPServerManager.getCmd(),
|
|
173
|
+
args: MCPServerManager.getArgs(),
|
|
174
|
+
transport: MCPServerManager.getTransport(),
|
|
175
|
+
env: MCPServerManager.getEnv(),
|
|
176
|
+
status: MCPServerManager.isRunning() ? "running" : "stopped"
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
filePathData.servers = mcpServersData;
|
|
180
|
+
mcpFilesPathsData[groupName]["stats"]["serversCount"] = await MCPConfigLinter.countMCPServers();
|
|
181
|
+
mcpFilesPathsData[groupName].paths.push(filePathData);
|
|
182
|
+
} catch (error) {
|
|
183
|
+
}
|
|
60
184
|
}
|
|
61
185
|
}
|
|
62
|
-
return
|
|
186
|
+
return mcpFilesPathsData;
|
|
63
187
|
}
|
|
64
188
|
};
|
|
65
189
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/main.d.cts
CHANGED
|
@@ -1,7 +1,39 @@
|
|
|
1
|
+
interface MCPServerInfo {
|
|
2
|
+
name: string;
|
|
3
|
+
command: string;
|
|
4
|
+
args?: string[];
|
|
5
|
+
transport?: 'stdio' | 'sse';
|
|
6
|
+
env?: Record<string, string>;
|
|
7
|
+
status?: 'running' | 'stopped';
|
|
8
|
+
}
|
|
9
|
+
interface MCPFilePath {
|
|
10
|
+
filePath: string;
|
|
11
|
+
type: 'local' | 'global';
|
|
12
|
+
parsable?: boolean;
|
|
13
|
+
servers?: MCPServerInfo[];
|
|
14
|
+
}
|
|
15
|
+
interface MCPFileGroups {
|
|
16
|
+
name: string;
|
|
17
|
+
friendlyName: string;
|
|
18
|
+
paths: MCPFilePath[];
|
|
19
|
+
stats?: {
|
|
20
|
+
serversCount?: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
interface MCPFileGroupsResult {
|
|
24
|
+
name: string;
|
|
25
|
+
friendlyName: string;
|
|
26
|
+
paths: MCPFilePath[];
|
|
27
|
+
stats: {
|
|
28
|
+
serversCount?: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
type MCPFilePathGroupsRecord = Record<string, MCPFileGroups>;
|
|
32
|
+
type MCPFileGroupsResultRecord = Record<string, MCPFileGroupsResult>;
|
|
1
33
|
declare class MCPFiles {
|
|
2
|
-
private
|
|
3
|
-
constructor(
|
|
4
|
-
findFiles(): Promise<
|
|
34
|
+
private mcpFilePathGroups;
|
|
35
|
+
constructor(mcpFilePathGroups?: MCPFilePathGroupsRecord);
|
|
36
|
+
findFiles(): Promise<MCPFileGroupsResultRecord>;
|
|
5
37
|
}
|
|
6
38
|
|
|
7
39
|
export { MCPFiles };
|
package/dist/main.d.ts
CHANGED
|
@@ -1,7 +1,39 @@
|
|
|
1
|
+
interface MCPServerInfo {
|
|
2
|
+
name: string;
|
|
3
|
+
command: string;
|
|
4
|
+
args?: string[];
|
|
5
|
+
transport?: 'stdio' | 'sse';
|
|
6
|
+
env?: Record<string, string>;
|
|
7
|
+
status?: 'running' | 'stopped';
|
|
8
|
+
}
|
|
9
|
+
interface MCPFilePath {
|
|
10
|
+
filePath: string;
|
|
11
|
+
type: 'local' | 'global';
|
|
12
|
+
parsable?: boolean;
|
|
13
|
+
servers?: MCPServerInfo[];
|
|
14
|
+
}
|
|
15
|
+
interface MCPFileGroups {
|
|
16
|
+
name: string;
|
|
17
|
+
friendlyName: string;
|
|
18
|
+
paths: MCPFilePath[];
|
|
19
|
+
stats?: {
|
|
20
|
+
serversCount?: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
interface MCPFileGroupsResult {
|
|
24
|
+
name: string;
|
|
25
|
+
friendlyName: string;
|
|
26
|
+
paths: MCPFilePath[];
|
|
27
|
+
stats: {
|
|
28
|
+
serversCount?: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
type MCPFilePathGroupsRecord = Record<string, MCPFileGroups>;
|
|
32
|
+
type MCPFileGroupsResultRecord = Record<string, MCPFileGroupsResult>;
|
|
1
33
|
declare class MCPFiles {
|
|
2
|
-
private
|
|
3
|
-
constructor(
|
|
4
|
-
findFiles(): Promise<
|
|
34
|
+
private mcpFilePathGroups;
|
|
35
|
+
constructor(mcpFilePathGroups?: MCPFilePathGroupsRecord);
|
|
36
|
+
findFiles(): Promise<MCPFileGroupsResultRecord>;
|
|
5
37
|
}
|
|
6
38
|
|
|
7
39
|
export { MCPFiles };
|