ls-mcp 1.13.1 → 1.13.2

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 CHANGED
@@ -35,6 +35,18 @@
35
35
  npx ls-mcp
36
36
  ```
37
37
 
38
+ ### JSON Output
39
+
40
+ To output results in JSON format (useful for programmatic consumption):
41
+
42
+ ```bash
43
+ npx ls-mcp --json
44
+ ```
45
+
46
+ This will return a structured JSON object containing:
47
+ - `mcpFiles`: Complete MCP server configurations organized by provider (only includes providers with configured servers)
48
+ - `summary`: Statistics including total servers, running servers, credential warnings, and transport breakdown
49
+
38
50
  ### Debug Mode
39
51
 
40
52
  To enable verbose debugging output, set the `NODE_DEBUG` environment variable:
package/dist/bin/cli.cjs CHANGED
@@ -535,8 +535,8 @@ var CredentialDetectionService = class {
535
535
  /**
536
536
  * Analyze command-line arguments for potential credentials
537
537
  */
538
- static analyzeArguments(args) {
539
- if (!args || !Array.isArray(args) || args.length === 0) {
538
+ static analyzeArguments(args2) {
539
+ if (!args2 || !Array.isArray(args2) || args2.length === 0) {
540
540
  return {
541
541
  hasCredentials: false,
542
542
  credentialVars: [],
@@ -544,9 +544,9 @@ var CredentialDetectionService = class {
544
544
  };
545
545
  }
546
546
  const credentialVars = [];
547
- for (let i = 0; i < args.length - 1; i++) {
548
- const arg = args[i];
549
- const nextArg = args[i + 1];
547
+ for (let i = 0; i < args2.length - 1; i++) {
548
+ const arg = args2[i];
549
+ const nextArg = args2[i + 1];
550
550
  const isHighRiskArg = this.ARGUMENT_PATTERNS.high.some((pattern) => pattern.test(arg));
551
551
  const isLowRiskArg = this.ARGUMENT_PATTERNS.low.some((pattern) => pattern.test(arg));
552
552
  if (isHighRiskArg || isLowRiskArg) {
@@ -784,14 +784,14 @@ var MCPVersionDetectionService = class {
784
784
  * @param args - Array of arguments passed to the command
785
785
  * @returns PackageVersionInfo if analysis is possible, null otherwise
786
786
  */
787
- analyzeServerVersion(command, args) {
787
+ analyzeServerVersion(command, args2) {
788
788
  if (!["npx", "uvx", "uv"].includes(command)) {
789
789
  return null;
790
790
  }
791
- if (!args || args.length === 0) {
791
+ if (!args2 || args2.length === 0) {
792
792
  return null;
793
793
  }
794
- const packageName = this.extractPackageName(command, args);
794
+ const packageName = this.extractPackageName(command, args2);
795
795
  if (!packageName) {
796
796
  return null;
797
797
  }
@@ -810,14 +810,14 @@ var MCPVersionDetectionService = class {
810
810
  * @param args - Array of arguments passed to the command
811
811
  * @returns The package name/spec or null if not found
812
812
  */
813
- extractPackageName(command, args) {
813
+ extractPackageName(command, args2) {
814
814
  switch (command) {
815
815
  case "npx":
816
- return this.extractNpxPackageName(args);
816
+ return this.extractNpxPackageName(args2);
817
817
  case "uvx":
818
- return this.extractUvxPackageName(args);
818
+ return this.extractUvxPackageName(args2);
819
819
  case "uv":
820
- return this.extractUvPackageName(args);
820
+ return this.extractUvPackageName(args2);
821
821
  default:
822
822
  return null;
823
823
  }
@@ -827,23 +827,23 @@ var MCPVersionDetectionService = class {
827
827
  * @param args - Array of arguments passed to npx
828
828
  * @returns The package name/spec or null if not found
829
829
  */
830
- extractNpxPackageName(args) {
831
- if (!args || args.length === 0) {
830
+ extractNpxPackageName(args2) {
831
+ if (!args2 || args2.length === 0) {
832
832
  return null;
833
833
  }
834
- const yIndex = args.indexOf("-y");
835
- if (yIndex !== -1 && yIndex + 1 < args.length) {
836
- return args[yIndex + 1];
834
+ const yIndex = args2.indexOf("-y");
835
+ if (yIndex !== -1 && yIndex + 1 < args2.length) {
836
+ return args2[yIndex + 1];
837
837
  }
838
- const yesIndex = args.indexOf("--yes");
839
- if (yesIndex !== -1 && yesIndex + 1 < args.length) {
840
- return args[yesIndex + 1];
838
+ const yesIndex = args2.indexOf("--yes");
839
+ if (yesIndex !== -1 && yesIndex + 1 < args2.length) {
840
+ return args2[yesIndex + 1];
841
841
  }
842
- for (let i = 0; i < args.length; i++) {
843
- const arg = args[i];
842
+ for (let i = 0; i < args2.length; i++) {
843
+ const arg = args2[i];
844
844
  if (!arg.startsWith("-")) {
845
845
  if (i > 0) {
846
- const prevArg = args[i - 1];
846
+ const prevArg = args2[i - 1];
847
847
  if (prevArg === "--registry" || prevArg === "-r" || prevArg === "--package" || prevArg === "-p") {
848
848
  continue;
849
849
  }
@@ -858,24 +858,24 @@ var MCPVersionDetectionService = class {
858
858
  * @param args - Array of arguments passed to uvx
859
859
  * @returns The package name/spec or null if not found
860
860
  */
861
- extractUvxPackageName(args) {
862
- if (!args || args.length === 0) {
861
+ extractUvxPackageName(args2) {
862
+ if (!args2 || args2.length === 0) {
863
863
  return null;
864
864
  }
865
- return args[0];
865
+ return args2[0];
866
866
  }
867
867
  /**
868
868
  * Extract the package name from uv arguments
869
869
  * @param args - Array of arguments passed to uv
870
870
  * @returns The package name/spec or null if not found
871
871
  */
872
- extractUvPackageName(args) {
873
- if (!args || args.length === 0) {
872
+ extractUvPackageName(args2) {
873
+ if (!args2 || args2.length === 0) {
874
874
  return null;
875
875
  }
876
- const runIndex = args.indexOf("run");
877
- if (runIndex !== -1 && runIndex + 1 < args.length) {
878
- return args[runIndex + 1];
876
+ const runIndex = args2.indexOf("run");
877
+ if (runIndex !== -1 && runIndex + 1 < args2.length) {
878
+ return args2[runIndex + 1];
879
879
  }
880
880
  return null;
881
881
  }
@@ -2039,9 +2039,13 @@ var RenderService = class _RenderService {
2039
2039
  };
2040
2040
 
2041
2041
  // src/bin/cli.ts
2042
+ var args = process.argv.slice(2);
2043
+ var jsonOutput = args.includes("--json");
2042
2044
  async function init() {
2043
- console.log();
2044
- console.log("[+] Detecting MCP Server configurations...");
2045
+ if (!jsonOutput) {
2046
+ console.log();
2047
+ console.log("[+] Detecting MCP Server configurations...");
2048
+ }
2045
2049
  const mcpFilesManager = new MCPFiles();
2046
2050
  const mcpFilesList = await mcpFilesManager.findFiles();
2047
2051
  if (Object.keys(mcpFilesList).length === 0) {
@@ -2080,18 +2084,20 @@ async function init() {
2080
2084
  totalImplicitLatestVersions++;
2081
2085
  }
2082
2086
  }
2083
- const mcpGroupData = [
2084
- { key: "PROVIDER", value: group.friendlyName },
2085
- { key: "FILE", value: filePath },
2086
- { key: "TYPE", value: filePathDataType },
2087
- { key: "PARSABLE", value: filePathValid }
2088
- ];
2089
- const groupMetadata = {
2090
- mcpServersTotal: totalMCPServers,
2091
- mcpServersRunning: totalMCPServersRunning
2092
- };
2093
- RenderService.printMcpGroup(pathIndex, mcpGroupData, groupMetadata);
2094
- RenderService.printMcpServers(mcpServers);
2087
+ if (!jsonOutput) {
2088
+ const mcpGroupData = [
2089
+ { key: "PROVIDER", value: group.friendlyName },
2090
+ { key: "FILE", value: filePath },
2091
+ { key: "TYPE", value: filePathDataType },
2092
+ { key: "PARSABLE", value: filePathValid }
2093
+ ];
2094
+ const groupMetadata = {
2095
+ mcpServersTotal: totalMCPServers,
2096
+ mcpServersRunning: totalMCPServersRunning
2097
+ };
2098
+ RenderService.printMcpGroup(pathIndex, mcpGroupData, groupMetadata);
2099
+ RenderService.printMcpServers(mcpServers);
2100
+ }
2095
2101
  }
2096
2102
  }
2097
2103
  }
@@ -2105,7 +2111,18 @@ async function init() {
2105
2111
  implicitLatestVersions: totalImplicitLatestVersions,
2106
2112
  transportBreakdown: transportCounts
2107
2113
  };
2108
- RenderService.printSummary(summaryStats);
2114
+ if (jsonOutput) {
2115
+ const filteredMcpFiles = Object.fromEntries(
2116
+ Object.entries(mcpFilesList).filter(([, group]) => group.paths.length > 0)
2117
+ );
2118
+ const output = {
2119
+ mcpFiles: filteredMcpFiles,
2120
+ summary: summaryStats
2121
+ };
2122
+ console.log(JSON.stringify(output, null, 2));
2123
+ } else {
2124
+ RenderService.printSummary(summaryStats);
2125
+ }
2109
2126
  }
2110
2127
  __name(init, "init");
2111
2128
  init().then(() => {
package/dist/bin/cli.mjs CHANGED
@@ -513,8 +513,8 @@ var CredentialDetectionService = class {
513
513
  /**
514
514
  * Analyze command-line arguments for potential credentials
515
515
  */
516
- static analyzeArguments(args) {
517
- if (!args || !Array.isArray(args) || args.length === 0) {
516
+ static analyzeArguments(args2) {
517
+ if (!args2 || !Array.isArray(args2) || args2.length === 0) {
518
518
  return {
519
519
  hasCredentials: false,
520
520
  credentialVars: [],
@@ -522,9 +522,9 @@ var CredentialDetectionService = class {
522
522
  };
523
523
  }
524
524
  const credentialVars = [];
525
- for (let i = 0; i < args.length - 1; i++) {
526
- const arg = args[i];
527
- const nextArg = args[i + 1];
525
+ for (let i = 0; i < args2.length - 1; i++) {
526
+ const arg = args2[i];
527
+ const nextArg = args2[i + 1];
528
528
  const isHighRiskArg = this.ARGUMENT_PATTERNS.high.some((pattern) => pattern.test(arg));
529
529
  const isLowRiskArg = this.ARGUMENT_PATTERNS.low.some((pattern) => pattern.test(arg));
530
530
  if (isHighRiskArg || isLowRiskArg) {
@@ -762,14 +762,14 @@ var MCPVersionDetectionService = class {
762
762
  * @param args - Array of arguments passed to the command
763
763
  * @returns PackageVersionInfo if analysis is possible, null otherwise
764
764
  */
765
- analyzeServerVersion(command, args) {
765
+ analyzeServerVersion(command, args2) {
766
766
  if (!["npx", "uvx", "uv"].includes(command)) {
767
767
  return null;
768
768
  }
769
- if (!args || args.length === 0) {
769
+ if (!args2 || args2.length === 0) {
770
770
  return null;
771
771
  }
772
- const packageName = this.extractPackageName(command, args);
772
+ const packageName = this.extractPackageName(command, args2);
773
773
  if (!packageName) {
774
774
  return null;
775
775
  }
@@ -788,14 +788,14 @@ var MCPVersionDetectionService = class {
788
788
  * @param args - Array of arguments passed to the command
789
789
  * @returns The package name/spec or null if not found
790
790
  */
791
- extractPackageName(command, args) {
791
+ extractPackageName(command, args2) {
792
792
  switch (command) {
793
793
  case "npx":
794
- return this.extractNpxPackageName(args);
794
+ return this.extractNpxPackageName(args2);
795
795
  case "uvx":
796
- return this.extractUvxPackageName(args);
796
+ return this.extractUvxPackageName(args2);
797
797
  case "uv":
798
- return this.extractUvPackageName(args);
798
+ return this.extractUvPackageName(args2);
799
799
  default:
800
800
  return null;
801
801
  }
@@ -805,23 +805,23 @@ var MCPVersionDetectionService = class {
805
805
  * @param args - Array of arguments passed to npx
806
806
  * @returns The package name/spec or null if not found
807
807
  */
808
- extractNpxPackageName(args) {
809
- if (!args || args.length === 0) {
808
+ extractNpxPackageName(args2) {
809
+ if (!args2 || args2.length === 0) {
810
810
  return null;
811
811
  }
812
- const yIndex = args.indexOf("-y");
813
- if (yIndex !== -1 && yIndex + 1 < args.length) {
814
- return args[yIndex + 1];
812
+ const yIndex = args2.indexOf("-y");
813
+ if (yIndex !== -1 && yIndex + 1 < args2.length) {
814
+ return args2[yIndex + 1];
815
815
  }
816
- const yesIndex = args.indexOf("--yes");
817
- if (yesIndex !== -1 && yesIndex + 1 < args.length) {
818
- return args[yesIndex + 1];
816
+ const yesIndex = args2.indexOf("--yes");
817
+ if (yesIndex !== -1 && yesIndex + 1 < args2.length) {
818
+ return args2[yesIndex + 1];
819
819
  }
820
- for (let i = 0; i < args.length; i++) {
821
- const arg = args[i];
820
+ for (let i = 0; i < args2.length; i++) {
821
+ const arg = args2[i];
822
822
  if (!arg.startsWith("-")) {
823
823
  if (i > 0) {
824
- const prevArg = args[i - 1];
824
+ const prevArg = args2[i - 1];
825
825
  if (prevArg === "--registry" || prevArg === "-r" || prevArg === "--package" || prevArg === "-p") {
826
826
  continue;
827
827
  }
@@ -836,24 +836,24 @@ var MCPVersionDetectionService = class {
836
836
  * @param args - Array of arguments passed to uvx
837
837
  * @returns The package name/spec or null if not found
838
838
  */
839
- extractUvxPackageName(args) {
840
- if (!args || args.length === 0) {
839
+ extractUvxPackageName(args2) {
840
+ if (!args2 || args2.length === 0) {
841
841
  return null;
842
842
  }
843
- return args[0];
843
+ return args2[0];
844
844
  }
845
845
  /**
846
846
  * Extract the package name from uv arguments
847
847
  * @param args - Array of arguments passed to uv
848
848
  * @returns The package name/spec or null if not found
849
849
  */
850
- extractUvPackageName(args) {
851
- if (!args || args.length === 0) {
850
+ extractUvPackageName(args2) {
851
+ if (!args2 || args2.length === 0) {
852
852
  return null;
853
853
  }
854
- const runIndex = args.indexOf("run");
855
- if (runIndex !== -1 && runIndex + 1 < args.length) {
856
- return args[runIndex + 1];
854
+ const runIndex = args2.indexOf("run");
855
+ if (runIndex !== -1 && runIndex + 1 < args2.length) {
856
+ return args2[runIndex + 1];
857
857
  }
858
858
  return null;
859
859
  }
@@ -2017,9 +2017,13 @@ var RenderService = class _RenderService {
2017
2017
  };
2018
2018
 
2019
2019
  // src/bin/cli.ts
2020
+ var args = process.argv.slice(2);
2021
+ var jsonOutput = args.includes("--json");
2020
2022
  async function init() {
2021
- console.log();
2022
- console.log("[+] Detecting MCP Server configurations...");
2023
+ if (!jsonOutput) {
2024
+ console.log();
2025
+ console.log("[+] Detecting MCP Server configurations...");
2026
+ }
2023
2027
  const mcpFilesManager = new MCPFiles();
2024
2028
  const mcpFilesList = await mcpFilesManager.findFiles();
2025
2029
  if (Object.keys(mcpFilesList).length === 0) {
@@ -2058,18 +2062,20 @@ async function init() {
2058
2062
  totalImplicitLatestVersions++;
2059
2063
  }
2060
2064
  }
2061
- const mcpGroupData = [
2062
- { key: "PROVIDER", value: group.friendlyName },
2063
- { key: "FILE", value: filePath },
2064
- { key: "TYPE", value: filePathDataType },
2065
- { key: "PARSABLE", value: filePathValid }
2066
- ];
2067
- const groupMetadata = {
2068
- mcpServersTotal: totalMCPServers,
2069
- mcpServersRunning: totalMCPServersRunning
2070
- };
2071
- RenderService.printMcpGroup(pathIndex, mcpGroupData, groupMetadata);
2072
- RenderService.printMcpServers(mcpServers);
2065
+ if (!jsonOutput) {
2066
+ const mcpGroupData = [
2067
+ { key: "PROVIDER", value: group.friendlyName },
2068
+ { key: "FILE", value: filePath },
2069
+ { key: "TYPE", value: filePathDataType },
2070
+ { key: "PARSABLE", value: filePathValid }
2071
+ ];
2072
+ const groupMetadata = {
2073
+ mcpServersTotal: totalMCPServers,
2074
+ mcpServersRunning: totalMCPServersRunning
2075
+ };
2076
+ RenderService.printMcpGroup(pathIndex, mcpGroupData, groupMetadata);
2077
+ RenderService.printMcpServers(mcpServers);
2078
+ }
2073
2079
  }
2074
2080
  }
2075
2081
  }
@@ -2083,7 +2089,18 @@ async function init() {
2083
2089
  implicitLatestVersions: totalImplicitLatestVersions,
2084
2090
  transportBreakdown: transportCounts
2085
2091
  };
2086
- RenderService.printSummary(summaryStats);
2092
+ if (jsonOutput) {
2093
+ const filteredMcpFiles = Object.fromEntries(
2094
+ Object.entries(mcpFilesList).filter(([, group]) => group.paths.length > 0)
2095
+ );
2096
+ const output = {
2097
+ mcpFiles: filteredMcpFiles,
2098
+ summary: summaryStats
2099
+ };
2100
+ console.log(JSON.stringify(output, null, 2));
2101
+ } else {
2102
+ RenderService.printSummary(summaryStats);
2103
+ }
2087
2104
  }
2088
2105
  __name(init, "init");
2089
2106
  init().then(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ls-mcp",
3
- "version": "1.13.1",
3
+ "version": "1.13.2",
4
4
  "description": "list and detect MCP servers and configurations",
5
5
  "types": "dist/main.d.ts",
6
6
  "type": "module",
package/src/bin/cli.ts CHANGED
@@ -16,10 +16,16 @@ interface MCPServerInfo {
16
16
  credentials?: any
17
17
  }
18
18
 
19
+ // Parse command-line arguments
20
+ const args = process.argv.slice(2)
21
+ const jsonOutput = args.includes('--json')
22
+
19
23
  async function init () {
20
- // Start the CLI with a new line for better readability
21
- console.log()
22
- console.log('[+] Detecting MCP Server configurations...')
24
+ // Start the CLI with a new line for better readability (only in non-JSON mode)
25
+ if (!jsonOutput) {
26
+ console.log()
27
+ console.log('[+] Detecting MCP Server configurations...')
28
+ }
23
29
 
24
30
  const mcpFilesManager = new MCPFiles()
25
31
  const mcpFilesList = await mcpFilesManager.findFiles()
@@ -76,20 +82,23 @@ async function init () {
76
82
  }
77
83
  }
78
84
 
79
- const mcpGroupData = [
80
- { key: 'PROVIDER', value: group.friendlyName },
81
- { key: 'FILE', value: filePath },
82
- { key: 'TYPE', value: filePathDataType },
83
- { key: 'PARSABLE', value: filePathValid },
84
- ]
85
+ // Only render in non-JSON mode
86
+ if (!jsonOutput) {
87
+ const mcpGroupData = [
88
+ { key: 'PROVIDER', value: group.friendlyName },
89
+ { key: 'FILE', value: filePath },
90
+ { key: 'TYPE', value: filePathDataType },
91
+ { key: 'PARSABLE', value: filePathValid },
92
+ ]
93
+
94
+ const groupMetadata = {
95
+ mcpServersTotal: totalMCPServers,
96
+ mcpServersRunning: totalMCPServersRunning,
97
+ }
85
98
 
86
- const groupMetadata = {
87
- mcpServersTotal: totalMCPServers,
88
- mcpServersRunning: totalMCPServersRunning,
99
+ RenderService.printMcpGroup(pathIndex, mcpGroupData, groupMetadata)
100
+ RenderService.printMcpServers(mcpServers)
89
101
  }
90
-
91
- RenderService.printMcpGroup(pathIndex, mcpGroupData, groupMetadata)
92
- RenderService.printMcpServers(mcpServers)
93
102
  }
94
103
  }
95
104
  }
@@ -98,7 +107,7 @@ async function init () {
98
107
  exitWithError('No MCP servers found in known configuration files.')
99
108
  }
100
109
 
101
- // Display summary statistics
110
+ // Prepare summary statistics
102
111
  const summaryStats = {
103
112
  totalServers,
104
113
  runningServers: totalRunning,
@@ -107,7 +116,21 @@ async function init () {
107
116
  transportBreakdown: transportCounts
108
117
  }
109
118
 
110
- RenderService.printSummary(summaryStats)
119
+ // Output based on mode
120
+ if (jsonOutput) {
121
+ // Filter out providers with empty paths
122
+ const filteredMcpFiles = Object.fromEntries(
123
+ Object.entries(mcpFilesList).filter(([, group]) => group.paths.length > 0)
124
+ )
125
+
126
+ const output = {
127
+ mcpFiles: filteredMcpFiles,
128
+ summary: summaryStats
129
+ }
130
+ console.log(JSON.stringify(output, null, 2))
131
+ } else {
132
+ RenderService.printSummary(summaryStats)
133
+ }
111
134
  }
112
135
 
113
136
  init().then(() => {