fix(kiro): parse .mcp.json wrapper key and support remote MCP servers (#259)

* fix(kiro): parse .mcp.json wrapper key and support remote MCP servers

* refactor: extract unwrapMcpServers helper to deduplicate parser logic

Address review feedback by extracting the mcpServers unwrap logic
into a shared helper used by both loadMcpServers and loadMcpPaths.
This commit is contained in:
Sphia Sadek
2026-03-17 00:09:07 -04:00
committed by GitHub
parent ff99b0a2e3
commit dfff20e1ad
3 changed files with 46 additions and 19 deletions

View File

@@ -158,7 +158,8 @@ async function loadMcpServers(
const mcpPath = path.join(root, ".mcp.json")
if (await pathExists(mcpPath)) {
return readJson<Record<string, ClaudeMcpServer>>(mcpPath)
const raw = await readJson<Record<string, unknown>>(mcpPath)
return unwrapMcpServers(raw)
}
return undefined
@@ -232,12 +233,20 @@ async function loadMcpPaths(
for (const entry of toPathList(value)) {
const resolved = resolveWithinRoot(root, entry, "mcpServers path")
if (await pathExists(resolved)) {
configs.push(await readJson<Record<string, ClaudeMcpServer>>(resolved))
const raw = await readJson<Record<string, unknown>>(resolved)
configs.push(unwrapMcpServers(raw))
}
}
return configs
}
function unwrapMcpServers(raw: Record<string, unknown>): Record<string, ClaudeMcpServer> {
if (raw.mcpServers && typeof raw.mcpServers === "object") {
return raw.mcpServers as Record<string, ClaudeMcpServer>
}
return raw as Record<string, ClaudeMcpServer>
}
function mergeMcpConfigs(configs: Record<string, ClaudeMcpServer>[]): Record<string, ClaudeMcpServer> {
return configs.reduce((acc, config) => ({ ...acc, ...config }), {})
}