Skip to main content

Module formats

Module formats 

Source
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:

  • mcpServers object - Claude Code (~/.claude.json, plus a nested mcpServers per project), .mcp.json, Claude Desktop, Cursor, Windsurf, Gemini CLI. Entries are {command, args, env} or {url, headers}, with Gemini adding httpUrl and Windsurf serverUrl.
  • servers object - VS Code, same entry shape with an explicit type.
  • mcp object - OpenCode, whose entries are tagged local/remote and whose command is an array (argv) rather than a string.
  • context_servers object - Zed, whose entry nests the launch under a command object ({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 global mcpServers object plus a per-project one under projects.<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 through serde_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.