feat(mcp): auto-register MCP servers into Claude + Codex from packages.yaml#36
Merged
Conversation
MCP servers live in per-machine ~/.claude.json (untracked, holds creds), so they don't propagate via dotfiles — every new machine (e.g. the jetson) lacks them. Add a data-driven mcp.claude list to packages.yaml; run_onchange_after_70 registers each via 'claude mcp add -s user' (idempotent: skips if 'mcp get' succeeds). Keyless remote (http) servers only — no secrets tracked; API-keyed servers stay manual. Seeds context7 (Upstash up-to-date library docs).
Generalise the Claude-only design: one top-level mcp: list in packages.yaml (name + url), registered into BOTH agents via their own CLIs — 'claude mcp add -s user --transport http' and 'codex mcp add --url' — each idempotent via 'mcp get'. codex writes ~/.codex/config.toml [mcp_servers], which survives modify_config.toml's merge (not in the unset chain; mergeOverwrite preserves it — verified). Keyless remote http only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Auto-register MCP servers across both Claude Code and Codex from one agent-agnostic list — no per-machine
mcp addby hand.Why
MCP servers live in per-machine config (
~/.claude.json,~/.codex/config.toml) — untracked (hold creds), so they don't propagate via dotfiles. Fresh machines (the jetson) lack them.Design — universal, data-driven
.chezmoidata/packages.yaml:run_onchange_after_70registers each into both agents (idempotent viamcp get):claude mcp add -s user --transport http <name> <url>codex mcp add <name> --url <url>Both agents have symmetric
mcp add/getCLIs → one list drives both.Safety
mcp getsucceeds → skip; fast (~0.4s miss / ~1.5s hit), no hang.~/.codex/config.toml [mcp_servers], which survivesmodify_config.toml— it's not in the unset chain andmergeOverwritepreserves it (verified empirically:keys after merge = [mcp_servers, model]).Verified
Both loops render valid commands,
sh -nOK, chezmoi parses the yaml, CI green (apply-dev runs the block without aborting). Seeds context7 (Upstash up-to-date library docs).Result
chezmoi apply/updateon any machine with claude and/or codex → context7 registered in both. Add more by appending tomcp:.