Validate + normalize a whole `mcpServers` record.
( raw: unknown, )
| 122 | |
| 123 | /** Validate + normalize a whole `mcpServers` record. */ |
| 124 | function normalizeServers( |
| 125 | raw: unknown, |
| 126 | ): Record<string, McpServerConfig> { |
| 127 | if (!isPlainObject(raw)) return {} |
| 128 | const servers: Record<string, McpServerConfig> = {} |
| 129 | for (const [name, cfg] of Object.entries(raw)) { |
| 130 | if (!/^[A-Za-z0-9_-]+$/.test(name)) continue |
| 131 | const normalized = normalizeServerConfig(cfg) |
| 132 | if (normalized) servers[name] = normalized |
| 133 | } |
| 134 | return servers |
| 135 | } |
| 136 | |
| 137 | /** Read `mcpServers` from a settings.json file (user or local scope). */ |
| 138 | function readSettingsServers(filePath: string): Record<string, McpServerConfig> { |
no test coverage detected