ls-mcp 1.13.1 → 1.13.3
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 +12 -0
- package/dist/bin/cli.cjs +85 -525
- package/dist/bin/cli.mjs +75 -515
- package/dist/main.cjs +22 -479
- package/dist/main.d.cts +3 -38
- package/dist/main.d.ts +3 -38
- package/dist/main.mjs +12 -469
- package/package.json +2 -1
- package/src/bin/cli.ts +40 -17
- package/src/services/mcp-config-service.ts +6 -7
- package/src/types/mcp-config-service.types.ts +2 -20
- package/src/services/directory-bubble-service.ts +0 -82
- package/src/services/mcp-config-linter-service.ts +0 -34
- package/src/services/mcp-config-parser.ts +0 -234
- package/src/services/mcp-path-registry.ts +0 -213
package/dist/main.d.ts
CHANGED
|
@@ -1,27 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
parsed: boolean;
|
|
4
|
-
valid: boolean;
|
|
5
|
-
servers: Record<string, MCPServerConfig>;
|
|
6
|
-
}
|
|
7
|
-
interface MCPServerConfig {
|
|
8
|
-
name: string;
|
|
9
|
-
command: string;
|
|
10
|
-
args?: string[];
|
|
11
|
-
transport?: 'stdio' | 'sse' | 'http';
|
|
12
|
-
type?: 'sse' | 'http' | 'stdio' | 'streamable-http';
|
|
13
|
-
url?: string;
|
|
14
|
-
env?: Record<string, string>;
|
|
15
|
-
headers?: Record<string, string>;
|
|
16
|
-
}
|
|
1
|
+
import { MCPFilePath as MCPFilePath$1, MCPConfigParser } from 'agent-files';
|
|
2
|
+
|
|
17
3
|
interface MCPAppMetadata {
|
|
18
4
|
name: string;
|
|
19
5
|
friendlyName: string;
|
|
20
6
|
paths: MCPFilePath[];
|
|
21
7
|
}
|
|
22
|
-
interface MCPFilePath {
|
|
23
|
-
filePath: string;
|
|
24
|
-
type: 'local' | 'global';
|
|
8
|
+
interface MCPFilePath extends MCPFilePath$1 {
|
|
25
9
|
parsable?: boolean;
|
|
26
10
|
servers?: MCPServerInfo[];
|
|
27
11
|
}
|
|
@@ -66,25 +50,6 @@ interface CredentialAnalysisResult {
|
|
|
66
50
|
riskLevel: 'none' | 'low' | 'high';
|
|
67
51
|
}
|
|
68
52
|
|
|
69
|
-
declare class MCPConfigParser {
|
|
70
|
-
private filePath;
|
|
71
|
-
private fileContents;
|
|
72
|
-
private parsed;
|
|
73
|
-
private valid;
|
|
74
|
-
private fileContentsData;
|
|
75
|
-
constructor(filePath: string);
|
|
76
|
-
parseConfigFile(): Promise<MCPConfigData>;
|
|
77
|
-
extractMCPServers(configData: any): Promise<Record<string, MCPServerConfig>>;
|
|
78
|
-
private normalizeServerConfigs;
|
|
79
|
-
private validateType;
|
|
80
|
-
private inferTransportType;
|
|
81
|
-
validateServerConfig(serverConfig: MCPServerConfig): boolean;
|
|
82
|
-
getSupportedConfigKeys(): string[];
|
|
83
|
-
isValidSyntax(): Promise<boolean>;
|
|
84
|
-
countMCPServers(): Promise<number>;
|
|
85
|
-
private getFileContent;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
53
|
interface MCPConfigServiceOptions {
|
|
89
54
|
enableDirectoryBubbling?: boolean;
|
|
90
55
|
}
|
package/dist/main.mjs
CHANGED
|
@@ -3,397 +3,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/services/mcp-config-service.ts
|
|
5
5
|
import { platform } from "os";
|
|
6
|
-
import path3 from "path";
|
|
7
|
-
import fs3 from "fs/promises";
|
|
8
|
-
import util from "util";
|
|
9
|
-
|
|
10
|
-
// src/services/mcp-path-registry.ts
|
|
11
6
|
import path from "path";
|
|
12
|
-
var MCPPathRegistry = class _MCPPathRegistry {
|
|
13
|
-
static {
|
|
14
|
-
__name(this, "MCPPathRegistry");
|
|
15
|
-
}
|
|
16
|
-
static WINDOWS_PATHS = {
|
|
17
|
-
claude: [
|
|
18
|
-
{ filePath: path.join(process.env.APPDATA || "", "Claude", "claude_desktop_config.json"), type: "global" }
|
|
19
|
-
],
|
|
20
|
-
claude_code: [
|
|
21
|
-
{ filePath: ".mcp.json", type: "local" }
|
|
22
|
-
],
|
|
23
|
-
cursor: [
|
|
24
|
-
{ filePath: path.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
|
|
25
|
-
{ filePath: path.join(".cursor", "mcp.json"), type: "local" }
|
|
26
|
-
],
|
|
27
|
-
vscode: [
|
|
28
|
-
{ filePath: path.join(".vscode", "mcp.json"), type: "local" },
|
|
29
|
-
{ filePath: path.join(process.env.APPDATA || "", "Code", "User", "settings.json"), type: "global" },
|
|
30
|
-
{ filePath: path.join(process.env.APPDATA || "", "Code - Insiders", "User", "settings.json"), type: "global" },
|
|
31
|
-
{ filePath: path.join(process.env.APPDATA || "", "Code", "User", "mcp.json"), type: "global" },
|
|
32
|
-
{ filePath: path.join(process.env.APPDATA || "", "Code - Insiders", "User", "mcp.json"), type: "global" }
|
|
33
|
-
],
|
|
34
|
-
cline: [
|
|
35
|
-
{ filePath: path.join(process.env.APPDATA || "", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
36
|
-
{ filePath: path.join(process.env.APPDATA || "", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
37
|
-
],
|
|
38
|
-
windsurf: [
|
|
39
|
-
{ filePath: path.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
|
|
40
|
-
],
|
|
41
|
-
roo: [
|
|
42
|
-
{ filePath: path.join(process.env.APPDATA || "", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
43
|
-
{ filePath: path.join(process.env.APPDATA || "", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
44
|
-
],
|
|
45
|
-
"intellij-github-copilot": [
|
|
46
|
-
{ filePath: path.join(process.env.LOCALAPPDATA || "", "github-copilot", "intellij", "mcp.json"), type: "global" }
|
|
47
|
-
],
|
|
48
|
-
junie: [
|
|
49
|
-
{ filePath: path.join(process.env.HOME || "", ".junie", "mcp", "mcp.json"), type: "global" }
|
|
50
|
-
],
|
|
51
|
-
zed: [
|
|
52
|
-
{ filePath: path.join(process.env.LOCALAPPDATA || "", "zed", "settings.json"), type: "global" },
|
|
53
|
-
{ filePath: path.join(".zed", "settings.json"), type: "local" }
|
|
54
|
-
],
|
|
55
|
-
gemini: [
|
|
56
|
-
{ filePath: path.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
|
|
57
|
-
{ filePath: path.join(".gemini", "settings.json"), type: "local" }
|
|
58
|
-
]
|
|
59
|
-
};
|
|
60
|
-
static DARWIN_PATHS = {
|
|
61
|
-
claude: [
|
|
62
|
-
{ filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Claude", "claude_desktop_config.json"), type: "global" }
|
|
63
|
-
],
|
|
64
|
-
claude_code: [
|
|
65
|
-
{ filePath: ".mcp.json", type: "local" }
|
|
66
|
-
],
|
|
67
|
-
cursor: [
|
|
68
|
-
{ filePath: path.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
|
|
69
|
-
{ filePath: path.join(".cursor", "mcp.json"), type: "local" }
|
|
70
|
-
],
|
|
71
|
-
vscode: [
|
|
72
|
-
{ filePath: path.join(".vscode", "mcp.json"), type: "local" },
|
|
73
|
-
{ filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "settings.json"), type: "global" },
|
|
74
|
-
{ filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "mcp.json"), type: "global" },
|
|
75
|
-
{ filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "settings.json"), type: "global" },
|
|
76
|
-
{ filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "mcp.json"), type: "global" }
|
|
77
|
-
],
|
|
78
|
-
cline: [
|
|
79
|
-
{ filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
80
|
-
{ filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
81
|
-
],
|
|
82
|
-
windsurf: [
|
|
83
|
-
{ filePath: path.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
|
|
84
|
-
],
|
|
85
|
-
roo: [
|
|
86
|
-
{ filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
87
|
-
{ filePath: path.join(process.env.HOME || "", "Library", "Application Support", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
88
|
-
],
|
|
89
|
-
"intellij-github-copilot": [
|
|
90
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
|
|
91
|
-
],
|
|
92
|
-
junie: [
|
|
93
|
-
{ filePath: path.join(process.env.HOME || "", ".junie", "mcp", "mcp.json"), type: "global" },
|
|
94
|
-
{ filePath: path.join(".junie", "mcp", "mcp.json"), type: "local" }
|
|
95
|
-
],
|
|
96
|
-
zed: [
|
|
97
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "zed", "settings.json"), type: "global" },
|
|
98
|
-
{ filePath: path.join(".zed", "settings.json"), type: "local" }
|
|
99
|
-
],
|
|
100
|
-
gemini: [
|
|
101
|
-
{ filePath: path.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
|
|
102
|
-
{ filePath: path.join(".gemini", "settings.json"), type: "local" }
|
|
103
|
-
]
|
|
104
|
-
};
|
|
105
|
-
static LINUX_PATHS = {
|
|
106
|
-
claude: [
|
|
107
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Claude", "claude_desktop_config.json"), type: "global" }
|
|
108
|
-
],
|
|
109
|
-
claude_code: [
|
|
110
|
-
{ filePath: ".mcp.json", type: "local" }
|
|
111
|
-
],
|
|
112
|
-
cursor: [
|
|
113
|
-
{ filePath: path.join(process.env.HOME || "", ".cursor", "mcp.json"), type: "global" },
|
|
114
|
-
{ filePath: path.join(".cursor", "mcp.json"), type: "local" }
|
|
115
|
-
],
|
|
116
|
-
vscode: [
|
|
117
|
-
{ filePath: path.join(".vscode", "mcp.json"), type: "local" },
|
|
118
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "settings.json"), type: "global" },
|
|
119
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "settings.json"), type: "global" },
|
|
120
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "mcp.json"), type: "global" },
|
|
121
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "mcp.json"), type: "global" },
|
|
122
|
-
{ filePath: path.join(process.env.HOME || "", ".mcp.json"), type: "global" }
|
|
123
|
-
],
|
|
124
|
-
cline: [
|
|
125
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
126
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
127
|
-
],
|
|
128
|
-
windsurf: [
|
|
129
|
-
{ filePath: path.join(".codeium", "windsurf", "mcp_config.json"), type: "local" }
|
|
130
|
-
],
|
|
131
|
-
roo: [
|
|
132
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" },
|
|
133
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "Code - Insiders", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json"), type: "global" }
|
|
134
|
-
],
|
|
135
|
-
"intellij-github-copilot": [
|
|
136
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "github-copilot", "intellij", "mcp.json"), type: "global" }
|
|
137
|
-
],
|
|
138
|
-
junie: [
|
|
139
|
-
{ filePath: path.join(process.env.HOME || "", ".junie", "mcp.json"), type: "global" },
|
|
140
|
-
{ filePath: path.join(".junie", "mcp", "mcp.json"), type: "local" }
|
|
141
|
-
],
|
|
142
|
-
zed: [
|
|
143
|
-
{ filePath: path.join(process.env.HOME || "", ".config", "zed", "settings.json"), type: "global" },
|
|
144
|
-
{ filePath: path.join(".zed", "settings.json"), type: "local" }
|
|
145
|
-
],
|
|
146
|
-
gemini: [
|
|
147
|
-
{ filePath: path.join(process.env.HOME || "", ".gemini", "settings.json"), type: "global" },
|
|
148
|
-
{ filePath: path.join(".gemini", "settings.json"), type: "local" }
|
|
149
|
-
]
|
|
150
|
-
};
|
|
151
|
-
customApps = /* @__PURE__ */ new Map();
|
|
152
|
-
/**
|
|
153
|
-
* Get all MCP configuration file paths for a specific operating system
|
|
154
|
-
*/
|
|
155
|
-
getPathsForOS(os) {
|
|
156
|
-
switch (os.toLowerCase()) {
|
|
157
|
-
case "win32":
|
|
158
|
-
case "windows":
|
|
159
|
-
return { ..._MCPPathRegistry.WINDOWS_PATHS };
|
|
160
|
-
case "darwin":
|
|
161
|
-
case "macos":
|
|
162
|
-
return { ..._MCPPathRegistry.DARWIN_PATHS };
|
|
163
|
-
case "linux":
|
|
164
|
-
return { ..._MCPPathRegistry.LINUX_PATHS };
|
|
165
|
-
default:
|
|
166
|
-
throw new Error(`Unsupported operating system: ${os}`);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Get MCP configuration file paths for a specific app on a specific OS
|
|
171
|
-
*/
|
|
172
|
-
getPathsForApp(os, appName) {
|
|
173
|
-
const osPaths = this.getPathsForOS(os);
|
|
174
|
-
const appPaths = osPaths[appName];
|
|
175
|
-
if (!appPaths) {
|
|
176
|
-
throw new Error(`App '${appName}' not found for OS '${os}'`);
|
|
177
|
-
}
|
|
178
|
-
return [...appPaths];
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Get all supported app names for a specific OS
|
|
182
|
-
*/
|
|
183
|
-
getSupportedApps(os) {
|
|
184
|
-
const osPaths = this.getPathsForOS(os);
|
|
185
|
-
return Object.keys(osPaths);
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Get all supported operating systems
|
|
189
|
-
*/
|
|
190
|
-
getSupportedOperatingSystems() {
|
|
191
|
-
return ["win32", "darwin", "linux"];
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Register a custom app with custom paths for a specific OS
|
|
195
|
-
*/
|
|
196
|
-
registerCustomApp(os, appName, paths) {
|
|
197
|
-
if (!this.customApps.has(os)) {
|
|
198
|
-
this.customApps.set(os, {});
|
|
199
|
-
}
|
|
200
|
-
const osCustomApps = this.customApps.get(os);
|
|
201
|
-
osCustomApps[appName] = [...paths];
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Get paths including custom registered apps
|
|
205
|
-
*/
|
|
206
|
-
getPathsForOSWithCustom(os) {
|
|
207
|
-
const basePaths = this.getPathsForOS(os);
|
|
208
|
-
const customPaths = this.customApps.get(os) || {};
|
|
209
|
-
return { ...basePaths, ...customPaths };
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
// src/services/mcp-config-parser.ts
|
|
214
7
|
import fs from "fs/promises";
|
|
215
|
-
import
|
|
216
|
-
|
|
217
|
-
static {
|
|
218
|
-
__name(this, "MCPConfigParser");
|
|
219
|
-
}
|
|
220
|
-
filePath;
|
|
221
|
-
fileContents = null;
|
|
222
|
-
parsed = false;
|
|
223
|
-
valid = false;
|
|
224
|
-
fileContentsData = null;
|
|
225
|
-
constructor(filePath) {
|
|
226
|
-
this.filePath = filePath;
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Parse the configuration file and return structured data
|
|
230
|
-
*/
|
|
231
|
-
async parseConfigFile() {
|
|
232
|
-
if (this.parsed) {
|
|
233
|
-
return {
|
|
234
|
-
raw: this.fileContentsData,
|
|
235
|
-
parsed: this.parsed,
|
|
236
|
-
valid: this.valid,
|
|
237
|
-
servers: await this.extractMCPServers(this.fileContentsData)
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
this.parsed = true;
|
|
241
|
-
const fileContent = await this.getFileContent();
|
|
242
|
-
try {
|
|
243
|
-
this.fileContentsData = JSON.parse(fileContent);
|
|
244
|
-
if (typeof this.fileContentsData === "object") {
|
|
245
|
-
this.valid = true;
|
|
246
|
-
}
|
|
247
|
-
} catch (e) {
|
|
248
|
-
}
|
|
249
|
-
if (!this.valid) {
|
|
250
|
-
try {
|
|
251
|
-
this.fileContentsData = parse(fileContent);
|
|
252
|
-
if (typeof this.fileContentsData === "object") {
|
|
253
|
-
this.valid = true;
|
|
254
|
-
}
|
|
255
|
-
} catch (error) {
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
if (!this.valid) {
|
|
259
|
-
throw new Error(`Failed to parse configuration file: ${this.filePath}`);
|
|
260
|
-
}
|
|
261
|
-
return {
|
|
262
|
-
raw: this.fileContentsData,
|
|
263
|
-
parsed: this.parsed,
|
|
264
|
-
valid: this.valid,
|
|
265
|
-
servers: await this.extractMCPServers(this.fileContentsData)
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Extract MCP servers from parsed configuration data
|
|
270
|
-
*/
|
|
271
|
-
async extractMCPServers(configData) {
|
|
272
|
-
if (!configData || typeof configData !== "object") {
|
|
273
|
-
return {};
|
|
274
|
-
}
|
|
275
|
-
if (configData.servers && typeof configData.servers === "object") {
|
|
276
|
-
return this.normalizeServerConfigs(configData.servers);
|
|
277
|
-
}
|
|
278
|
-
if (configData.mcp?.servers && typeof configData.mcp.servers === "object") {
|
|
279
|
-
return this.normalizeServerConfigs(configData.mcp.servers);
|
|
280
|
-
}
|
|
281
|
-
if (configData.mcpServers && typeof configData.mcpServers === "object") {
|
|
282
|
-
return this.normalizeServerConfigs(configData.mcpServers);
|
|
283
|
-
}
|
|
284
|
-
if (configData.context_servers && typeof configData.context_servers === "object") {
|
|
285
|
-
return this.normalizeServerConfigs(configData.context_servers);
|
|
286
|
-
}
|
|
287
|
-
return {};
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Normalize server configurations to ensure consistent structure
|
|
291
|
-
*/
|
|
292
|
-
normalizeServerConfigs(servers) {
|
|
293
|
-
const normalized = {};
|
|
294
|
-
for (const [serverName, serverConfig] of Object.entries(servers)) {
|
|
295
|
-
if (serverConfig && typeof serverConfig === "object") {
|
|
296
|
-
const env = serverConfig.env && typeof serverConfig.env === "object" ? serverConfig.env : void 0;
|
|
297
|
-
normalized[serverName] = {
|
|
298
|
-
name: serverName,
|
|
299
|
-
command: serverConfig.command || "",
|
|
300
|
-
args: Array.isArray(serverConfig.args) ? serverConfig.args : void 0,
|
|
301
|
-
type: this.validateType(serverConfig.type) ? serverConfig.type : this.inferTransportType(serverConfig),
|
|
302
|
-
url: serverConfig.url,
|
|
303
|
-
env
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
return normalized;
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Validate type value
|
|
311
|
-
*/
|
|
312
|
-
validateType(type) {
|
|
313
|
-
return ["sse", "http", "stdio", "streamable-http"].includes(type);
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Infer transport type from server configuration when type field is not explicitly set
|
|
317
|
-
*/
|
|
318
|
-
inferTransportType(serverConfig) {
|
|
319
|
-
if (serverConfig.url && typeof serverConfig.url === "string") {
|
|
320
|
-
return "http";
|
|
321
|
-
}
|
|
322
|
-
if (Array.isArray(serverConfig.args)) {
|
|
323
|
-
const argsString = serverConfig.args.join(" ").toLowerCase();
|
|
324
|
-
if (argsString.includes("stdio")) {
|
|
325
|
-
return "stdio";
|
|
326
|
-
}
|
|
327
|
-
if (argsString.includes("http")) {
|
|
328
|
-
return "http";
|
|
329
|
-
}
|
|
330
|
-
if (argsString.includes("sse")) {
|
|
331
|
-
return "sse";
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
if (serverConfig.command && typeof serverConfig.command === "string") {
|
|
335
|
-
return "stdio";
|
|
336
|
-
}
|
|
337
|
-
return void 0;
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Validate server configuration
|
|
341
|
-
*/
|
|
342
|
-
validateServerConfig(serverConfig) {
|
|
343
|
-
if (!serverConfig || typeof serverConfig !== "object") {
|
|
344
|
-
return false;
|
|
345
|
-
}
|
|
346
|
-
if (!serverConfig.name || typeof serverConfig.name !== "string") {
|
|
347
|
-
return false;
|
|
348
|
-
}
|
|
349
|
-
if (!serverConfig.command || typeof serverConfig.command !== "string") {
|
|
350
|
-
return false;
|
|
351
|
-
}
|
|
352
|
-
return true;
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Get supported configuration keys that the parser recognizes
|
|
356
|
-
*/
|
|
357
|
-
getSupportedConfigKeys() {
|
|
358
|
-
return ["servers", "mcp.servers", "mcpServers", "context_servers"];
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Check if the configuration file has valid syntax
|
|
362
|
-
*/
|
|
363
|
-
async isValidSyntax() {
|
|
364
|
-
try {
|
|
365
|
-
const configData = await this.parseConfigFile();
|
|
366
|
-
return configData.valid;
|
|
367
|
-
} catch (error) {
|
|
368
|
-
return false;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Count the number of MCP servers in the configuration
|
|
373
|
-
*/
|
|
374
|
-
async countMCPServers() {
|
|
375
|
-
try {
|
|
376
|
-
const configData = await this.parseConfigFile();
|
|
377
|
-
return Object.keys(configData.servers).length;
|
|
378
|
-
} catch (error) {
|
|
379
|
-
return 0;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Get the raw file content
|
|
384
|
-
*/
|
|
385
|
-
async getFileContent() {
|
|
386
|
-
if (this.fileContents) {
|
|
387
|
-
return this.fileContents;
|
|
388
|
-
}
|
|
389
|
-
try {
|
|
390
|
-
this.fileContents = await fs.readFile(this.filePath, "utf-8");
|
|
391
|
-
return this.fileContents;
|
|
392
|
-
} catch (error) {
|
|
393
|
-
throw new Error(`Failed to read file: ${this.filePath}`);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
};
|
|
8
|
+
import util from "util";
|
|
9
|
+
import { MCPPathRegistry, MCPConfigParser, DirectoryBubbleService } from "agent-files";
|
|
397
10
|
|
|
398
11
|
// src/services/credential-detection-service.ts
|
|
399
12
|
var CredentialDetectionService = class {
|
|
@@ -676,77 +289,6 @@ var CredentialDetectionService = class {
|
|
|
676
289
|
}
|
|
677
290
|
};
|
|
678
291
|
|
|
679
|
-
// src/services/directory-bubble-service.ts
|
|
680
|
-
import path2 from "path";
|
|
681
|
-
import fs2 from "fs/promises";
|
|
682
|
-
import { homedir } from "os";
|
|
683
|
-
var DirectoryBubbleService = class {
|
|
684
|
-
static {
|
|
685
|
-
__name(this, "DirectoryBubbleService");
|
|
686
|
-
}
|
|
687
|
-
/**
|
|
688
|
-
* Find a local MCP config file by bubbling up the directory tree
|
|
689
|
-
* @param localPath - The relative path to search for (e.g., '.vscode/mcp.json')
|
|
690
|
-
* @param startDir - The directory to start searching from
|
|
691
|
-
* @returns The absolute path to the found config file, or null if not found
|
|
692
|
-
*/
|
|
693
|
-
async findLocalConfigInParentDirectories(localPath, startDir) {
|
|
694
|
-
try {
|
|
695
|
-
let currentDir = path2.resolve(startDir);
|
|
696
|
-
const homeDir = homedir();
|
|
697
|
-
const rootDir = "/";
|
|
698
|
-
let iterationCount = 0;
|
|
699
|
-
const maxIterations = 100;
|
|
700
|
-
const startDirResult = await this.checkDirectoryForConfig(currentDir, localPath);
|
|
701
|
-
if (startDirResult) {
|
|
702
|
-
return path2.join(currentDir, localPath);
|
|
703
|
-
}
|
|
704
|
-
while (currentDir !== homeDir && currentDir !== rootDir && iterationCount < maxIterations) {
|
|
705
|
-
const parentDir = this.getParentDirectory(currentDir);
|
|
706
|
-
if (!parentDir || parentDir === currentDir) {
|
|
707
|
-
break;
|
|
708
|
-
}
|
|
709
|
-
if (parentDir === currentDir || parentDir.length >= currentDir.length) {
|
|
710
|
-
break;
|
|
711
|
-
}
|
|
712
|
-
currentDir = parentDir;
|
|
713
|
-
iterationCount++;
|
|
714
|
-
const found = await this.checkDirectoryForConfig(currentDir, localPath);
|
|
715
|
-
if (found) {
|
|
716
|
-
return path2.join(currentDir, localPath);
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
return null;
|
|
720
|
-
} catch (error) {
|
|
721
|
-
return null;
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
/**
|
|
725
|
-
* Check if a config file exists in the specified directory
|
|
726
|
-
* @param dir - The directory to check
|
|
727
|
-
* @param configPath - The relative path to the config file
|
|
728
|
-
* @returns True if the config file exists and is accessible
|
|
729
|
-
*/
|
|
730
|
-
async checkDirectoryForConfig(dir, configPath) {
|
|
731
|
-
try {
|
|
732
|
-
const fullPath = path2.join(dir, configPath);
|
|
733
|
-
await fs2.access(fullPath);
|
|
734
|
-
return true;
|
|
735
|
-
} catch (error) {
|
|
736
|
-
return false;
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
/**
|
|
740
|
-
* Get the parent directory of the specified directory
|
|
741
|
-
* @param dir - The directory to get the parent of
|
|
742
|
-
* @returns The parent directory path, or null if already at root
|
|
743
|
-
*/
|
|
744
|
-
getParentDirectory(dir) {
|
|
745
|
-
const parent = path2.dirname(dir);
|
|
746
|
-
return parent === dir ? null : parent;
|
|
747
|
-
}
|
|
748
|
-
};
|
|
749
|
-
|
|
750
292
|
// src/services/mcp-version-detection-service.ts
|
|
751
293
|
var MCPVersionDetectionService = class {
|
|
752
294
|
static {
|
|
@@ -1015,7 +557,7 @@ var MCPConfigService = class {
|
|
|
1015
557
|
*/
|
|
1016
558
|
async validateConfigFile(filePath) {
|
|
1017
559
|
try {
|
|
1018
|
-
await
|
|
560
|
+
await fs.access(filePath);
|
|
1019
561
|
const parser = this.createParser(filePath);
|
|
1020
562
|
return await parser.isValidSyntax();
|
|
1021
563
|
} catch (error) {
|
|
@@ -1035,7 +577,8 @@ var MCPConfigService = class {
|
|
|
1035
577
|
try {
|
|
1036
578
|
const appPaths = this.getAllConfigFiles();
|
|
1037
579
|
const mcpFilesPathsData = {};
|
|
1038
|
-
for (const
|
|
580
|
+
for (const groupName of Object.keys(appPaths)) {
|
|
581
|
+
const paths = appPaths[groupName];
|
|
1039
582
|
mcpFilesPathsData[groupName] = {
|
|
1040
583
|
name: groupName,
|
|
1041
584
|
friendlyName: this.getFriendlyName(groupName),
|
|
@@ -1046,10 +589,10 @@ var MCPConfigService = class {
|
|
|
1046
589
|
let totalServersCount = 0;
|
|
1047
590
|
for (const filePathData of paths) {
|
|
1048
591
|
let resolvedPath = filePathData.filePath.replace("~", process.env.HOME || "");
|
|
1049
|
-
let absolutePath =
|
|
592
|
+
let absolutePath = path.resolve(resolvedPath);
|
|
1050
593
|
if (filePathData.type === "local" && this.enableDirectoryBubbling) {
|
|
1051
594
|
try {
|
|
1052
|
-
await
|
|
595
|
+
await fs.access(resolvedPath);
|
|
1053
596
|
} catch (error) {
|
|
1054
597
|
const bubbledPath = await this.directoryBubbleService.findLocalConfigInParentDirectories(
|
|
1055
598
|
filePathData.filePath,
|
|
@@ -1057,7 +600,7 @@ var MCPConfigService = class {
|
|
|
1057
600
|
);
|
|
1058
601
|
if (bubbledPath) {
|
|
1059
602
|
resolvedPath = bubbledPath;
|
|
1060
|
-
absolutePath =
|
|
603
|
+
absolutePath = path.resolve(resolvedPath);
|
|
1061
604
|
}
|
|
1062
605
|
}
|
|
1063
606
|
}
|
|
@@ -1066,7 +609,7 @@ var MCPConfigService = class {
|
|
|
1066
609
|
}
|
|
1067
610
|
uniqueFilePaths.add(absolutePath);
|
|
1068
611
|
try {
|
|
1069
|
-
await
|
|
612
|
+
await fs.access(resolvedPath);
|
|
1070
613
|
const parser = this.createParser(resolvedPath);
|
|
1071
614
|
const parsable = await parser.isValidSyntax();
|
|
1072
615
|
filePathData.parsable = parsable;
|
|
@@ -1175,7 +718,7 @@ var MCPConfigService = class {
|
|
|
1175
718
|
};
|
|
1176
719
|
|
|
1177
720
|
// src/services/mcp-server-manager-service.ts
|
|
1178
|
-
import
|
|
721
|
+
import path2 from "path";
|
|
1179
722
|
import { execSync } from "child_process";
|
|
1180
723
|
import { platform as platform2 } from "os";
|
|
1181
724
|
var MCPServerManagerService = class {
|
|
@@ -1385,9 +928,9 @@ var MCPServerManagerService = class {
|
|
|
1385
928
|
return true;
|
|
1386
929
|
}
|
|
1387
930
|
getBaseCommand(fullCommandPath) {
|
|
1388
|
-
let baseCommand =
|
|
931
|
+
let baseCommand = path2.basename(fullCommandPath);
|
|
1389
932
|
if (platform2() === "win32") {
|
|
1390
|
-
baseCommand =
|
|
933
|
+
baseCommand = path2.basename(fullCommandPath, ".exe");
|
|
1391
934
|
}
|
|
1392
935
|
baseCommand = baseCommand.toLowerCase();
|
|
1393
936
|
return baseCommand;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ls-mcp",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.3",
|
|
4
4
|
"description": "list and detect MCP servers and configurations",
|
|
5
5
|
"types": "dist/main.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"url": "https://github.com/lirantal/ls-mcp.git"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
+
"agent-files": "^1.0.1",
|
|
78
79
|
"jsonc-parser": "^3.3.1"
|
|
79
80
|
},
|
|
80
81
|
"devDependencies": {
|