feat(config): Claude Code adapter (~/.claude.json) [D1]#117
Merged
Conversation
mcpm now manages MCP servers for Claude Code — the most widely-used MCP host — as a first-class client (`--client claude-code`), reading/writing the user-global `mcpServers` map in ~/.claude.json. Because ~/.claude.json uses the same top-level `mcpServers` root key as every other client, ClaudeCodeAdapter is a rootKey-only BaseAdapter subclass — no new I/O logic. Registration is the CLIENT_IDS tuple + factory + barrel + the two Record<ClientId> label maps (doctor, guard/cli) + the completions duplicate; detection/install/remove/audit/sync/up/guard all pick it up via the factory. Scope: user-global only. Per-project servers (projects[<path>].mcpServers) are intentionally out of scope — that nested shape doesn't fit the single-rootKey model and is a separate feature. Writes preserve every unrelated key in the file (projects, oauthAccount, numStartups, …) via the existing atomic read-modify-write + .bak backup. Distinct from claude-desktop (different app, different file). Zero new deps. Tests: clientId + ~/.claude.json path (all platforms, home-relative not appData) + the sibling-key-preservation invariant. Verified end-to-end against the built CLI: doctor detects it, disable writes the flag, all unrelated keys survive.
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.
What
mcpm now manages MCP servers for Claude Code — the single most widely-used MCP host — as a first-class client (
--client claude-code), reading and writing the user-globalmcpServersmap in~/.claude.json.This is Wave 1's #1 adoption lever from
docs/ROADMAP-ADOPTION.md: until now mcpm couldn't manage the most common host, so a huge share of MCP users had no reason to reach for it.How
~/.claude.jsonuses the same top-levelmcpServersroot key as every other client, soClaudeCodeAdapteris a rootKey-onlyBaseAdaptersubclass — no new I/O logic, it inherits the atomic write +.bakbackup + symlink guards. Registration:CLIENT_IDStuple +getConfigPathcase (~/.claude.json, home-relative on all platforms) —src/config/paths.tssrc/config/adapters/claude-code.ts(new), factory case, barrel exportRecord<ClientId, string>label maps (doctor,guard/cli) — surfaced by the exhaustiveness tripwireCLIENT_IDSduplicate incompletions.tsdetect/install/remove/audit/sync --check/up/guardall pick it up automatically via the factory.Scope
User-global only. Per-project servers (
projects[<path>].mcpServers) are intentionally out of scope — that nested shape doesn't fit the single-rootKey model and is a separate feature. Writes preserve every unrelated key in the file (projects,oauthAccount,numStartups, …).Distinct from the existing
claude-desktopclient (different app, different file). Zero new deps.Tests
clientId+~/.claude.jsonpath (darwin/linux/win32 — home-relative, not under APPDATA, unlike claude-desktop)doctordetects it ("config found, 1 server"),disablewrites the flag, andprojects/oauthAccount/numStartupsall survive the write.Full suite green (the 2 pre-existing darwin-local fails — secrets-migrate-count, chalk-TTY — are unrelated and pass on ubuntu CI).