diff --git a/.chezmoidata/packages.yaml b/.chezmoidata/packages.yaml index e07bb77..adb9294 100644 --- a/.chezmoidata/packages.yaml +++ b/.chezmoidata/packages.yaml @@ -94,3 +94,11 @@ plugins: - google-drive@openai-curated codex_marketplaces: [] + +# MCP servers, registered into BOTH Claude Code + Codex by +# run_onchange_after_70 (each via its own `mcp add` CLI, idempotent). +# Agent-agnostic: keyless remote (streamable-http) servers only — no secrets +# in this repo. API-keyed servers stay per-machine (` mcp add` by hand). +mcp: + - name: context7 # up-to-date library/framework docs (Upstash) + url: https://mcp.context7.com/mcp diff --git a/.chezmoiscripts/run_onchange_after_70-install-plugins.sh.tmpl b/.chezmoiscripts/run_onchange_after_70-install-plugins.sh.tmpl index 8e0f408..e699f5b 100644 --- a/.chezmoiscripts/run_onchange_after_70-install-plugins.sh.tmpl +++ b/.chezmoiscripts/run_onchange_after_70-install-plugins.sh.tmpl @@ -1,5 +1,5 @@ {{- /* - Install Claude Code + Codex plugins from .chezmoidata/packages.yaml. + Install Claude Code + Codex plugins + MCP servers from .chezmoidata/packages.yaml. Claude: `plugin marketplace add` (defensively re-adds claude-plugins-official in case claude was never launched interactively) + `plugin install`/`update`. Codex: only non-reserved marketplaces need `plugin marketplace add`; enable @@ -38,6 +38,16 @@ if command -v claude >/dev/null 2>&1; then claude plugin update {{ . }} >/dev/null 2>&1 || true {{ end -}} claude plugin marketplace update >/dev/null 2>&1 || true + + # MCP servers (shared list, registered per-agent). User scope = all + # projects. Idempotent: `mcp get` succeeds if already registered. +{{ range .mcp -}} + if ! claude mcp get {{ .name | quote }} >/dev/null 2>&1; then + claude mcp add -s user --transport http {{ .name | quote }} {{ .url | quote }} >/dev/null 2>&1 \ + && echo "claude mcp add {{ .name }}" \ + || echo "claude mcp add {{ .name }} failed" >&2 + fi +{{ end -}} else echo "claude CLI not found, skipping Claude plugin install" >&2 fi @@ -52,6 +62,16 @@ if command -v codex >/dev/null 2>&1; then fi {{ end -}} codex plugin marketplace upgrade >/dev/null 2>&1 || true + + # Same MCP server list as Claude, via codex's own CLI (writes ~/.codex/ + # config.toml [mcp_servers]; survives modify_config.toml's merge). +{{ range .mcp -}} + if ! codex mcp get {{ .name | quote }} >/dev/null 2>&1; then + codex mcp add {{ .name | quote }} --url {{ .url | quote }} >/dev/null 2>&1 \ + && echo "codex mcp add {{ .name }}" \ + || echo "codex mcp add {{ .name }} failed" >&2 + fi +{{ end -}} else echo "codex CLI not found, skipping Codex plugin install" >&2 fi diff --git a/AGENTS.md b/AGENTS.md index 6e96572..73c8937 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -29,8 +29,8 @@ sh -c "$(curl -fsLS get.chezmoi.io/lb)" -- init --apply vaintrub | `iterm/com.googlecode.iterm2.plist` | real iTerm2 binary plist (chezmoi-ignored). iTerm2 reads + writes here directly via `PrefsCustomFolder` (set by run_once_after script) | | `dot_claude/` | Claude Code: instructions, settings (modify_), statusline, agents, skills, rules | | `dot_codex/` | Codex CLI: AGENTS.md, config.toml (modify_), shared skills (symlink) | -| `.chezmoidata/packages.yaml` | single source of truth for all packages (Mac brews/casks, Linux apt/dnf/npm) AND Claude/Codex plugin lists | -| `.chezmoiscripts/` | install hooks (run_once_after_*, run_onchange_after_*). Per-OS subdirs: `darwin/`, `linux/`. Numerical prefix (50/70/99) controls ordering — 50 installs packages (+ mise tools + post-installs from lib), 70 installs Claude+Codex plugins, 99 prints first-apply hint | +| `.chezmoidata/packages.yaml` | single source of truth for all packages (Mac brews/casks, Linux apt/dnf/npm), Claude/Codex plugin lists, AND MCP servers (`mcp:` — agent-agnostic, registered into both Claude + Codex; keyless remote only) | +| `.chezmoiscripts/` | install hooks (run_once_after_*, run_onchange_after_*). Per-OS subdirs: `darwin/`, `linux/`. Numerical prefix (50/70/99) controls ordering — 50 installs packages (+ mise tools + post-installs from lib), 70 installs Claude+Codex plugins + registers MCP servers into both, 99 prints first-apply hint | | `hooks/` | hook scripts registered in `.chezmoi.toml.tmpl`. `ensure-prereqs.sh` runs BEFORE source-state read on every apply, installing minimum tools (git/zsh/vim/tmux/curl + brew on Mac) | | `.chezmoitemplates/` | shared template partials (base configs read by `modify_` scripts via `includeTemplate`, not applied to $HOME) | | `lib/` | shell libraries sourced by `.chezmoiscripts/*` wrappers via `{{ .chezmoi.sourceDir }}/lib/X.sh`. Pure POSIX `sh`, no template syntax. Chezmoi-ignored so it never deploys to $HOME — also makes the libraries `source`-able by bats unit tests with mocked externals. |