@maplezzk/mcps 1.0.1 → 1.0.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/dist/core/config.js +21 -5
- package/dist/types/config.js +5 -5
- package/package.json +1 -1
package/dist/core/config.js
CHANGED
|
@@ -18,20 +18,36 @@ export class ConfigManager {
|
|
|
18
18
|
try {
|
|
19
19
|
const content = fs.readFileSync(CONFIG_FILE, 'utf-8');
|
|
20
20
|
const json = JSON.parse(content);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
// Log for debugging (can be removed later or controlled by verbose flag)
|
|
22
|
+
// console.log('Loading config from:', CONFIG_FILE);
|
|
23
|
+
if (!json || typeof json !== 'object') {
|
|
24
|
+
console.warn('Invalid config file structure. Expected JSON object.');
|
|
24
25
|
return { servers: [] };
|
|
25
26
|
}
|
|
27
|
+
// Handle both { servers: [...] } and { mcpServers: { ... } } (VSCode/Claude style)
|
|
28
|
+
let servers = [];
|
|
29
|
+
if (Array.isArray(json.servers)) {
|
|
30
|
+
servers = json.servers;
|
|
31
|
+
}
|
|
32
|
+
else if (json.mcpServers && typeof json.mcpServers === 'object') {
|
|
33
|
+
// Convert map to array and add default type='stdio' if missing
|
|
34
|
+
servers = Object.entries(json.mcpServers).map(([name, config]) => ({
|
|
35
|
+
name,
|
|
36
|
+
type: config.type || (config.command ? 'stdio' : undefined), // Auto-detect type
|
|
37
|
+
...config
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
26
40
|
const validServers = [];
|
|
27
|
-
const servers = json.servers;
|
|
28
41
|
for (const server of servers) {
|
|
29
42
|
const result = ServerConfigSchema.safeParse(server);
|
|
30
43
|
if (result.success) {
|
|
31
44
|
validServers.push(result.data);
|
|
32
45
|
}
|
|
33
46
|
else {
|
|
34
|
-
|
|
47
|
+
// Only warn if it looks like a server config we *should* have supported
|
|
48
|
+
if (server.name) {
|
|
49
|
+
console.warn(`Skipping invalid server config "${server.name}":`, result.error.errors[0]?.message);
|
|
50
|
+
}
|
|
35
51
|
}
|
|
36
52
|
}
|
|
37
53
|
return { servers: validServers };
|
package/dist/types/config.js
CHANGED
|
@@ -2,21 +2,21 @@ import { z } from 'zod';
|
|
|
2
2
|
export const ServerConfigSchema = z.union([
|
|
3
3
|
z.object({
|
|
4
4
|
name: z.string(),
|
|
5
|
-
type: z.literal('stdio'),
|
|
5
|
+
type: z.literal('stdio').optional().default('stdio'),
|
|
6
6
|
command: z.string(),
|
|
7
|
-
args: z.array(z.string()).default([]),
|
|
7
|
+
args: z.array(z.string()).optional().default([]),
|
|
8
8
|
env: z.record(z.string()).optional(),
|
|
9
|
-
}),
|
|
9
|
+
}).passthrough(),
|
|
10
10
|
z.object({
|
|
11
11
|
name: z.string(),
|
|
12
12
|
type: z.literal('sse'),
|
|
13
13
|
url: z.string().url(),
|
|
14
|
-
}),
|
|
14
|
+
}).passthrough(),
|
|
15
15
|
z.object({
|
|
16
16
|
name: z.string(),
|
|
17
17
|
type: z.literal('http'),
|
|
18
18
|
url: z.string().url(),
|
|
19
|
-
}),
|
|
19
|
+
}).passthrough(),
|
|
20
20
|
]);
|
|
21
21
|
export const ConfigSchema = z.object({
|
|
22
22
|
servers: z.array(ServerConfigSchema).default([]),
|