Expand description
Turning another harness’s config file contents into Leviath
MCPServerConfigs.
Everything here is a pure &str -> Result<Vec<..>> function. No path
resolution, no filesystem, no #[cfg] - those live in the parent module -
so every harness’s format is unit-testable on every platform, including the
ones whose config files could never exist there.
§The shapes
Nine harnesses, four families:
mcpServersobject - Claude Code (~/.claude.json, plus a nestedmcpServersper project),.mcp.json, Claude Desktop, Cursor, Windsurf, Gemini CLI. Entries are{command, args, env}or{url, headers}, with Gemini addinghttpUrland WindsurfserverUrl.serversobject - VS Code, same entry shape with an explicittype.mcpobject - OpenCode, whose entries are taggedlocal/remoteand whosecommandis an array (argv) rather than a string.context_serversobject - Zed, whose entry nests the launch under acommandobject ({path, args, env}).[mcp_servers]table - Codex, the one TOML source.
Rather than nine near-identical structs, one tolerant entry parser accepts the union of field names and every wrapper normalises into it. Unknown fields are dropped rather than rejected: these files are written by other tools that add keys on their own schedule, and refusing to import a server because it carries a setting Leviath does not model would be useless strictness.
Structs§
- Candidate
- One server offered for import, with enough provenance to show the user where it came from and what it would drag along.
Functions§
- parse_
claude_ code - Claude Code’s
~/.claude.json: a globalmcpServersobject plus a per-project one underprojects.<absolute path>.mcpServers. - parse_
codex - Codex’s
~/.codex/config.toml, whose servers live in an[mcp_servers]table. Reuses the JSON entry parser by converting the TOML table throughserde_json::Value- the field names are identical, and one tolerant entry parser beats two that must be kept in step. - parse_
json_ entry - Parse one server entry from any of the JSON-shaped harnesses.
- parse_
json_ object - A JSON file whose servers live under one top-level key.