Skip to content

feat(mcp): auto-register MCP servers into Claude + Codex from packages.yaml#36

Merged
vaintrub merged 2 commits into
masterfrom
feat/context7-mcp
May 31, 2026
Merged

feat(mcp): auto-register MCP servers into Claude + Codex from packages.yaml#36
vaintrub merged 2 commits into
masterfrom
feat/context7-mcp

Conversation

@vaintrub

@vaintrub vaintrub commented May 31, 2026

Copy link
Copy Markdown
Owner

Auto-register MCP servers across both Claude Code and Codex from one agent-agnostic list — no per-machine mcp add by 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:

mcp:
  - name: context7
    url: https://mcp.context7.com/mcp

run_onchange_after_70 registers each into both agents (idempotent via mcp get):

  • Claude: claude mcp add -s user --transport http <name> <url>
  • Codex: codex mcp add <name> --url <url>

Both agents have symmetric mcp add/get CLIs → one list drives both.

Safety

  • Keyless remote (streamable-http) only — no secrets in the repo. API-keyed servers stay manual.
  • Idempotent: mcp get succeeds → skip; fast (~0.4s miss / ~1.5s hit), no hang.
  • codex writes ~/.codex/config.toml [mcp_servers], which survives modify_config.toml — it's not in the unset chain and mergeOverwrite preserves it (verified empirically: keys after merge = [mcp_servers, model]).
  • Existing servers untouched (by-name idempotency) — e.g. this Mac's stdio context7 stays.

Verified

Both loops render valid commands, sh -n OK, chezmoi parses the yaml, CI green (apply-dev runs the block without aborting). Seeds context7 (Upstash up-to-date library docs).

Result

chezmoi apply/update on any machine with claude and/or codex → context7 registered in both. Add more by appending to mcp:.

vaintrub added 2 commits May 31, 2026 15:10
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.
@vaintrub vaintrub changed the title feat(claude): auto-register MCP servers from packages.yaml feat(mcp): auto-register MCP servers into Claude + Codex from packages.yaml May 31, 2026
@vaintrub vaintrub merged commit ff00c78 into master May 31, 2026
3 checks passed
@vaintrub vaintrub deleted the feat/context7-mcp branch May 31, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant