ls-mcp 1.12.0 → 1.13.1

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/main.mjs CHANGED
@@ -747,6 +747,157 @@ var DirectoryBubbleService = class {
747
747
  }
748
748
  };
749
749
 
750
+ // src/services/mcp-version-detection-service.ts
751
+ var MCPVersionDetectionService = class {
752
+ static {
753
+ __name(this, "MCPVersionDetectionService");
754
+ }
755
+ /**
756
+ * Analyze a server configuration to extract version information
757
+ * @param command - The command used to run the server
758
+ * @param args - Array of arguments passed to the command
759
+ * @returns PackageVersionInfo if analysis is possible, null otherwise
760
+ */
761
+ analyzeServerVersion(command, args) {
762
+ if (!["npx", "uvx", "uv"].includes(command)) {
763
+ return null;
764
+ }
765
+ if (!args || args.length === 0) {
766
+ return null;
767
+ }
768
+ const packageName = this.extractPackageName(command, args);
769
+ if (!packageName) {
770
+ return null;
771
+ }
772
+ const { name, version } = this.parsePackageVersion(packageName);
773
+ const isPinned = this.isPinnedVersion(version);
774
+ return {
775
+ packageName: name,
776
+ version,
777
+ isPinned,
778
+ isLatest: !isPinned
779
+ };
780
+ }
781
+ /**
782
+ * Extract the package name based on the command type
783
+ * @param command - The command used to run the server
784
+ * @param args - Array of arguments passed to the command
785
+ * @returns The package name/spec or null if not found
786
+ */
787
+ extractPackageName(command, args) {
788
+ switch (command) {
789
+ case "npx":
790
+ return this.extractNpxPackageName(args);
791
+ case "uvx":
792
+ return this.extractUvxPackageName(args);
793
+ case "uv":
794
+ return this.extractUvPackageName(args);
795
+ default:
796
+ return null;
797
+ }
798
+ }
799
+ /**
800
+ * Extract the package name from npx arguments
801
+ * @param args - Array of arguments passed to npx
802
+ * @returns The package name/spec or null if not found
803
+ */
804
+ extractNpxPackageName(args) {
805
+ if (!args || args.length === 0) {
806
+ return null;
807
+ }
808
+ const yIndex = args.indexOf("-y");
809
+ if (yIndex !== -1 && yIndex + 1 < args.length) {
810
+ return args[yIndex + 1];
811
+ }
812
+ const yesIndex = args.indexOf("--yes");
813
+ if (yesIndex !== -1 && yesIndex + 1 < args.length) {
814
+ return args[yesIndex + 1];
815
+ }
816
+ for (let i = 0; i < args.length; i++) {
817
+ const arg = args[i];
818
+ if (!arg.startsWith("-")) {
819
+ if (i > 0) {
820
+ const prevArg = args[i - 1];
821
+ if (prevArg === "--registry" || prevArg === "-r" || prevArg === "--package" || prevArg === "-p") {
822
+ continue;
823
+ }
824
+ }
825
+ return arg;
826
+ }
827
+ }
828
+ return null;
829
+ }
830
+ /**
831
+ * Extract the package name from uvx arguments
832
+ * @param args - Array of arguments passed to uvx
833
+ * @returns The package name/spec or null if not found
834
+ */
835
+ extractUvxPackageName(args) {
836
+ if (!args || args.length === 0) {
837
+ return null;
838
+ }
839
+ return args[0];
840
+ }
841
+ /**
842
+ * Extract the package name from uv arguments
843
+ * @param args - Array of arguments passed to uv
844
+ * @returns The package name/spec or null if not found
845
+ */
846
+ extractUvPackageName(args) {
847
+ if (!args || args.length === 0) {
848
+ return null;
849
+ }
850
+ const runIndex = args.indexOf("run");
851
+ if (runIndex !== -1 && runIndex + 1 < args.length) {
852
+ return args[runIndex + 1];
853
+ }
854
+ return null;
855
+ }
856
+ /**
857
+ * Parse a package specification to extract name and version
858
+ * @param packageSpec - Package specification (e.g., "package@1.0.0" or "package")
859
+ * @returns Object with name and optional version
860
+ */
861
+ parsePackageVersion(packageSpec) {
862
+ if (!packageSpec) {
863
+ return { name: "", version: void 0 };
864
+ }
865
+ if (packageSpec.startsWith("@")) {
866
+ const parts = packageSpec.split("@");
867
+ if (parts.length === 2) {
868
+ return { name: packageSpec, version: void 0 };
869
+ } else if (parts.length === 3) {
870
+ return {
871
+ name: `@${parts[1]}`,
872
+ version: parts[2]
873
+ };
874
+ }
875
+ }
876
+ const atIndex = packageSpec.lastIndexOf("@");
877
+ if (atIndex > 0) {
878
+ return {
879
+ name: packageSpec.substring(0, atIndex),
880
+ version: packageSpec.substring(atIndex + 1)
881
+ };
882
+ }
883
+ return { name: packageSpec, version: void 0 };
884
+ }
885
+ /**
886
+ * Determine if a version represents a pinned version
887
+ * @param version - The version string to check
888
+ * @returns true if the version is pinned, false if it's latest/implicit
889
+ */
890
+ isPinnedVersion(version) {
891
+ if (!version) {
892
+ return false;
893
+ }
894
+ if (version === "latest") {
895
+ return false;
896
+ }
897
+ return true;
898
+ }
899
+ };
900
+
750
901
  // src/utils/url-utils.ts
751
902
  function extractHostname(urlString) {
752
903
  try {
@@ -771,12 +922,14 @@ var MCPConfigService = class {
771
922
  currentOS;
772
923
  debug;
773
924
  directoryBubbleService;
925
+ versionDetectionService;
774
926
  enableDirectoryBubbling;
775
927
  constructor(options = {}) {
776
928
  this.pathRegistry = new MCPPathRegistry();
777
929
  this.currentOS = platform();
778
930
  this.debug = util.debuglog("ls-mcp");
779
931
  this.directoryBubbleService = new DirectoryBubbleService();
932
+ this.versionDetectionService = new MCPVersionDetectionService();
780
933
  this.enableDirectoryBubbling = options.enableDirectoryBubbling ?? false;
781
934
  }
782
935
  /**
@@ -973,6 +1126,10 @@ var MCPConfigService = class {
973
1126
  } else {
974
1127
  source = serverConfig.command || "";
975
1128
  }
1129
+ const versionInfo = this.versionDetectionService.analyzeServerVersion(
1130
+ serverConfig.command || "",
1131
+ Array.isArray(serverConfig.args) ? serverConfig.args : void 0
1132
+ );
976
1133
  serverInfos.push({
977
1134
  name: serverName,
978
1135
  command: serverConfig.command || "",
@@ -985,6 +1142,7 @@ var MCPConfigService = class {
985
1142
  headers: serverConfig.headers,
986
1143
  status: "stopped",
987
1144
  // Default status, will be updated by server manager
1145
+ versionInfo: versionInfo || void 0,
988
1146
  credentials: CredentialDetectionService.analyzeServerConfig({
989
1147
  env: serverConfig.env,
990
1148
  args: serverConfig.args,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ls-mcp",
3
- "version": "1.12.0",
3
+ "version": "1.13.1",
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
@@ -32,6 +32,7 @@ async function init () {
32
32
  let totalServers = 0
33
33
  let totalRunning = 0
34
34
  let totalHighRiskCredentials = 0
35
+ let totalImplicitLatestVersions = 0
35
36
  const transportCounts = { stdio: 0, sse: 0, http: 0 }
36
37
 
37
38
  for (const groupName of Object.keys(mcpFilesList)) {
@@ -68,6 +69,11 @@ async function init () {
68
69
  if (server.credentials?.hasCredentials && server.credentials?.riskLevel === 'high') {
69
70
  totalHighRiskCredentials++
70
71
  }
72
+
73
+ // Count implicit latest versions
74
+ if (server.versionInfo?.isLatest) {
75
+ totalImplicitLatestVersions++
76
+ }
71
77
  }
72
78
 
73
79
  const mcpGroupData = [
@@ -97,6 +103,7 @@ async function init () {
97
103
  totalServers,
98
104
  runningServers: totalRunning,
99
105
  highRiskCredentials: totalHighRiskCredentials,
106
+ implicitLatestVersions: totalImplicitLatestVersions,
100
107
  transportBreakdown: transportCounts
101
108
  }
102
109
 
@@ -0,0 +1,19 @@
1
+ import { styleText } from 'node:util'
2
+ import type { PackageVersionInfo } from '../types/mcp-config-service.types.js'
3
+
4
+ export default function render (versionInfo?: PackageVersionInfo): string {
5
+ if (!versionInfo) {
6
+ return ''
7
+ }
8
+
9
+ const version = versionInfo.version || 'LATEST'
10
+ const displayVersion = version === 'latest' ? 'LATEST' : version
11
+
12
+ if (versionInfo.isPinned) {
13
+ // Green circle for pinned versions (stable/safe)
14
+ return styleText(['green'], '●') + ' ' + displayVersion
15
+ } else {
16
+ // Red circle for latest versions (higher risk)
17
+ return styleText(['red'], '●') + ' ' + 'LATEST'
18
+ }
19
+ }
@@ -4,6 +4,7 @@ interface SummaryStats {
4
4
  totalServers: number
5
5
  runningServers: number
6
6
  highRiskCredentials: number
7
+ implicitLatestVersions: number
7
8
  transportBreakdown: {
8
9
  stdio: number
9
10
  sse: number
@@ -12,11 +13,12 @@ interface SummaryStats {
12
13
  }
13
14
 
14
15
  export default function SummaryComponent (stats: SummaryStats): string {
15
- const { totalServers, runningServers, highRiskCredentials, transportBreakdown } = stats
16
+ const { totalServers, runningServers, highRiskCredentials, implicitLatestVersions, transportBreakdown } = stats
16
17
 
17
18
  // Create progress bars (20 characters wide, following existing convention)
18
- const runningBar = createProgressBar(runningServers, totalServers, 20, 'green')
19
- const securityBar = createProgressBar(highRiskCredentials, totalServers, 20, 'red')
19
+ const runningBar = createProgressBar(runningServers, totalServers, 20, 'green', false)
20
+ const securityBar = createProgressBar(highRiskCredentials, totalServers, 20, 'red', true)
21
+ const versionBar = createProgressBar(implicitLatestVersions, totalServers, 20, 'red', true)
20
22
 
21
23
  // Format transport breakdown
22
24
  const transportText = `stdio: ${transportBreakdown.stdio} | SSE: ${transportBreakdown.sse} | HTTP: ${transportBreakdown.http}`
@@ -26,13 +28,14 @@ export default function SummaryComponent (stats: SummaryStats): string {
26
28
  'SUMMARY',
27
29
  ` SERVERS ${runningBar} ${runningServers} / ${totalServers} Running`,
28
30
  ` SECURITY ${securityBar} ${highRiskCredentials} / ${totalServers} High Risk Credentials`,
31
+ ` VERSION ${versionBar} ${implicitLatestVersions} / ${totalServers} Implicit Latest`,
29
32
  ` TRANSPORT ${transportText}`
30
33
  ]
31
34
 
32
35
  return lines.join('\n')
33
36
  }
34
37
 
35
- function createProgressBar (count: number, total: number, width: number, color: 'green' | 'red'): string {
38
+ function createProgressBar (count: number, total: number, width: number, color: 'green' | 'red', emptyIsGood: boolean = false): string {
36
39
  if (total === 0) {
37
40
  const emptyBar = '░'.repeat(width)
38
41
  return emptyBar
@@ -50,7 +53,12 @@ function createProgressBar (count: number, total: number, width: number, color:
50
53
  empty = styleText(['green'], '░'.repeat(emptyWidth))
51
54
  } else { // red
52
55
  filled = styleText(['redBright'], '█'.repeat(filledWidth))
53
- empty = styleText(['red'], '░'.repeat(emptyWidth))
56
+ // If count is 0 and emptyIsGood is true, use green for empty sections (0 issues is good)
57
+ if (count === 0 && emptyIsGood) {
58
+ empty = styleText(['green'], '░'.repeat(emptyWidth))
59
+ } else {
60
+ empty = styleText(['red'], '░'.repeat(emptyWidth))
61
+ }
54
62
  }
55
63
 
56
64
  return `${filled}${empty}`
@@ -6,6 +6,7 @@ import { MCPPathRegistry } from './mcp-path-registry.js'
6
6
  import { MCPConfigParser } from './mcp-config-parser.js'
7
7
  import { CredentialDetectionService } from './credential-detection-service.js'
8
8
  import { DirectoryBubbleService } from './directory-bubble-service.js'
9
+ import { MCPVersionDetectionService } from './mcp-version-detection-service.js'
9
10
  import { extractHostname } from '../utils/url-utils.js'
10
11
  import {
11
12
  type MCPAppPathsRecord,
@@ -24,6 +25,7 @@ export class MCPConfigService {
24
25
  private currentOS: string
25
26
  private debug: util.DebugLogger
26
27
  private directoryBubbleService: DirectoryBubbleService
28
+ private versionDetectionService: MCPVersionDetectionService
27
29
  private enableDirectoryBubbling: boolean
28
30
 
29
31
  constructor (options: MCPConfigServiceOptions = {}) {
@@ -31,6 +33,7 @@ export class MCPConfigService {
31
33
  this.currentOS = platform()
32
34
  this.debug = util.debuglog('ls-mcp')
33
35
  this.directoryBubbleService = new DirectoryBubbleService()
36
+ this.versionDetectionService = new MCPVersionDetectionService()
34
37
  this.enableDirectoryBubbling = options.enableDirectoryBubbling ?? false
35
38
  }
36
39
 
@@ -264,6 +267,12 @@ export class MCPConfigService {
264
267
  source = serverConfig.command || ''
265
268
  }
266
269
 
270
+ // Analyze version information for stdio servers
271
+ const versionInfo = this.versionDetectionService.analyzeServerVersion(
272
+ serverConfig.command || '',
273
+ Array.isArray(serverConfig.args) ? serverConfig.args : undefined
274
+ )
275
+
267
276
  serverInfos.push({
268
277
  name: serverName,
269
278
  command: serverConfig.command || '',
@@ -274,6 +283,7 @@ export class MCPConfigService {
274
283
  env: serverConfig.env,
275
284
  headers: serverConfig.headers,
276
285
  status: 'stopped', // Default status, will be updated by server manager
286
+ versionInfo: versionInfo || undefined,
277
287
  credentials: CredentialDetectionService.analyzeServerConfig({
278
288
  env: serverConfig.env,
279
289
  args: serverConfig.args,
@@ -0,0 +1,191 @@
1
+ import { PackageVersionInfo } from '../types/mcp-config-service.types.js'
2
+
3
+ /**
4
+ * Service for detecting version information from MCP server configurations
5
+ * Specifically handles npx-based server commands to determine if they use
6
+ * pinned versions or implicit latest versions
7
+ */
8
+ export class MCPVersionDetectionService {
9
+ /**
10
+ * Analyze a server configuration to extract version information
11
+ * @param command - The command used to run the server
12
+ * @param args - Array of arguments passed to the command
13
+ * @returns PackageVersionInfo if analysis is possible, null otherwise
14
+ */
15
+ analyzeServerVersion (command: string, args?: string[]): PackageVersionInfo | null {
16
+ // Only analyze supported package manager commands
17
+ if (!['npx', 'uvx', 'uv'].includes(command)) {
18
+ return null
19
+ }
20
+
21
+ // Need args to extract package information
22
+ if (!args || args.length === 0) {
23
+ return null
24
+ }
25
+
26
+ const packageName = this.extractPackageName(command, args)
27
+ if (!packageName) {
28
+ return null
29
+ }
30
+
31
+ const { name, version } = this.parsePackageVersion(packageName)
32
+ const isPinned = this.isPinnedVersion(version)
33
+
34
+ return {
35
+ packageName: name,
36
+ version,
37
+ isPinned,
38
+ isLatest: !isPinned
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Extract the package name based on the command type
44
+ * @param command - The command used to run the server
45
+ * @param args - Array of arguments passed to the command
46
+ * @returns The package name/spec or null if not found
47
+ */
48
+ extractPackageName (command: string, args: string[]): string | null {
49
+ switch (command) {
50
+ case 'npx':
51
+ return this.extractNpxPackageName(args)
52
+ case 'uvx':
53
+ return this.extractUvxPackageName(args)
54
+ case 'uv':
55
+ return this.extractUvPackageName(args)
56
+ default:
57
+ return null
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Extract the package name from npx arguments
63
+ * @param args - Array of arguments passed to npx
64
+ * @returns The package name/spec or null if not found
65
+ */
66
+ extractNpxPackageName (args: string[]): string | null {
67
+ if (!args || args.length === 0) {
68
+ return null
69
+ }
70
+
71
+ // Look for -y flag and get the next argument
72
+ const yIndex = args.indexOf('-y')
73
+ if (yIndex !== -1 && yIndex + 1 < args.length) {
74
+ return args[yIndex + 1]
75
+ }
76
+
77
+ // Look for --yes flag and get the next argument
78
+ const yesIndex = args.indexOf('--yes')
79
+ if (yesIndex !== -1 && yesIndex + 1 < args.length) {
80
+ return args[yesIndex + 1]
81
+ }
82
+
83
+ // If no -y flag, find the first argument that doesn't start with -
84
+ // Skip over option values (arguments following options that take values)
85
+ for (let i = 0; i < args.length; i++) {
86
+ const arg = args[i]
87
+ if (!arg.startsWith('-')) {
88
+ // Check if this might be a value for a previous option
89
+ if (i > 0) {
90
+ const prevArg = args[i - 1]
91
+ // Known options that take values
92
+ if (prevArg === '--registry' || prevArg === '-r' || prevArg === '--package' || prevArg === '-p') {
93
+ continue // Skip this as it's an option value
94
+ }
95
+ }
96
+ return arg
97
+ }
98
+ }
99
+
100
+ return null
101
+ }
102
+
103
+ /**
104
+ * Extract the package name from uvx arguments
105
+ * @param args - Array of arguments passed to uvx
106
+ * @returns The package name/spec or null if not found
107
+ */
108
+ extractUvxPackageName (args: string[]): string | null {
109
+ if (!args || args.length === 0) {
110
+ return null
111
+ }
112
+
113
+ // For uvx, the first argument is always the package name
114
+ return args[0]
115
+ }
116
+
117
+ /**
118
+ * Extract the package name from uv arguments
119
+ * @param args - Array of arguments passed to uv
120
+ * @returns The package name/spec or null if not found
121
+ */
122
+ extractUvPackageName (args: string[]): string | null {
123
+ if (!args || args.length === 0) {
124
+ return null
125
+ }
126
+
127
+ // Find the 'run' argument and get the next one
128
+ const runIndex = args.indexOf('run')
129
+ if (runIndex !== -1 && runIndex + 1 < args.length) {
130
+ return args[runIndex + 1]
131
+ }
132
+
133
+ return null
134
+ }
135
+
136
+ /**
137
+ * Parse a package specification to extract name and version
138
+ * @param packageSpec - Package specification (e.g., "package@1.0.0" or "package")
139
+ * @returns Object with name and optional version
140
+ */
141
+ parsePackageVersion (packageSpec: string): { name: string; version?: string } {
142
+ if (!packageSpec) {
143
+ return { name: '', version: undefined }
144
+ }
145
+
146
+ // Handle scoped packages (e.g., @org/package@1.0.0)
147
+ if (packageSpec.startsWith('@')) {
148
+ const parts = packageSpec.split('@')
149
+ if (parts.length === 2) {
150
+ // Just @org/package with no version
151
+ return { name: packageSpec, version: undefined }
152
+ } else if (parts.length === 3) {
153
+ // @org/package@version
154
+ return {
155
+ name: `@${parts[1]}`,
156
+ version: parts[2]
157
+ }
158
+ }
159
+ }
160
+
161
+ // Handle regular packages (e.g., package@1.0.0)
162
+ const atIndex = packageSpec.lastIndexOf('@')
163
+ if (atIndex > 0) { // atIndex > 0 to avoid matching scoped packages starting with @
164
+ return {
165
+ name: packageSpec.substring(0, atIndex),
166
+ version: packageSpec.substring(atIndex + 1)
167
+ }
168
+ }
169
+
170
+ // No version specified
171
+ return { name: packageSpec, version: undefined }
172
+ }
173
+
174
+ /**
175
+ * Determine if a version represents a pinned version
176
+ * @param version - The version string to check
177
+ * @returns true if the version is pinned, false if it's latest/implicit
178
+ */
179
+ isPinnedVersion (version?: string): boolean {
180
+ if (!version) {
181
+ return false // No version = latest
182
+ }
183
+
184
+ if (version === 'latest') {
185
+ return false // Explicit latest
186
+ }
187
+
188
+ // Any other version specification is considered pinned
189
+ return true
190
+ }
191
+ }
@@ -4,6 +4,7 @@ import ColumnNameComponent from '../components/column-name.js'
4
4
  import MCPServerStatusComponent from '../components/mcp-server-status.js'
5
5
  import MCPServerNameComponent from '../components/mcp-server-name.js'
6
6
  import MCPServerSourceComponent from '../components/mcp-server-source.js'
7
+ import MCPServerVersionComponent from '../components/mcp-server-version.js'
7
8
  import FilePathComponent from '../components/file-path.js'
8
9
  import MCPServersConfigParsableComponent from '../components/mcp-servers-config-parsable.js'
9
10
  import CredentialWarningComponent from '../components/credential-warning.js'
@@ -18,6 +19,7 @@ interface SummaryStats {
18
19
  totalServers: number
19
20
  runningServers: number
20
21
  highRiskCredentials: number
22
+ implicitLatestVersions: number
21
23
  transportBreakdown: {
22
24
  stdio: number
23
25
  sse: number
@@ -41,9 +43,9 @@ export class RenderService {
41
43
  static printMcpServers (data: any[]) {
42
44
  if (data.length === 0) return
43
45
 
44
- const headers = ['STATUS', 'NAME', 'SOURCE', 'TRANSPORT', 'CREDENTIALS']
45
- const keys = ['status', 'name', 'source', 'transport', 'credentials']
46
- const centerColumns = [0, 2, 3] // STATUS and TRANSPORT column indices
46
+ const headers = ['STATUS', 'NAME', 'VERSION', 'SOURCE', 'TRANSPORT', 'CREDENTIALS']
47
+ const keys = ['status', 'name', 'versionInfo', 'source', 'transport', 'credentials']
48
+ const centerColumns = [0, 3, 4] // STATUS, SOURCE and TRANSPORT column indices
47
49
  const leftPadding = ' ' // 6 characters
48
50
 
49
51
  // Calculate column widths accounting for styled text
@@ -69,6 +71,10 @@ export class RenderService {
69
71
  text = MCPServerNameComponent(text)
70
72
  }
71
73
 
74
+ if (keys[index] === 'versionInfo') {
75
+ text = MCPServerVersionComponent(row[keys[index]])
76
+ }
77
+
72
78
  if (keys[index] === 'credentials') {
73
79
  text = CredentialWarningComponent(row[keys[index]])
74
80
  }
@@ -136,6 +142,10 @@ export class RenderService {
136
142
  text = MCPServerNameComponent(text)
137
143
  }
138
144
 
145
+ if (key === 'versionInfo') {
146
+ text = MCPServerVersionComponent(row[key])
147
+ }
148
+
139
149
  if (key === 'credentials') {
140
150
  text = CredentialWarningComponent(row[key])
141
151
  }
@@ -29,6 +29,13 @@ export interface MCPFilePath {
29
29
  servers?: MCPServerInfo[]
30
30
  }
31
31
 
32
+ export interface PackageVersionInfo {
33
+ packageName: string
34
+ version?: string
35
+ isPinned: boolean
36
+ isLatest: boolean
37
+ }
38
+
32
39
  export interface MCPServerInfo {
33
40
  name: string
34
41
  command: string
@@ -39,6 +46,7 @@ export interface MCPServerInfo {
39
46
  env?: Record<string, string>
40
47
  headers?: Record<string, string>
41
48
  status?: 'running' | 'stopped'
49
+ versionInfo?: PackageVersionInfo
42
50
  credentials?: CredentialAnalysisResult
43
51
  }
44
52