Skip to content

feat(mcp): agentmark-mcp install — auto-wire detected AI clients - #38

Merged
rrader26 merged 1 commit into
mainfrom
feat/mcp-client-installer
May 13, 2026
Merged

feat(mcp): agentmark-mcp install — auto-wire detected AI clients#38
rrader26 merged 1 commit into
mainfrom
feat/mcp-client-installer

Conversation

@rrader26

Copy link
Copy Markdown
Contributor

Summary

  • New `install` / `uninstall` / `doctor` subcommands on the `agentmark-mcp` CLI.
  • Detects which AI clients are on the box (Claude Code, Claude Desktop, Cursor, Windsurf, Codex CLI) and writes the standard `mcpServers` config block into each — one command, all clients.
  • Pairs with PR feat(packaging): macOS .pkg + Windows .msi installer scaffolding #37 (.pkg / .msi installer): after one-click install, this is the one-command setup.

CLI surface

```
agentmark-mcp start the MCP server (default)
agentmark-mcp serve same, explicit
agentmark-mcp install auto-wire detected clients
agentmark-mcp install --client=cursor target specific clients
agentmark-mcp install --dry-run show what would change
agentmark-mcp uninstall remove our entry
agentmark-mcp doctor diagnose what's installed
agentmark-mcp --help
```

Supported clients

All four use the same `mcpServers` JSON shape, so one writer covers them; only the file path differs per descriptor.

Client Config path (macOS shown; mirrored on other OS)
Claude Code `~/.claude.json`
Claude Desktop `~/Library/Application Support/Claude/claude_desktop_config.json`
Cursor `~/.cursor/mcp.json`
Windsurf `~/.codeium/windsurf/mcp_config.json`
Codex CLI `~/.codex/config.toml` (TOML — surfaces "not yet supported, edit manually" pending a TOML writer)

Safety

  • Every write creates a `.bak` copy first. Rollback is one `mv` away.
  • Refuses to overwrite malformed JSON — better to fail loudly than silently destroy the user's config.
  • Writes go through temp file + atomic rename.
  • Auto-detection of the launcher command walks the bundled-installer layout first (relocatable), then PATH, then falls back to `process.execPath`.

Result reporting

Per-client action tag: `added` / `updated` / `already_present` / `removed` / `not_present` / `skipped` / `error`, plus a per-row message (backup path on writes; error detail on errors).

```
$ agentmark-mcp install
agentmark-mcp install — results:

✓ Claude Code [added] /Users/me/.claude.json
backup: /Users/me/.claude.json.bak
✓ Cursor [added] /Users/me/.cursor/mcp.json
· Windsurf [already_present] /Users/me/.codeium/windsurf/mcp_config.json
```

Test plan

  • `pnpm build` clean
  • `pnpm test` — 504 pass / 10 skip (13 new tests covering atomic IO, apply/remove semantics, dry-run safety, unknown-client errors)
  • Smoke-tested on this developer's machine: `agentmark-mcp install --dry-run --client=claude-code` against the real `~/.claude.json` correctly reported "added" without modifying the file
  • Manual: run the live install on a fresh dev machine, then `/mcp` in Claude Code and verify the agentmark server appears

🤖 Generated with Claude Code

The friction-killer that pairs with the new .pkg / .msi installers.
After someone double-clicks the installer, the next thing they have
to do today is figure out which JSON config file to edit and where.
This subcommand does it for them: detects what's installed on the
box, writes the right config blocks, supports dry-run + rollback.

CLI surface:

  agentmark-mcp                                start the MCP server (default)
  agentmark-mcp serve                          same, explicit
  agentmark-mcp install                        auto-wire detected clients
  agentmark-mcp install --client=cursor        target specific clients
  agentmark-mcp install --dry-run              show what would change
  agentmark-mcp uninstall                      remove our entry
  agentmark-mcp doctor                         diagnose what's installed
  agentmark-mcp --help

Supported clients (config path on macOS shown; mirrored on other OS):

  claude-code      ~/.claude.json
  claude-desktop   ~/Library/Application Support/Claude/claude_desktop_config.json
  cursor           ~/.cursor/mcp.json
  windsurf         ~/.codeium/windsurf/mcp_config.json
  codex            ~/.codex/config.toml  (TOML — surfaces a "not yet
                                          supported, edit manually"
                                          error pending a TOML writer)

All four supported clients use the same `mcpServers` JSON shape, so
one writer covers them; only the file path differs per descriptor.

Safety:
  - Every write creates a `<path>.bak` copy first; rollback is one
    `mv` away.
  - Refuses to overwrite malformed JSON (would silently lose user
    config otherwise).
  - Writes go through temp file + atomic rename.
  - Auto-detection of the launcher command walks the bundled-installer
    layout first (relocatable), then PATH, then falls back to
    process.execPath.

The install / uninstall results are reported per-client with one of:
  added | updated | already_present | removed | not_present | skipped | error
Plus a per-row message (backup path on writes; error detail on errors).

Tests (13 new, 504 total):
  - readJson + writeJson atomic round-trips
  - .bak created on overwrite
  - parent-dir auto-create
  - refuses malformed JSON
  - applyEntry adds + updates + preserves siblings
  - removeEntry returns removed=false when no entry
  - installToClients rejects unknown client ids
  - dry-run doesn't touch disk

Smoke-tested end-to-end against this developer's actual ~/.claude.json
via `--dry-run` (file was correctly left alone).

Pairs with PR #37 (.pkg / .msi installer): after a one-click install,
`agentmark-mcp install` is the one-command setup that gets every
AI tool on the box talking to the agentmark MCP server.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rrader26
rrader26 merged commit 46ae081 into main May 13, 2026
5 checks passed
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.

2 participants