ls-mcp 1.13.3 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -1
- package/dist/bin/cli.cjs +128 -5
- package/dist/bin/cli.mjs +128 -5
- package/dist/main.cjs +89 -1
- package/dist/main.d.cts +3 -1
- package/dist/main.d.ts +3 -1
- package/dist/main.mjs +89 -1
- package/package.json +1 -1
- package/src/bin/cli.ts +47 -5
- package/src/main.ts +45 -1
- package/src/services/mcp-config-service.ts +69 -0
package/README.md
CHANGED
|
@@ -35,16 +35,57 @@
|
|
|
35
35
|
npx ls-mcp
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
### Analyze Specific Files
|
|
39
|
+
|
|
40
|
+
To analyze specific MCP configuration files instead of using automatic discovery, use the `--files` flag. This flag **replaces** automatic discovery and only analyzes the files you specify:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Single file
|
|
44
|
+
npx ls-mcp --files ./mcp-config.json
|
|
45
|
+
|
|
46
|
+
# Multiple files (comma-separated)
|
|
47
|
+
npx ls-mcp --files ./config1.json,./config2.json
|
|
48
|
+
|
|
49
|
+
# Multiple files (space-separated)
|
|
50
|
+
npx ls-mcp --files ./config1.json ./config2.json
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The `--files` flag automatically detects the configuration structure in your files, supporting various formats including:
|
|
54
|
+
- `servers` - Standard MCP configuration key
|
|
55
|
+
- `mcpServers` - Alternative MCP configuration key
|
|
56
|
+
- `mcp.servers` - Nested configuration format
|
|
57
|
+
- `context_servers` - Context-based configuration format
|
|
58
|
+
|
|
59
|
+
### Show All Providers
|
|
60
|
+
|
|
61
|
+
By default, `ls-mcp` hides providers that have zero configured servers to reduce clutter. To show all providers including those with empty configurations, use the `--all` or `-a` flag:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Show all providers including empty ones
|
|
65
|
+
npx ls-mcp --all
|
|
66
|
+
|
|
67
|
+
# Short form
|
|
68
|
+
npx ls-mcp -a
|
|
69
|
+
|
|
70
|
+
# Combine with JSON output
|
|
71
|
+
npx ls-mcp --all --json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Note**: When using `--files` to analyze specific configuration files, the custom group is always shown even if it contains zero servers, as you explicitly requested to analyze those files.
|
|
75
|
+
|
|
38
76
|
### JSON Output
|
|
39
77
|
|
|
40
78
|
To output results in JSON format (useful for programmatic consumption):
|
|
41
79
|
|
|
42
80
|
```bash
|
|
43
81
|
npx ls-mcp --json
|
|
82
|
+
|
|
83
|
+
# Combine with --files flag
|
|
84
|
+
npx ls-mcp --files ./config.json --json
|
|
44
85
|
```
|
|
45
86
|
|
|
46
87
|
This will return a structured JSON object containing:
|
|
47
|
-
- `mcpFiles`: Complete MCP server configurations organized by provider (only includes providers with configured servers)
|
|
88
|
+
- `mcpFiles`: Complete MCP server configurations organized by provider (only includes providers with configured servers unless `--all` is specified)
|
|
48
89
|
- `summary`: Statistics including total servers, running servers, credential warnings, and transport breakdown
|
|
49
90
|
|
|
50
91
|
### Debug Mode
|
|
@@ -66,6 +107,7 @@ For detailed information about the project architecture and features:
|
|
|
66
107
|
- **[Project Overview](./docs/project.md)**: Comprehensive project analysis and architecture
|
|
67
108
|
- **[Design Documentation](./docs/design.md)**: Technical design decisions and implementation details
|
|
68
109
|
- **[Requirements](./docs/requirements.md)**: Functional and non-functional requirements
|
|
110
|
+
- **[Custom File Analysis](./docs/custom-files-analysis.md)**: Analyze specific MCP configuration files with the `--files` flag
|
|
69
111
|
- **[Directory Bubbling](./docs/directory-bubbling.md)**: Intelligent directory traversal feature
|
|
70
112
|
- **[URL Hostname Extraction](./docs/url-hostname-extraction.md)**: Clean display of hostnames for URL-based servers
|
|
71
113
|
- **[Credential Detection](./docs/credential-detection.md)**: Security analysis features
|
package/dist/bin/cli.cjs
CHANGED
|
@@ -659,6 +659,61 @@ var MCPConfigService = class {
|
|
|
659
659
|
throw new Error(`Failed to get MCP file groups: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
660
660
|
}
|
|
661
661
|
}
|
|
662
|
+
/**
|
|
663
|
+
* Parse custom configuration files provided by the user
|
|
664
|
+
* This method processes files independently of standard app-based discovery
|
|
665
|
+
*/
|
|
666
|
+
async parseCustomFiles(filePaths) {
|
|
667
|
+
try {
|
|
668
|
+
const mcpFilesPathsData = {
|
|
669
|
+
custom: {
|
|
670
|
+
name: "custom",
|
|
671
|
+
friendlyName: "Custom Files",
|
|
672
|
+
paths: [],
|
|
673
|
+
stats: { serversCount: 0 }
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
let totalServersCount = 0;
|
|
677
|
+
for (const filePath of filePaths) {
|
|
678
|
+
const resolvedPath = filePath.replace("~", process.env.HOME || "");
|
|
679
|
+
const absolutePath = import_node_path.default.resolve(resolvedPath);
|
|
680
|
+
try {
|
|
681
|
+
await import_promises.default.access(absolutePath);
|
|
682
|
+
const parser = this.createParser(absolutePath);
|
|
683
|
+
const parsable = await parser.isValidSyntax();
|
|
684
|
+
const filePathData = {
|
|
685
|
+
filePath: absolutePath,
|
|
686
|
+
type: "local",
|
|
687
|
+
parsable
|
|
688
|
+
};
|
|
689
|
+
if (parsable) {
|
|
690
|
+
const configData = await parser.parseConfigFile();
|
|
691
|
+
const servers = await this.convertToMCPServerInfo(configData.servers || {});
|
|
692
|
+
filePathData.servers = servers;
|
|
693
|
+
totalServersCount += servers.length;
|
|
694
|
+
} else {
|
|
695
|
+
this.debug(`File ${absolutePath} has invalid syntax`);
|
|
696
|
+
filePathData.servers = [];
|
|
697
|
+
}
|
|
698
|
+
mcpFilesPathsData.custom.paths.push(filePathData);
|
|
699
|
+
} catch (error) {
|
|
700
|
+
this.debug(`Skipping file ${absolutePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
701
|
+
mcpFilesPathsData.custom.paths.push({
|
|
702
|
+
filePath: absolutePath,
|
|
703
|
+
type: "local",
|
|
704
|
+
parsable: false,
|
|
705
|
+
servers: []
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
if (mcpFilesPathsData.custom.stats) {
|
|
710
|
+
mcpFilesPathsData.custom.stats.serversCount = totalServersCount;
|
|
711
|
+
}
|
|
712
|
+
return mcpFilesPathsData;
|
|
713
|
+
} catch (error) {
|
|
714
|
+
throw new Error(`Failed to parse custom files: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
662
717
|
/**
|
|
663
718
|
* Register a custom app with custom paths for the current OS
|
|
664
719
|
*/
|
|
@@ -1143,14 +1198,47 @@ var MCPFiles = class {
|
|
|
1143
1198
|
__name(this, "MCPFiles");
|
|
1144
1199
|
}
|
|
1145
1200
|
mcpConfigService;
|
|
1146
|
-
|
|
1201
|
+
customFiles;
|
|
1202
|
+
constructor(customFiles2) {
|
|
1147
1203
|
this.mcpConfigService = new MCPConfigService({ enableDirectoryBubbling: true });
|
|
1204
|
+
this.customFiles = customFiles2;
|
|
1148
1205
|
}
|
|
1149
1206
|
/**
|
|
1150
1207
|
* Find and process all MCP configuration files
|
|
1208
|
+
* If customFiles are provided, only those files are processed (replaces automatic discovery)
|
|
1151
1209
|
*/
|
|
1152
1210
|
async findFiles() {
|
|
1153
1211
|
try {
|
|
1212
|
+
if (this.customFiles && this.customFiles.length > 0) {
|
|
1213
|
+
const mcpFilesPathsData2 = await this.mcpConfigService.parseCustomFiles(this.customFiles);
|
|
1214
|
+
for (const groupName of Object.keys(mcpFilesPathsData2)) {
|
|
1215
|
+
const group = mcpFilesPathsData2[groupName];
|
|
1216
|
+
for (const filePathData of group.paths) {
|
|
1217
|
+
if (filePathData.servers && filePathData.servers.length > 0) {
|
|
1218
|
+
for (const server of filePathData.servers) {
|
|
1219
|
+
const serverConfig = {
|
|
1220
|
+
name: server.name,
|
|
1221
|
+
command: server.command,
|
|
1222
|
+
args: server.args,
|
|
1223
|
+
transport: server.transport,
|
|
1224
|
+
type: server.type,
|
|
1225
|
+
env: server.env
|
|
1226
|
+
};
|
|
1227
|
+
const serverManager = new MCPServerManagerService(serverConfig);
|
|
1228
|
+
const processDetection = serverManager.isRunning();
|
|
1229
|
+
let isRunning = false;
|
|
1230
|
+
if (processDetection) {
|
|
1231
|
+
if (typeof processDetection === "object" && processDetection.estimatedProduct === group.name) {
|
|
1232
|
+
isRunning = true;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
server.status = isRunning ? "running" : "stopped";
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
return mcpFilesPathsData2;
|
|
1241
|
+
}
|
|
1154
1242
|
const mcpFilesPathsData = await this.mcpConfigService.getMCPFileGroups();
|
|
1155
1243
|
for (const groupName of Object.keys(mcpFilesPathsData)) {
|
|
1156
1244
|
const group = mcpFilesPathsData[groupName];
|
|
@@ -1584,12 +1672,31 @@ var RenderService = class _RenderService {
|
|
|
1584
1672
|
// src/bin/cli.ts
|
|
1585
1673
|
var args = process.argv.slice(2);
|
|
1586
1674
|
var jsonOutput = args.includes("--json");
|
|
1675
|
+
var showAll = args.includes("--all") || args.includes("-a");
|
|
1676
|
+
var customFiles;
|
|
1677
|
+
var filesIndex = args.findIndex((arg) => arg === "--files");
|
|
1678
|
+
if (filesIndex !== -1 && filesIndex < args.length - 1) {
|
|
1679
|
+
const fileArgs = [];
|
|
1680
|
+
for (let i = filesIndex + 1; i < args.length; i++) {
|
|
1681
|
+
if (args[i].startsWith("--")) {
|
|
1682
|
+
break;
|
|
1683
|
+
}
|
|
1684
|
+
fileArgs.push(args[i]);
|
|
1685
|
+
}
|
|
1686
|
+
customFiles = fileArgs.flatMap(
|
|
1687
|
+
(arg) => arg.includes(",") ? arg.split(",").map((f) => f.trim()) : [arg.trim()]
|
|
1688
|
+
).filter((f) => f.length > 0);
|
|
1689
|
+
}
|
|
1587
1690
|
async function init() {
|
|
1588
1691
|
if (!jsonOutput) {
|
|
1589
1692
|
console.log();
|
|
1590
|
-
|
|
1693
|
+
if (customFiles && customFiles.length > 0) {
|
|
1694
|
+
console.log("[+] Analyzing specified MCP configuration files...");
|
|
1695
|
+
} else {
|
|
1696
|
+
console.log("[+] Detecting MCP Server configurations...");
|
|
1697
|
+
}
|
|
1591
1698
|
}
|
|
1592
|
-
const mcpFilesManager = new MCPFiles();
|
|
1699
|
+
const mcpFilesManager = new MCPFiles(customFiles);
|
|
1593
1700
|
const mcpFilesList = await mcpFilesManager.findFiles();
|
|
1594
1701
|
if (Object.keys(mcpFilesList).length === 0) {
|
|
1595
1702
|
exitWithError("No configuration for MCP Server applications found.");
|
|
@@ -1602,6 +1709,11 @@ async function init() {
|
|
|
1602
1709
|
const transportCounts = { stdio: 0, sse: 0, http: 0 };
|
|
1603
1710
|
for (const groupName of Object.keys(mcpFilesList)) {
|
|
1604
1711
|
const group = mcpFilesList[groupName];
|
|
1712
|
+
const isCustomFilesMode = customFiles && customFiles.length > 0;
|
|
1713
|
+
const shouldSkipGroup = !showAll && !isCustomFilesMode && group.stats?.serversCount === 0;
|
|
1714
|
+
if (shouldSkipGroup) {
|
|
1715
|
+
continue;
|
|
1716
|
+
}
|
|
1605
1717
|
if (group.paths.length > 0) {
|
|
1606
1718
|
for (const filePathData of group.paths) {
|
|
1607
1719
|
pathIndex++;
|
|
@@ -1645,7 +1757,12 @@ async function init() {
|
|
|
1645
1757
|
}
|
|
1646
1758
|
}
|
|
1647
1759
|
if (pathIndex === 0) {
|
|
1648
|
-
|
|
1760
|
+
const isCustomFilesMode = customFiles && customFiles.length > 0;
|
|
1761
|
+
if (isCustomFilesMode) {
|
|
1762
|
+
exitWithError("No MCP servers found in specified configuration files.");
|
|
1763
|
+
} else {
|
|
1764
|
+
exitWithError("No MCP servers found in known configuration files.");
|
|
1765
|
+
}
|
|
1649
1766
|
}
|
|
1650
1767
|
const summaryStats = {
|
|
1651
1768
|
totalServers,
|
|
@@ -1655,8 +1772,14 @@ async function init() {
|
|
|
1655
1772
|
transportBreakdown: transportCounts
|
|
1656
1773
|
};
|
|
1657
1774
|
if (jsonOutput) {
|
|
1775
|
+
const isCustomFilesMode = customFiles && customFiles.length > 0;
|
|
1658
1776
|
const filteredMcpFiles = Object.fromEntries(
|
|
1659
|
-
Object.entries(mcpFilesList).filter(([, group]) =>
|
|
1777
|
+
Object.entries(mcpFilesList).filter(([, group]) => {
|
|
1778
|
+
if (showAll || isCustomFilesMode) {
|
|
1779
|
+
return group.paths.length > 0;
|
|
1780
|
+
}
|
|
1781
|
+
return (group.stats?.serversCount ?? 0) > 0;
|
|
1782
|
+
})
|
|
1660
1783
|
);
|
|
1661
1784
|
const output = {
|
|
1662
1785
|
mcpFiles: filteredMcpFiles,
|
package/dist/bin/cli.mjs
CHANGED
|
@@ -637,6 +637,61 @@ var MCPConfigService = class {
|
|
|
637
637
|
throw new Error(`Failed to get MCP file groups: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
638
638
|
}
|
|
639
639
|
}
|
|
640
|
+
/**
|
|
641
|
+
* Parse custom configuration files provided by the user
|
|
642
|
+
* This method processes files independently of standard app-based discovery
|
|
643
|
+
*/
|
|
644
|
+
async parseCustomFiles(filePaths) {
|
|
645
|
+
try {
|
|
646
|
+
const mcpFilesPathsData = {
|
|
647
|
+
custom: {
|
|
648
|
+
name: "custom",
|
|
649
|
+
friendlyName: "Custom Files",
|
|
650
|
+
paths: [],
|
|
651
|
+
stats: { serversCount: 0 }
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
let totalServersCount = 0;
|
|
655
|
+
for (const filePath of filePaths) {
|
|
656
|
+
const resolvedPath = filePath.replace("~", process.env.HOME || "");
|
|
657
|
+
const absolutePath = path.resolve(resolvedPath);
|
|
658
|
+
try {
|
|
659
|
+
await fs.access(absolutePath);
|
|
660
|
+
const parser = this.createParser(absolutePath);
|
|
661
|
+
const parsable = await parser.isValidSyntax();
|
|
662
|
+
const filePathData = {
|
|
663
|
+
filePath: absolutePath,
|
|
664
|
+
type: "local",
|
|
665
|
+
parsable
|
|
666
|
+
};
|
|
667
|
+
if (parsable) {
|
|
668
|
+
const configData = await parser.parseConfigFile();
|
|
669
|
+
const servers = await this.convertToMCPServerInfo(configData.servers || {});
|
|
670
|
+
filePathData.servers = servers;
|
|
671
|
+
totalServersCount += servers.length;
|
|
672
|
+
} else {
|
|
673
|
+
this.debug(`File ${absolutePath} has invalid syntax`);
|
|
674
|
+
filePathData.servers = [];
|
|
675
|
+
}
|
|
676
|
+
mcpFilesPathsData.custom.paths.push(filePathData);
|
|
677
|
+
} catch (error) {
|
|
678
|
+
this.debug(`Skipping file ${absolutePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
679
|
+
mcpFilesPathsData.custom.paths.push({
|
|
680
|
+
filePath: absolutePath,
|
|
681
|
+
type: "local",
|
|
682
|
+
parsable: false,
|
|
683
|
+
servers: []
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
if (mcpFilesPathsData.custom.stats) {
|
|
688
|
+
mcpFilesPathsData.custom.stats.serversCount = totalServersCount;
|
|
689
|
+
}
|
|
690
|
+
return mcpFilesPathsData;
|
|
691
|
+
} catch (error) {
|
|
692
|
+
throw new Error(`Failed to parse custom files: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
640
695
|
/**
|
|
641
696
|
* Register a custom app with custom paths for the current OS
|
|
642
697
|
*/
|
|
@@ -1121,14 +1176,47 @@ var MCPFiles = class {
|
|
|
1121
1176
|
__name(this, "MCPFiles");
|
|
1122
1177
|
}
|
|
1123
1178
|
mcpConfigService;
|
|
1124
|
-
|
|
1179
|
+
customFiles;
|
|
1180
|
+
constructor(customFiles2) {
|
|
1125
1181
|
this.mcpConfigService = new MCPConfigService({ enableDirectoryBubbling: true });
|
|
1182
|
+
this.customFiles = customFiles2;
|
|
1126
1183
|
}
|
|
1127
1184
|
/**
|
|
1128
1185
|
* Find and process all MCP configuration files
|
|
1186
|
+
* If customFiles are provided, only those files are processed (replaces automatic discovery)
|
|
1129
1187
|
*/
|
|
1130
1188
|
async findFiles() {
|
|
1131
1189
|
try {
|
|
1190
|
+
if (this.customFiles && this.customFiles.length > 0) {
|
|
1191
|
+
const mcpFilesPathsData2 = await this.mcpConfigService.parseCustomFiles(this.customFiles);
|
|
1192
|
+
for (const groupName of Object.keys(mcpFilesPathsData2)) {
|
|
1193
|
+
const group = mcpFilesPathsData2[groupName];
|
|
1194
|
+
for (const filePathData of group.paths) {
|
|
1195
|
+
if (filePathData.servers && filePathData.servers.length > 0) {
|
|
1196
|
+
for (const server of filePathData.servers) {
|
|
1197
|
+
const serverConfig = {
|
|
1198
|
+
name: server.name,
|
|
1199
|
+
command: server.command,
|
|
1200
|
+
args: server.args,
|
|
1201
|
+
transport: server.transport,
|
|
1202
|
+
type: server.type,
|
|
1203
|
+
env: server.env
|
|
1204
|
+
};
|
|
1205
|
+
const serverManager = new MCPServerManagerService(serverConfig);
|
|
1206
|
+
const processDetection = serverManager.isRunning();
|
|
1207
|
+
let isRunning = false;
|
|
1208
|
+
if (processDetection) {
|
|
1209
|
+
if (typeof processDetection === "object" && processDetection.estimatedProduct === group.name) {
|
|
1210
|
+
isRunning = true;
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
server.status = isRunning ? "running" : "stopped";
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
return mcpFilesPathsData2;
|
|
1219
|
+
}
|
|
1132
1220
|
const mcpFilesPathsData = await this.mcpConfigService.getMCPFileGroups();
|
|
1133
1221
|
for (const groupName of Object.keys(mcpFilesPathsData)) {
|
|
1134
1222
|
const group = mcpFilesPathsData[groupName];
|
|
@@ -1562,12 +1650,31 @@ var RenderService = class _RenderService {
|
|
|
1562
1650
|
// src/bin/cli.ts
|
|
1563
1651
|
var args = process.argv.slice(2);
|
|
1564
1652
|
var jsonOutput = args.includes("--json");
|
|
1653
|
+
var showAll = args.includes("--all") || args.includes("-a");
|
|
1654
|
+
var customFiles;
|
|
1655
|
+
var filesIndex = args.findIndex((arg) => arg === "--files");
|
|
1656
|
+
if (filesIndex !== -1 && filesIndex < args.length - 1) {
|
|
1657
|
+
const fileArgs = [];
|
|
1658
|
+
for (let i = filesIndex + 1; i < args.length; i++) {
|
|
1659
|
+
if (args[i].startsWith("--")) {
|
|
1660
|
+
break;
|
|
1661
|
+
}
|
|
1662
|
+
fileArgs.push(args[i]);
|
|
1663
|
+
}
|
|
1664
|
+
customFiles = fileArgs.flatMap(
|
|
1665
|
+
(arg) => arg.includes(",") ? arg.split(",").map((f) => f.trim()) : [arg.trim()]
|
|
1666
|
+
).filter((f) => f.length > 0);
|
|
1667
|
+
}
|
|
1565
1668
|
async function init() {
|
|
1566
1669
|
if (!jsonOutput) {
|
|
1567
1670
|
console.log();
|
|
1568
|
-
|
|
1671
|
+
if (customFiles && customFiles.length > 0) {
|
|
1672
|
+
console.log("[+] Analyzing specified MCP configuration files...");
|
|
1673
|
+
} else {
|
|
1674
|
+
console.log("[+] Detecting MCP Server configurations...");
|
|
1675
|
+
}
|
|
1569
1676
|
}
|
|
1570
|
-
const mcpFilesManager = new MCPFiles();
|
|
1677
|
+
const mcpFilesManager = new MCPFiles(customFiles);
|
|
1571
1678
|
const mcpFilesList = await mcpFilesManager.findFiles();
|
|
1572
1679
|
if (Object.keys(mcpFilesList).length === 0) {
|
|
1573
1680
|
exitWithError("No configuration for MCP Server applications found.");
|
|
@@ -1580,6 +1687,11 @@ async function init() {
|
|
|
1580
1687
|
const transportCounts = { stdio: 0, sse: 0, http: 0 };
|
|
1581
1688
|
for (const groupName of Object.keys(mcpFilesList)) {
|
|
1582
1689
|
const group = mcpFilesList[groupName];
|
|
1690
|
+
const isCustomFilesMode = customFiles && customFiles.length > 0;
|
|
1691
|
+
const shouldSkipGroup = !showAll && !isCustomFilesMode && group.stats?.serversCount === 0;
|
|
1692
|
+
if (shouldSkipGroup) {
|
|
1693
|
+
continue;
|
|
1694
|
+
}
|
|
1583
1695
|
if (group.paths.length > 0) {
|
|
1584
1696
|
for (const filePathData of group.paths) {
|
|
1585
1697
|
pathIndex++;
|
|
@@ -1623,7 +1735,12 @@ async function init() {
|
|
|
1623
1735
|
}
|
|
1624
1736
|
}
|
|
1625
1737
|
if (pathIndex === 0) {
|
|
1626
|
-
|
|
1738
|
+
const isCustomFilesMode = customFiles && customFiles.length > 0;
|
|
1739
|
+
if (isCustomFilesMode) {
|
|
1740
|
+
exitWithError("No MCP servers found in specified configuration files.");
|
|
1741
|
+
} else {
|
|
1742
|
+
exitWithError("No MCP servers found in known configuration files.");
|
|
1743
|
+
}
|
|
1627
1744
|
}
|
|
1628
1745
|
const summaryStats = {
|
|
1629
1746
|
totalServers,
|
|
@@ -1633,8 +1750,14 @@ async function init() {
|
|
|
1633
1750
|
transportBreakdown: transportCounts
|
|
1634
1751
|
};
|
|
1635
1752
|
if (jsonOutput) {
|
|
1753
|
+
const isCustomFilesMode = customFiles && customFiles.length > 0;
|
|
1636
1754
|
const filteredMcpFiles = Object.fromEntries(
|
|
1637
|
-
Object.entries(mcpFilesList).filter(([, group]) =>
|
|
1755
|
+
Object.entries(mcpFilesList).filter(([, group]) => {
|
|
1756
|
+
if (showAll || isCustomFilesMode) {
|
|
1757
|
+
return group.paths.length > 0;
|
|
1758
|
+
}
|
|
1759
|
+
return (group.stats?.serversCount ?? 0) > 0;
|
|
1760
|
+
})
|
|
1638
1761
|
);
|
|
1639
1762
|
const output = {
|
|
1640
1763
|
mcpFiles: filteredMcpFiles,
|
package/dist/main.cjs
CHANGED
|
@@ -667,6 +667,61 @@ var MCPConfigService = class {
|
|
|
667
667
|
throw new Error(`Failed to get MCP file groups: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
|
+
/**
|
|
671
|
+
* Parse custom configuration files provided by the user
|
|
672
|
+
* This method processes files independently of standard app-based discovery
|
|
673
|
+
*/
|
|
674
|
+
async parseCustomFiles(filePaths) {
|
|
675
|
+
try {
|
|
676
|
+
const mcpFilesPathsData = {
|
|
677
|
+
custom: {
|
|
678
|
+
name: "custom",
|
|
679
|
+
friendlyName: "Custom Files",
|
|
680
|
+
paths: [],
|
|
681
|
+
stats: { serversCount: 0 }
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
let totalServersCount = 0;
|
|
685
|
+
for (const filePath of filePaths) {
|
|
686
|
+
const resolvedPath = filePath.replace("~", process.env.HOME || "");
|
|
687
|
+
const absolutePath = import_node_path.default.resolve(resolvedPath);
|
|
688
|
+
try {
|
|
689
|
+
await import_promises.default.access(absolutePath);
|
|
690
|
+
const parser = this.createParser(absolutePath);
|
|
691
|
+
const parsable = await parser.isValidSyntax();
|
|
692
|
+
const filePathData = {
|
|
693
|
+
filePath: absolutePath,
|
|
694
|
+
type: "local",
|
|
695
|
+
parsable
|
|
696
|
+
};
|
|
697
|
+
if (parsable) {
|
|
698
|
+
const configData = await parser.parseConfigFile();
|
|
699
|
+
const servers = await this.convertToMCPServerInfo(configData.servers || {});
|
|
700
|
+
filePathData.servers = servers;
|
|
701
|
+
totalServersCount += servers.length;
|
|
702
|
+
} else {
|
|
703
|
+
this.debug(`File ${absolutePath} has invalid syntax`);
|
|
704
|
+
filePathData.servers = [];
|
|
705
|
+
}
|
|
706
|
+
mcpFilesPathsData.custom.paths.push(filePathData);
|
|
707
|
+
} catch (error) {
|
|
708
|
+
this.debug(`Skipping file ${absolutePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
709
|
+
mcpFilesPathsData.custom.paths.push({
|
|
710
|
+
filePath: absolutePath,
|
|
711
|
+
type: "local",
|
|
712
|
+
parsable: false,
|
|
713
|
+
servers: []
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
if (mcpFilesPathsData.custom.stats) {
|
|
718
|
+
mcpFilesPathsData.custom.stats.serversCount = totalServersCount;
|
|
719
|
+
}
|
|
720
|
+
return mcpFilesPathsData;
|
|
721
|
+
} catch (error) {
|
|
722
|
+
throw new Error(`Failed to parse custom files: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
670
725
|
/**
|
|
671
726
|
* Register a custom app with custom paths for the current OS
|
|
672
727
|
*/
|
|
@@ -1151,14 +1206,47 @@ var MCPFiles = class {
|
|
|
1151
1206
|
__name(this, "MCPFiles");
|
|
1152
1207
|
}
|
|
1153
1208
|
mcpConfigService;
|
|
1154
|
-
|
|
1209
|
+
customFiles;
|
|
1210
|
+
constructor(customFiles) {
|
|
1155
1211
|
this.mcpConfigService = new MCPConfigService({ enableDirectoryBubbling: true });
|
|
1212
|
+
this.customFiles = customFiles;
|
|
1156
1213
|
}
|
|
1157
1214
|
/**
|
|
1158
1215
|
* Find and process all MCP configuration files
|
|
1216
|
+
* If customFiles are provided, only those files are processed (replaces automatic discovery)
|
|
1159
1217
|
*/
|
|
1160
1218
|
async findFiles() {
|
|
1161
1219
|
try {
|
|
1220
|
+
if (this.customFiles && this.customFiles.length > 0) {
|
|
1221
|
+
const mcpFilesPathsData2 = await this.mcpConfigService.parseCustomFiles(this.customFiles);
|
|
1222
|
+
for (const groupName of Object.keys(mcpFilesPathsData2)) {
|
|
1223
|
+
const group = mcpFilesPathsData2[groupName];
|
|
1224
|
+
for (const filePathData of group.paths) {
|
|
1225
|
+
if (filePathData.servers && filePathData.servers.length > 0) {
|
|
1226
|
+
for (const server of filePathData.servers) {
|
|
1227
|
+
const serverConfig = {
|
|
1228
|
+
name: server.name,
|
|
1229
|
+
command: server.command,
|
|
1230
|
+
args: server.args,
|
|
1231
|
+
transport: server.transport,
|
|
1232
|
+
type: server.type,
|
|
1233
|
+
env: server.env
|
|
1234
|
+
};
|
|
1235
|
+
const serverManager = new MCPServerManagerService(serverConfig);
|
|
1236
|
+
const processDetection = serverManager.isRunning();
|
|
1237
|
+
let isRunning = false;
|
|
1238
|
+
if (processDetection) {
|
|
1239
|
+
if (typeof processDetection === "object" && processDetection.estimatedProduct === group.name) {
|
|
1240
|
+
isRunning = true;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
server.status = isRunning ? "running" : "stopped";
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
return mcpFilesPathsData2;
|
|
1249
|
+
}
|
|
1162
1250
|
const mcpFilesPathsData = await this.mcpConfigService.getMCPFileGroups();
|
|
1163
1251
|
for (const groupName of Object.keys(mcpFilesPathsData)) {
|
|
1164
1252
|
const group = mcpFilesPathsData[groupName];
|
package/dist/main.d.cts
CHANGED
|
@@ -70,6 +70,7 @@ declare class MCPConfigService {
|
|
|
70
70
|
validateConfigFile(filePath: string): Promise<boolean>;
|
|
71
71
|
protected createParser(filePath: string): MCPConfigParser;
|
|
72
72
|
getMCPFileGroups(): Promise<MCPFileGroupsResultRecord>;
|
|
73
|
+
parseCustomFiles(filePaths: string[]): Promise<MCPFileGroupsResultRecord>;
|
|
73
74
|
registerCustomApp(appName: string, paths: MCPFilePath[]): void;
|
|
74
75
|
private parseConfigFileForServers;
|
|
75
76
|
private convertToMCPServerInfo;
|
|
@@ -78,7 +79,8 @@ declare class MCPConfigService {
|
|
|
78
79
|
|
|
79
80
|
declare class MCPFiles {
|
|
80
81
|
private mcpConfigService;
|
|
81
|
-
|
|
82
|
+
private customFiles?;
|
|
83
|
+
constructor(customFiles?: string[]);
|
|
82
84
|
findFiles(): Promise<MCPFileGroupsResultRecord>;
|
|
83
85
|
getMCPConfigService(): MCPConfigService;
|
|
84
86
|
}
|
package/dist/main.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ declare class MCPConfigService {
|
|
|
70
70
|
validateConfigFile(filePath: string): Promise<boolean>;
|
|
71
71
|
protected createParser(filePath: string): MCPConfigParser;
|
|
72
72
|
getMCPFileGroups(): Promise<MCPFileGroupsResultRecord>;
|
|
73
|
+
parseCustomFiles(filePaths: string[]): Promise<MCPFileGroupsResultRecord>;
|
|
73
74
|
registerCustomApp(appName: string, paths: MCPFilePath[]): void;
|
|
74
75
|
private parseConfigFileForServers;
|
|
75
76
|
private convertToMCPServerInfo;
|
|
@@ -78,7 +79,8 @@ declare class MCPConfigService {
|
|
|
78
79
|
|
|
79
80
|
declare class MCPFiles {
|
|
80
81
|
private mcpConfigService;
|
|
81
|
-
|
|
82
|
+
private customFiles?;
|
|
83
|
+
constructor(customFiles?: string[]);
|
|
82
84
|
findFiles(): Promise<MCPFileGroupsResultRecord>;
|
|
83
85
|
getMCPConfigService(): MCPConfigService;
|
|
84
86
|
}
|
package/dist/main.mjs
CHANGED
|
@@ -633,6 +633,61 @@ var MCPConfigService = class {
|
|
|
633
633
|
throw new Error(`Failed to get MCP file groups: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
|
+
/**
|
|
637
|
+
* Parse custom configuration files provided by the user
|
|
638
|
+
* This method processes files independently of standard app-based discovery
|
|
639
|
+
*/
|
|
640
|
+
async parseCustomFiles(filePaths) {
|
|
641
|
+
try {
|
|
642
|
+
const mcpFilesPathsData = {
|
|
643
|
+
custom: {
|
|
644
|
+
name: "custom",
|
|
645
|
+
friendlyName: "Custom Files",
|
|
646
|
+
paths: [],
|
|
647
|
+
stats: { serversCount: 0 }
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
let totalServersCount = 0;
|
|
651
|
+
for (const filePath of filePaths) {
|
|
652
|
+
const resolvedPath = filePath.replace("~", process.env.HOME || "");
|
|
653
|
+
const absolutePath = path.resolve(resolvedPath);
|
|
654
|
+
try {
|
|
655
|
+
await fs.access(absolutePath);
|
|
656
|
+
const parser = this.createParser(absolutePath);
|
|
657
|
+
const parsable = await parser.isValidSyntax();
|
|
658
|
+
const filePathData = {
|
|
659
|
+
filePath: absolutePath,
|
|
660
|
+
type: "local",
|
|
661
|
+
parsable
|
|
662
|
+
};
|
|
663
|
+
if (parsable) {
|
|
664
|
+
const configData = await parser.parseConfigFile();
|
|
665
|
+
const servers = await this.convertToMCPServerInfo(configData.servers || {});
|
|
666
|
+
filePathData.servers = servers;
|
|
667
|
+
totalServersCount += servers.length;
|
|
668
|
+
} else {
|
|
669
|
+
this.debug(`File ${absolutePath} has invalid syntax`);
|
|
670
|
+
filePathData.servers = [];
|
|
671
|
+
}
|
|
672
|
+
mcpFilesPathsData.custom.paths.push(filePathData);
|
|
673
|
+
} catch (error) {
|
|
674
|
+
this.debug(`Skipping file ${absolutePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
675
|
+
mcpFilesPathsData.custom.paths.push({
|
|
676
|
+
filePath: absolutePath,
|
|
677
|
+
type: "local",
|
|
678
|
+
parsable: false,
|
|
679
|
+
servers: []
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
if (mcpFilesPathsData.custom.stats) {
|
|
684
|
+
mcpFilesPathsData.custom.stats.serversCount = totalServersCount;
|
|
685
|
+
}
|
|
686
|
+
return mcpFilesPathsData;
|
|
687
|
+
} catch (error) {
|
|
688
|
+
throw new Error(`Failed to parse custom files: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
636
691
|
/**
|
|
637
692
|
* Register a custom app with custom paths for the current OS
|
|
638
693
|
*/
|
|
@@ -1117,14 +1172,47 @@ var MCPFiles = class {
|
|
|
1117
1172
|
__name(this, "MCPFiles");
|
|
1118
1173
|
}
|
|
1119
1174
|
mcpConfigService;
|
|
1120
|
-
|
|
1175
|
+
customFiles;
|
|
1176
|
+
constructor(customFiles) {
|
|
1121
1177
|
this.mcpConfigService = new MCPConfigService({ enableDirectoryBubbling: true });
|
|
1178
|
+
this.customFiles = customFiles;
|
|
1122
1179
|
}
|
|
1123
1180
|
/**
|
|
1124
1181
|
* Find and process all MCP configuration files
|
|
1182
|
+
* If customFiles are provided, only those files are processed (replaces automatic discovery)
|
|
1125
1183
|
*/
|
|
1126
1184
|
async findFiles() {
|
|
1127
1185
|
try {
|
|
1186
|
+
if (this.customFiles && this.customFiles.length > 0) {
|
|
1187
|
+
const mcpFilesPathsData2 = await this.mcpConfigService.parseCustomFiles(this.customFiles);
|
|
1188
|
+
for (const groupName of Object.keys(mcpFilesPathsData2)) {
|
|
1189
|
+
const group = mcpFilesPathsData2[groupName];
|
|
1190
|
+
for (const filePathData of group.paths) {
|
|
1191
|
+
if (filePathData.servers && filePathData.servers.length > 0) {
|
|
1192
|
+
for (const server of filePathData.servers) {
|
|
1193
|
+
const serverConfig = {
|
|
1194
|
+
name: server.name,
|
|
1195
|
+
command: server.command,
|
|
1196
|
+
args: server.args,
|
|
1197
|
+
transport: server.transport,
|
|
1198
|
+
type: server.type,
|
|
1199
|
+
env: server.env
|
|
1200
|
+
};
|
|
1201
|
+
const serverManager = new MCPServerManagerService(serverConfig);
|
|
1202
|
+
const processDetection = serverManager.isRunning();
|
|
1203
|
+
let isRunning = false;
|
|
1204
|
+
if (processDetection) {
|
|
1205
|
+
if (typeof processDetection === "object" && processDetection.estimatedProduct === group.name) {
|
|
1206
|
+
isRunning = true;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
server.status = isRunning ? "running" : "stopped";
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
return mcpFilesPathsData2;
|
|
1215
|
+
}
|
|
1128
1216
|
const mcpFilesPathsData = await this.mcpConfigService.getMCPFileGroups();
|
|
1129
1217
|
for (const groupName of Object.keys(mcpFilesPathsData)) {
|
|
1130
1218
|
const group = mcpFilesPathsData[groupName];
|
package/package.json
CHANGED
package/src/bin/cli.ts
CHANGED
|
@@ -19,15 +19,39 @@ interface MCPServerInfo {
|
|
|
19
19
|
// Parse command-line arguments
|
|
20
20
|
const args = process.argv.slice(2)
|
|
21
21
|
const jsonOutput = args.includes('--json')
|
|
22
|
+
const showAll = args.includes('--all') || args.includes('-a')
|
|
23
|
+
|
|
24
|
+
// Parse --files flag
|
|
25
|
+
let customFiles: string[] | undefined
|
|
26
|
+
const filesIndex = args.findIndex(arg => arg === '--files')
|
|
27
|
+
if (filesIndex !== -1 && filesIndex < args.length - 1) {
|
|
28
|
+
// Get all arguments after --files until we hit another flag or end of args
|
|
29
|
+
const fileArgs: string[] = []
|
|
30
|
+
for (let i = filesIndex + 1; i < args.length; i++) {
|
|
31
|
+
if (args[i].startsWith('--')) {
|
|
32
|
+
break
|
|
33
|
+
}
|
|
34
|
+
fileArgs.push(args[i])
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Support both comma-separated and space-separated file paths
|
|
38
|
+
customFiles = fileArgs.flatMap(arg =>
|
|
39
|
+
arg.includes(',') ? arg.split(',').map(f => f.trim()) : [arg.trim()]
|
|
40
|
+
).filter(f => f.length > 0)
|
|
41
|
+
}
|
|
22
42
|
|
|
23
43
|
async function init () {
|
|
24
44
|
// Start the CLI with a new line for better readability (only in non-JSON mode)
|
|
25
45
|
if (!jsonOutput) {
|
|
26
46
|
console.log()
|
|
27
|
-
|
|
47
|
+
if (customFiles && customFiles.length > 0) {
|
|
48
|
+
console.log('[+] Analyzing specified MCP configuration files...')
|
|
49
|
+
} else {
|
|
50
|
+
console.log('[+] Detecting MCP Server configurations...')
|
|
51
|
+
}
|
|
28
52
|
}
|
|
29
53
|
|
|
30
|
-
const mcpFilesManager = new MCPFiles()
|
|
54
|
+
const mcpFilesManager = new MCPFiles(customFiles)
|
|
31
55
|
const mcpFilesList = await mcpFilesManager.findFiles()
|
|
32
56
|
|
|
33
57
|
if (Object.keys(mcpFilesList).length === 0) {
|
|
@@ -44,6 +68,13 @@ async function init () {
|
|
|
44
68
|
for (const groupName of Object.keys(mcpFilesList)) {
|
|
45
69
|
const group = mcpFilesList[groupName]
|
|
46
70
|
|
|
71
|
+
// Skip groups with zero servers unless --all is specified or in --files mode
|
|
72
|
+
const isCustomFilesMode = customFiles && customFiles.length > 0
|
|
73
|
+
const shouldSkipGroup = !showAll && !isCustomFilesMode && (group.stats?.serversCount === 0)
|
|
74
|
+
if (shouldSkipGroup) {
|
|
75
|
+
continue
|
|
76
|
+
}
|
|
77
|
+
|
|
47
78
|
if (group.paths.length > 0) {
|
|
48
79
|
// handle file path list of MCP Servers
|
|
49
80
|
for (const filePathData of group.paths) {
|
|
@@ -104,7 +135,12 @@ async function init () {
|
|
|
104
135
|
}
|
|
105
136
|
|
|
106
137
|
if (pathIndex === 0) {
|
|
107
|
-
|
|
138
|
+
const isCustomFilesMode = customFiles && customFiles.length > 0
|
|
139
|
+
if (isCustomFilesMode) {
|
|
140
|
+
exitWithError('No MCP servers found in specified configuration files.')
|
|
141
|
+
} else {
|
|
142
|
+
exitWithError('No MCP servers found in known configuration files.')
|
|
143
|
+
}
|
|
108
144
|
}
|
|
109
145
|
|
|
110
146
|
// Prepare summary statistics
|
|
@@ -118,9 +154,15 @@ async function init () {
|
|
|
118
154
|
|
|
119
155
|
// Output based on mode
|
|
120
156
|
if (jsonOutput) {
|
|
121
|
-
// Filter out providers with
|
|
157
|
+
// Filter out providers with zero servers unless --all is specified or in --files mode
|
|
158
|
+
const isCustomFilesMode = customFiles && customFiles.length > 0
|
|
122
159
|
const filteredMcpFiles = Object.fromEntries(
|
|
123
|
-
Object.entries(mcpFilesList).filter(([, group]) =>
|
|
160
|
+
Object.entries(mcpFilesList).filter(([, group]) => {
|
|
161
|
+
if (showAll || isCustomFilesMode) {
|
|
162
|
+
return group.paths.length > 0
|
|
163
|
+
}
|
|
164
|
+
return (group.stats?.serversCount ?? 0) > 0
|
|
165
|
+
})
|
|
124
166
|
)
|
|
125
167
|
|
|
126
168
|
const output = {
|
package/src/main.ts
CHANGED
|
@@ -4,17 +4,61 @@ import { type MCPFileGroupsResultRecord } from './types/mcp-config-service.types
|
|
|
4
4
|
|
|
5
5
|
export class MCPFiles {
|
|
6
6
|
private mcpConfigService: MCPConfigService
|
|
7
|
+
private customFiles?: string[]
|
|
7
8
|
|
|
8
|
-
constructor () {
|
|
9
|
+
constructor (customFiles?: string[]) {
|
|
9
10
|
// Enable directory bubbling for better DX when running from nested directories
|
|
10
11
|
this.mcpConfigService = new MCPConfigService({ enableDirectoryBubbling: true })
|
|
12
|
+
this.customFiles = customFiles
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Find and process all MCP configuration files
|
|
17
|
+
* If customFiles are provided, only those files are processed (replaces automatic discovery)
|
|
15
18
|
*/
|
|
16
19
|
async findFiles (): Promise<MCPFileGroupsResultRecord> {
|
|
17
20
|
try {
|
|
21
|
+
// If custom files are specified, use them instead of automatic discovery
|
|
22
|
+
if (this.customFiles && this.customFiles.length > 0) {
|
|
23
|
+
const mcpFilesPathsData = await this.mcpConfigService.parseCustomFiles(this.customFiles)
|
|
24
|
+
|
|
25
|
+
// Process each group to add server status information
|
|
26
|
+
for (const groupName of Object.keys(mcpFilesPathsData)) {
|
|
27
|
+
const group = mcpFilesPathsData[groupName]
|
|
28
|
+
|
|
29
|
+
for (const filePathData of group.paths) {
|
|
30
|
+
if (filePathData.servers && filePathData.servers.length > 0) {
|
|
31
|
+
// Update server status for each server in this file
|
|
32
|
+
for (const server of filePathData.servers) {
|
|
33
|
+
const serverConfig = {
|
|
34
|
+
name: server.name,
|
|
35
|
+
command: server.command,
|
|
36
|
+
args: server.args,
|
|
37
|
+
transport: server.transport,
|
|
38
|
+
type: server.type,
|
|
39
|
+
env: server.env
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const serverManager = new MCPServerManagerService(serverConfig)
|
|
43
|
+
const processDetection = serverManager.isRunning()
|
|
44
|
+
|
|
45
|
+
// Determine if the server is running
|
|
46
|
+
let isRunning = false
|
|
47
|
+
if (processDetection) {
|
|
48
|
+
if (typeof processDetection === 'object' && processDetection.estimatedProduct === group.name) {
|
|
49
|
+
isRunning = true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
server.status = isRunning ? 'running' : 'stopped'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return mcpFilesPathsData
|
|
60
|
+
}
|
|
61
|
+
|
|
18
62
|
// Get MCP file groups with basic server information
|
|
19
63
|
const mcpFilesPathsData = await this.mcpConfigService.getMCPFileGroups()
|
|
20
64
|
|
|
@@ -225,6 +225,75 @@ export class MCPConfigService {
|
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Parse custom configuration files provided by the user
|
|
230
|
+
* This method processes files independently of standard app-based discovery
|
|
231
|
+
*/
|
|
232
|
+
async parseCustomFiles (filePaths: string[]): Promise<MCPFileGroupsResultRecord> {
|
|
233
|
+
try {
|
|
234
|
+
const mcpFilesPathsData: MCPFileGroupsResultRecord = {
|
|
235
|
+
custom: {
|
|
236
|
+
name: 'custom',
|
|
237
|
+
friendlyName: 'Custom Files',
|
|
238
|
+
paths: [],
|
|
239
|
+
stats: { serversCount: 0 }
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
let totalServersCount = 0
|
|
244
|
+
|
|
245
|
+
for (const filePath of filePaths) {
|
|
246
|
+
const resolvedPath = filePath.replace('~', process.env.HOME || '')
|
|
247
|
+
const absolutePath = path.resolve(resolvedPath)
|
|
248
|
+
|
|
249
|
+
try {
|
|
250
|
+
// Check if file exists
|
|
251
|
+
await fs.access(absolutePath)
|
|
252
|
+
|
|
253
|
+
const parser = this.createParser(absolutePath)
|
|
254
|
+
const parsable = await parser.isValidSyntax()
|
|
255
|
+
|
|
256
|
+
const filePathData: MCPFilePath = {
|
|
257
|
+
filePath: absolutePath,
|
|
258
|
+
type: 'local',
|
|
259
|
+
parsable
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (parsable) {
|
|
263
|
+
const configData = await parser.parseConfigFile()
|
|
264
|
+
const servers = await this.convertToMCPServerInfo(configData.servers || {})
|
|
265
|
+
filePathData.servers = servers
|
|
266
|
+
totalServersCount += servers.length
|
|
267
|
+
} else {
|
|
268
|
+
this.debug(`File ${absolutePath} has invalid syntax`)
|
|
269
|
+
filePathData.servers = []
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
mcpFilesPathsData.custom.paths.push(filePathData)
|
|
273
|
+
} catch (error) {
|
|
274
|
+
// File does not exist or is not accessible
|
|
275
|
+
this.debug(`Skipping file ${absolutePath}: ${error instanceof Error ? error.message : 'Unknown error'}`)
|
|
276
|
+
|
|
277
|
+
// Still add to paths with parsable=false to show user it was attempted
|
|
278
|
+
mcpFilesPathsData.custom.paths.push({
|
|
279
|
+
filePath: absolutePath,
|
|
280
|
+
type: 'local',
|
|
281
|
+
parsable: false,
|
|
282
|
+
servers: []
|
|
283
|
+
})
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (mcpFilesPathsData.custom.stats) {
|
|
288
|
+
mcpFilesPathsData.custom.stats.serversCount = totalServersCount
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return mcpFilesPathsData
|
|
292
|
+
} catch (error) {
|
|
293
|
+
throw new Error(`Failed to parse custom files: ${error instanceof Error ? error.message : 'Unknown error'}`)
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
228
297
|
/**
|
|
229
298
|
* Register a custom app with custom paths for the current OS
|
|
230
299
|
*/
|