ls-mcp 1.11.0 → 1.13.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 +491 -74
- package/dist/bin/cli.mjs +491 -74
- package/dist/main.cjs +400 -41
- package/dist/main.d.cts +11 -0
- package/dist/main.d.ts +11 -0
- package/dist/main.mjs +400 -41
- package/package.json +1 -1
- package/src/bin/cli.ts +7 -0
- package/src/components/credential-warning.ts +35 -5
- package/src/components/mcp-server-version.ts +19 -0
- package/src/components/summary.ts +4 -1
- package/src/services/credential-detection-service.ts +230 -44
- package/src/services/mcp-config-service.ts +16 -1
- package/src/services/mcp-path-registry.ts +50 -1
- package/src/services/mcp-version-detection-service.ts +191 -0
- package/src/services/render-service.ts +13 -3
- package/src/types/mcp-config-service.types.ts +11 -0
|
@@ -4,51 +4,19 @@ export class CredentialDetectionService {
|
|
|
4
4
|
*/
|
|
5
5
|
private static readonly CREDENTIAL_PATTERNS = {
|
|
6
6
|
high: [
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/access[_-]?token/i,
|
|
11
|
-
/secret[_-]?key/i,
|
|
12
|
-
/private[_-]?key/i,
|
|
13
|
-
|
|
14
|
-
// Authentication Tokens
|
|
15
|
-
/auth[_-]?token/i,
|
|
16
|
-
/bearer[_-]?token/i,
|
|
17
|
-
/jwt[_-]?token/i,
|
|
18
|
-
/oauth[_-]?token/i,
|
|
7
|
+
// Generic Key and Token patterns (broad matching)
|
|
8
|
+
/.*key.*/i,
|
|
9
|
+
/.*token.*/i,
|
|
19
10
|
|
|
20
11
|
// Passwords
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// Credentials
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// Specific service patterns
|
|
30
|
-
/openai[_-]?api[_-]?key/i,
|
|
31
|
-
/anthropic[_-]?api[_-]?key/i,
|
|
32
|
-
/firecrawl[_-]?api[_-]?key/i,
|
|
33
|
-
/github[_-]?token/i,
|
|
34
|
-
/gitlab[_-]?token/i,
|
|
35
|
-
/bitbucket[_-]?token/i,
|
|
36
|
-
|
|
37
|
-
// Database passwords
|
|
38
|
-
/db[_-]?password/i,
|
|
39
|
-
/database[_-]?password/i,
|
|
40
|
-
/redis[_-]?password/i,
|
|
41
|
-
/postgres[_-]?password/i,
|
|
42
|
-
/mysql[_-]?password/i,
|
|
43
|
-
|
|
44
|
-
// Cloud services
|
|
45
|
-
/aws[_-]?secret[_-]?access[_-]?key/i,
|
|
46
|
-
/aws[_-]?access[_-]?key[_-]?id/i,
|
|
47
|
-
/azure[_-]?key/i,
|
|
48
|
-
/gcp[_-]?key/i,
|
|
49
|
-
/google[_-]?api[_-]?key/i,
|
|
50
|
-
/gemini[_-]?api[_-]?key/i,
|
|
51
|
-
/claude[_-]?api[_-]?key/i
|
|
12
|
+
/.*password.*/i,
|
|
13
|
+
/.*passwd.*/i,
|
|
14
|
+
/.*pwd.*/i,
|
|
15
|
+
|
|
16
|
+
// Credentials and Secrets
|
|
17
|
+
/.*credential.*/i,
|
|
18
|
+
/.*creds.*/i,
|
|
19
|
+
/.*secret.*/i
|
|
52
20
|
],
|
|
53
21
|
low: [
|
|
54
22
|
// Organization and Account IDs
|
|
@@ -60,6 +28,217 @@ export class CredentialDetectionService {
|
|
|
60
28
|
]
|
|
61
29
|
}
|
|
62
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Argument patterns for detecting credentials in command-line arguments
|
|
33
|
+
*/
|
|
34
|
+
private static readonly ARGUMENT_PATTERNS = {
|
|
35
|
+
high: [
|
|
36
|
+
// API key arguments
|
|
37
|
+
/--api-key/i,
|
|
38
|
+
/--apikey/i,
|
|
39
|
+
/--key/i,
|
|
40
|
+
|
|
41
|
+
// Token arguments
|
|
42
|
+
/--token/i,
|
|
43
|
+
/--access-token/i,
|
|
44
|
+
/--auth-token/i,
|
|
45
|
+
/--bearer-token/i,
|
|
46
|
+
|
|
47
|
+
// Password arguments
|
|
48
|
+
/--password/i,
|
|
49
|
+
/--passwd/i,
|
|
50
|
+
/--pwd/i,
|
|
51
|
+
|
|
52
|
+
// Secret arguments
|
|
53
|
+
/--secret/i,
|
|
54
|
+
/--client-secret/i,
|
|
55
|
+
|
|
56
|
+
// Authentication arguments
|
|
57
|
+
/--auth/i,
|
|
58
|
+
/--authorization/i,
|
|
59
|
+
/--credentials/i,
|
|
60
|
+
/--creds/i
|
|
61
|
+
],
|
|
62
|
+
low: [
|
|
63
|
+
// Organization and account IDs
|
|
64
|
+
/--org-id/i,
|
|
65
|
+
/--organization-id/i,
|
|
66
|
+
/--account-id/i,
|
|
67
|
+
/--user-id/i
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Header patterns for detecting credentials in HTTP headers
|
|
73
|
+
*/
|
|
74
|
+
private static readonly HEADER_PATTERNS = {
|
|
75
|
+
high: [
|
|
76
|
+
// Authorization headers
|
|
77
|
+
/authorization/i,
|
|
78
|
+
/auth/i,
|
|
79
|
+
|
|
80
|
+
// API key headers
|
|
81
|
+
/x-api-key/i,
|
|
82
|
+
/api-key/i,
|
|
83
|
+
/apikey/i,
|
|
84
|
+
|
|
85
|
+
// Token headers
|
|
86
|
+
/x-access-token/i,
|
|
87
|
+
/access-token/i,
|
|
88
|
+
/bearer-token/i,
|
|
89
|
+
/x-auth-token/i,
|
|
90
|
+
/auth-token/i,
|
|
91
|
+
|
|
92
|
+
// Custom authentication headers
|
|
93
|
+
/x-.*-key/i,
|
|
94
|
+
/x-.*-token/i,
|
|
95
|
+
/x-.*-secret/i,
|
|
96
|
+
|
|
97
|
+
// Service-specific patterns
|
|
98
|
+
/x-github-token/i,
|
|
99
|
+
/x-openai-key/i,
|
|
100
|
+
/x-anthropic-key/i
|
|
101
|
+
],
|
|
102
|
+
low: [
|
|
103
|
+
// User identification headers
|
|
104
|
+
/x-user-id/i,
|
|
105
|
+
/x-org-id/i,
|
|
106
|
+
/x-organization-id/i,
|
|
107
|
+
/x-account-id/i
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Variable substitution pattern to detect safe variable references
|
|
113
|
+
*/
|
|
114
|
+
private static readonly VARIABLE_SUBSTITUTION_PATTERN = /^\$\{[^}]+\}$/
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Check if a value is a variable substitution pattern (e.g., ${input:token})
|
|
118
|
+
*/
|
|
119
|
+
static isVariableSubstitution (value: string): boolean {
|
|
120
|
+
return this.VARIABLE_SUBSTITUTION_PATTERN.test(value)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Analyze command-line arguments for potential credentials
|
|
125
|
+
*/
|
|
126
|
+
static analyzeArguments (args: string[] | undefined): CredentialAnalysisResult {
|
|
127
|
+
if (!args || !Array.isArray(args) || args.length === 0) {
|
|
128
|
+
return {
|
|
129
|
+
hasCredentials: false,
|
|
130
|
+
credentialVars: [],
|
|
131
|
+
riskLevel: 'none'
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const credentialVars: CredentialVariable[] = []
|
|
136
|
+
|
|
137
|
+
// Check each argument and the next one for credential patterns
|
|
138
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
139
|
+
const arg = args[i]
|
|
140
|
+
const nextArg = args[i + 1]
|
|
141
|
+
|
|
142
|
+
// Check if current argument matches a credential flag pattern
|
|
143
|
+
const isHighRiskArg = this.ARGUMENT_PATTERNS.high.some(pattern => pattern.test(arg))
|
|
144
|
+
const isLowRiskArg = this.ARGUMENT_PATTERNS.low.some(pattern => pattern.test(arg))
|
|
145
|
+
|
|
146
|
+
if (isHighRiskArg || isLowRiskArg) {
|
|
147
|
+
// The next argument should be the value
|
|
148
|
+
if (nextArg && !nextArg.startsWith('-')) {
|
|
149
|
+
credentialVars.push({
|
|
150
|
+
name: arg,
|
|
151
|
+
value: this.maskValue(nextArg),
|
|
152
|
+
riskLevel: isHighRiskArg ? 'high' : 'low',
|
|
153
|
+
source: 'args'
|
|
154
|
+
})
|
|
155
|
+
i++ // Skip the next argument since we've processed it as a value
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const hasCredentials = credentialVars.length > 0
|
|
161
|
+
const riskLevel = this.calculateOverallRiskLevel(credentialVars)
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
hasCredentials,
|
|
165
|
+
credentialVars,
|
|
166
|
+
riskLevel
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Analyze HTTP headers for potential credentials
|
|
172
|
+
*/
|
|
173
|
+
static analyzeHeaders (headers: Record<string, string> | undefined): CredentialAnalysisResult {
|
|
174
|
+
if (!headers || typeof headers !== 'object') {
|
|
175
|
+
return {
|
|
176
|
+
hasCredentials: false,
|
|
177
|
+
credentialVars: [],
|
|
178
|
+
riskLevel: 'none'
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const credentialVars: CredentialVariable[] = []
|
|
183
|
+
|
|
184
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
185
|
+
// Skip variable substitution patterns (they're safe)
|
|
186
|
+
if (this.isVariableSubstitution(value)) {
|
|
187
|
+
continue
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const isHighRiskHeader = this.HEADER_PATTERNS.high.some(pattern => pattern.test(name))
|
|
191
|
+
const isLowRiskHeader = this.HEADER_PATTERNS.low.some(pattern => pattern.test(name))
|
|
192
|
+
|
|
193
|
+
if (isHighRiskHeader || isLowRiskHeader) {
|
|
194
|
+
credentialVars.push({
|
|
195
|
+
name,
|
|
196
|
+
value: this.maskValue(value),
|
|
197
|
+
riskLevel: isHighRiskHeader ? 'high' : 'low',
|
|
198
|
+
source: 'headers'
|
|
199
|
+
})
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const hasCredentials = credentialVars.length > 0
|
|
204
|
+
const riskLevel = this.calculateOverallRiskLevel(credentialVars)
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
hasCredentials,
|
|
208
|
+
credentialVars,
|
|
209
|
+
riskLevel
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Comprehensive analysis of server configuration for credentials
|
|
215
|
+
*/
|
|
216
|
+
static analyzeServerConfig (config: {
|
|
217
|
+
env?: Record<string, string>
|
|
218
|
+
args?: string[]
|
|
219
|
+
headers?: Record<string, string>
|
|
220
|
+
}): CredentialAnalysisResult {
|
|
221
|
+
const envResult = this.analyzeEnvironmentVariables(config.env)
|
|
222
|
+
const argsResult = this.analyzeArguments(config.args)
|
|
223
|
+
const headersResult = this.analyzeHeaders(config.headers)
|
|
224
|
+
|
|
225
|
+
// Combine all credential variables
|
|
226
|
+
const allCredentialVars = [
|
|
227
|
+
...envResult.credentialVars,
|
|
228
|
+
...argsResult.credentialVars,
|
|
229
|
+
...headersResult.credentialVars
|
|
230
|
+
]
|
|
231
|
+
|
|
232
|
+
const hasCredentials = allCredentialVars.length > 0
|
|
233
|
+
const riskLevel = this.calculateOverallRiskLevel(allCredentialVars)
|
|
234
|
+
|
|
235
|
+
return {
|
|
236
|
+
hasCredentials,
|
|
237
|
+
credentialVars: allCredentialVars,
|
|
238
|
+
riskLevel
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
63
242
|
/**
|
|
64
243
|
* Check if an environment variable name suggests it might contain credentials
|
|
65
244
|
*/
|
|
@@ -83,11 +262,17 @@ export class CredentialDetectionService {
|
|
|
83
262
|
const credentialVars: CredentialVariable[] = []
|
|
84
263
|
|
|
85
264
|
for (const [name, value] of Object.entries(env)) {
|
|
265
|
+
// Skip variable substitution patterns (they're safe)
|
|
266
|
+
if (this.isVariableSubstitution(value)) {
|
|
267
|
+
continue
|
|
268
|
+
}
|
|
269
|
+
|
|
86
270
|
if (this.isPotentialCredential(name)) {
|
|
87
271
|
credentialVars.push({
|
|
88
272
|
name,
|
|
89
273
|
value: this.maskValue(value),
|
|
90
|
-
riskLevel: this.assessRiskLevel(name)
|
|
274
|
+
riskLevel: this.assessRiskLevel(name),
|
|
275
|
+
source: 'env'
|
|
91
276
|
})
|
|
92
277
|
}
|
|
93
278
|
}
|
|
@@ -157,6 +342,7 @@ export interface CredentialVariable {
|
|
|
157
342
|
name: string
|
|
158
343
|
value: string
|
|
159
344
|
riskLevel: 'low' | 'high'
|
|
345
|
+
source?: 'env' | 'args' | 'headers'
|
|
160
346
|
}
|
|
161
347
|
|
|
162
348
|
export interface CredentialAnalysisResult {
|
|
@@ -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 || '',
|
|
@@ -272,8 +281,14 @@ export class MCPConfigService {
|
|
|
272
281
|
type: serverConfig.type,
|
|
273
282
|
source,
|
|
274
283
|
env: serverConfig.env,
|
|
284
|
+
headers: serverConfig.headers,
|
|
275
285
|
status: 'stopped', // Default status, will be updated by server manager
|
|
276
|
-
|
|
286
|
+
versionInfo: versionInfo || undefined,
|
|
287
|
+
credentials: CredentialDetectionService.analyzeServerConfig({
|
|
288
|
+
env: serverConfig.env,
|
|
289
|
+
args: serverConfig.args,
|
|
290
|
+
headers: serverConfig.headers
|
|
291
|
+
})
|
|
277
292
|
})
|
|
278
293
|
}
|
|
279
294
|
}
|
|
@@ -93,6 +93,53 @@ export class MCPPathRegistry {
|
|
|
93
93
|
]
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
private static readonly LINUX_PATHS: MCPAppPathsRecord = {
|
|
97
|
+
claude: [
|
|
98
|
+
{ filePath: path.join(process.env.HOME || '', '.config', 'Claude', 'claude_desktop_config.json'), type: 'global' }
|
|
99
|
+
],
|
|
100
|
+
claude_code: [
|
|
101
|
+
{ filePath: '.mcp.json', type: 'local' }
|
|
102
|
+
],
|
|
103
|
+
cursor: [
|
|
104
|
+
{ filePath: path.join(process.env.HOME || '', '.cursor', 'mcp.json'), type: 'global' },
|
|
105
|
+
{ filePath: path.join('.cursor', 'mcp.json'), type: 'local' }
|
|
106
|
+
],
|
|
107
|
+
vscode: [
|
|
108
|
+
{ filePath: path.join('.vscode', 'mcp.json'), type: 'local' },
|
|
109
|
+
{ filePath: path.join(process.env.HOME || '', '.config', 'Code', 'User', 'settings.json'), type: 'global' },
|
|
110
|
+
{ filePath: path.join(process.env.HOME || '', '.config', 'Code - Insiders', 'User', 'settings.json'), type: 'global' },
|
|
111
|
+
{ filePath: path.join(process.env.HOME || '', '.config', 'Code', 'User', 'mcp.json'), type: 'global' },
|
|
112
|
+
{ filePath: path.join(process.env.HOME || '', '.config', 'Code - Insiders', 'User', 'mcp.json'), type: 'global' },
|
|
113
|
+
{ filePath: path.join(process.env.HOME || '', '.mcp.json'), type: 'global' }
|
|
114
|
+
],
|
|
115
|
+
cline: [
|
|
116
|
+
{ filePath: path.join(process.env.HOME || '', '.config', 'Code', 'User', 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json'), type: 'global' },
|
|
117
|
+
{ filePath: path.join(process.env.HOME || '', '.config', 'Code - Insiders', 'User', 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json'), type: 'global' }
|
|
118
|
+
],
|
|
119
|
+
windsurf: [
|
|
120
|
+
{ filePath: path.join('.codeium', 'windsurf', 'mcp_config.json'), type: 'local' }
|
|
121
|
+
],
|
|
122
|
+
roo: [
|
|
123
|
+
{ filePath: path.join(process.env.HOME || '', '.config', 'Code', 'User', 'globalStorage', 'rooveterinaryinc.roo-cline', 'settings', 'cline_mcp_settings.json'), type: 'global' },
|
|
124
|
+
{ filePath: path.join(process.env.HOME || '', '.config', 'Code - Insiders', 'User', 'globalStorage', 'rooveterinaryinc.roo-cline', 'settings', 'cline_mcp_settings.json'), type: 'global' }
|
|
125
|
+
],
|
|
126
|
+
'intellij-github-copilot': [
|
|
127
|
+
{ filePath: path.join(process.env.HOME || '', '.config', 'github-copilot', 'intellij', 'mcp.json'), type: 'global' }
|
|
128
|
+
],
|
|
129
|
+
junie: [
|
|
130
|
+
{ filePath: path.join(process.env.HOME || '', '.junie', 'mcp.json'), type: 'global' },
|
|
131
|
+
{ filePath: path.join('.junie', 'mcp', 'mcp.json'), type: 'local' }
|
|
132
|
+
],
|
|
133
|
+
zed: [
|
|
134
|
+
{ filePath: path.join(process.env.HOME || '', '.config', 'zed', 'settings.json'), type: 'global' },
|
|
135
|
+
{ filePath: path.join('.zed', 'settings.json'), type: 'local' }
|
|
136
|
+
],
|
|
137
|
+
gemini: [
|
|
138
|
+
{ filePath: path.join(process.env.HOME || '', '.gemini', 'settings.json'), type: 'global' },
|
|
139
|
+
{ filePath: path.join('.gemini', 'settings.json'), type: 'local' }
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
|
|
96
143
|
private customApps: Map<string, MCPAppPathsRecord> = new Map()
|
|
97
144
|
|
|
98
145
|
/**
|
|
@@ -106,6 +153,8 @@ export class MCPPathRegistry {
|
|
|
106
153
|
case 'darwin':
|
|
107
154
|
case 'macos':
|
|
108
155
|
return { ...MCPPathRegistry.DARWIN_PATHS }
|
|
156
|
+
case 'linux':
|
|
157
|
+
return { ...MCPPathRegistry.LINUX_PATHS }
|
|
109
158
|
default:
|
|
110
159
|
throw new Error(`Unsupported operating system: ${os}`)
|
|
111
160
|
}
|
|
@@ -137,7 +186,7 @@ export class MCPPathRegistry {
|
|
|
137
186
|
* Get all supported operating systems
|
|
138
187
|
*/
|
|
139
188
|
getSupportedOperatingSystems (): string[] {
|
|
140
|
-
return ['win32', 'darwin']
|
|
189
|
+
return ['win32', 'darwin', 'linux']
|
|
141
190
|
}
|
|
142
191
|
|
|
143
192
|
/**
|
|
@@ -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,
|
|
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
|
}
|