fix(mcp): read .claude.json + mcp_servers.json, handle type/transport + array commands

This commit is contained in:
2026-05-23 11:41:57 +01:00
parent 9633f9ad4c
commit 8f5200a7f2
6 changed files with 186 additions and 68 deletions
+21 -4
View File
@@ -38,10 +38,27 @@ func importFrom(home string) (*adapter.ImportResult, error) {
}
res.Instructions = body
servers, err := common.ImportMCPFromJSONFile(filepath.Join(base, "settings.json"), "mcpServers")
if err != nil {
return nil, err
// Claude Code stores MCP servers across several files. Read all known
// locations and dedupe by name; ~/.claude.json is the live source so
// its entries win on conflict.
mcpSources := []string{
filepath.Join(home, ".claude.json"),
filepath.Join(base, "mcp_servers.json"),
filepath.Join(base, "settings.json"),
}
seen := map[string]bool{}
for _, p := range mcpSources {
servers, err := common.ImportMCPFromJSONFile(p, "mcpServers")
if err != nil {
return nil, err
}
for _, s := range servers {
if seen[s.Name] {
continue
}
seen[s.Name] = true
res.MCP = append(res.MCP, s)
}
}
res.MCP = servers
return res, nil
}