LangENKO

`mandu mcp register`

Automatic IDE integration — writes a Mandu MCP server entry into Claude Code, Cursor, Continue, or Aider without touching sibling configuration. Merge-safe, tolerant of JSON-C, preserves YAML preamble.

since v0.25
On this page

mandu mcp register

Automatic IDE integration — writes a Mandu MCP server entry into four popular editors without overwriting their existing configuration.

mandu mcp register                              # register for all four IDEs
mandu mcp register --ide=claude                 # only Claude Code
mandu mcp register --ide=all                    # explicit "all" (default)
mandu mcp register --remove                     # remove Mandu entry
mandu mcp register --dry-run                    # preview without writing
mandu mcp register --token=env:MY_TOKEN         # custom env var name

Supported IDEs

IDE Config path (per-user) Format
Claude Code ~/.claude/mcp.json JSON(-C) tolerance
Cursor ~/.cursor/mcp.json JSON(-C) tolerance
Continue ~/.continue/config.json JSON(-C) tolerance
Aider <cwd>/.aider.conf.yml YAML — project-local

Aider uses a project-local file (in the current working directory) because Aider reads its config from $CWD. The other three use per-user config files under ~/.

What gets written

JSON IDEs (Claude, Cursor, Continue)

{
  "mcpServers": {
    "mandu": {
      "command": "bunx",
      "args": ["-y", "@mandujs/mcp"],
      "env": {
        "MANDU_MCP_TOKEN": "${localEnv:MANDU_MCP_TOKEN}"
      }
    },
    "...": "...existing siblings preserved verbatim"
  }
}

Aider YAML

# Before: (your preamble, untouched)
edit-format: diff-fenced
auto-commits: false

# Mandu merges only the mcp_servers section — preamble above survives
mcp_servers:
  mandu:
    command: bunx
    args:
      - -y
      - "@mandujs/mcp"
    env:
      MANDU_MCP_TOKEN: ${MANDU_MCP_TOKEN}

Safety model

Concern Mechanism
Sibling preservation Reads existing config, merges mcpServers.mandu only. Other entries never touched.
Atomic write <config>.bak.<unix-ms> stashed next to the target; write via rename (atomic on POSIX, best-effort on Windows).
JSON-C tolerance Claude/Cursor/Continue configs tolerate comments on read; comments stripped on write with a warning surfaced in stdout.
YAML preamble Aider YAML merge preserves everything above/below the mcp_servers: block verbatim.
Token placeholder ${localEnv:MANDU_MCP_TOKEN} — tokens are NEVER embedded in the config file unless you pass the raw value explicitly.

Token strategies

Flag Behavior
(none) ${localEnv:MANDU_MCP_TOKEN} placeholder
--token=env:CUSTOM ${localEnv:CUSTOM} placeholder
--token=generate Generate a random base64url token; store inline
--token=<literal> Store the literal value (NOT recommended — plain text)

For a fresh setup:

# 1. Generate a random token
bunx @mandujs/cli mcp register --token=generate
# → prints the token once, stores inline in config + OS keychain

# 2. Or use an env var you manage elsewhere
export MANDU_MCP_TOKEN="$(openssl rand -hex 32)"
bunx @mandujs/cli mcp register
# → config uses ${localEnv:MANDU_MCP_TOKEN}

Dry-run

$ mandu mcp register --ide=claude --dry-run
[dry-run] would write ~/.claude/mcp.json
  backup: ~/.claude/mcp.json.bak.1718550892471
  diff:
    + "mandu": {
    +   "command": "bunx",
    +   "args": ["-y", "@mandujs/mcp"],
    +   "env": { "MANDU_MCP_TOKEN": "${localEnv:MANDU_MCP_TOKEN}" }
    + }
[dry-run] no changes made

Removing the Mandu entry

mandu mcp register --remove                  # remove from all four IDEs
mandu mcp register --ide=cursor --remove     # only Cursor

This removes mcpServers.mandu (or mcp_servers.mandu for YAML) while leaving every sibling entry intact. A backup is still stashed so you can undo.

Exit codes

Code Meaning
0 success
1 I/O / parse error
2 usage error (unknown --ide)

Common errors

ENOENT: ~/.claude/mcp.json does not exist — Claude Code hasn't been launched yet (or the profile dir hasn't been created). mandu mcp register --ide=claude creates the file if it's missing, so this only appears if the parent dir can't be created (permissions).

CLI_E050: config parse error — JSON-C strip failed — the target file has a JSON-C syntax the parser can't handle (e.g. trailing commas in an invalid spot). Open the file, fix the syntax, retry.

CLI_E051: aider YAML preamble lost — a very old Aider config format that the YAML merger doesn't recognize. Back up manually, then reformat your YAML to the modern layout and retry.

Post-register verification

After registering:

# Claude Code: check the server shows up
claude mcp list

# Cursor: open Settings → MCP to see the Mandu server
# Continue: open Continue → Settings → Tools
# Aider: tail --verbose starts mcp_servers log lines

🤖 Agent Prompt

🤖 Agent Prompt — `mandu mcp register`
Apply the guidance from the Mandu docs page at https://mandujs.com/docs/cli/mcp-register to my project.

Summary of the page:
`mandu mcp register` merges `mcpServers.mandu` into ~/.claude/mcp.json (Claude Code), ~/.cursor/mcp.json (Cursor), ~/.continue/config.json (Continue), <cwd>/.aider.conf.yml (Aider). Never overwrites sibling keys. Stashes <config>.bak.<ms> before every write. Token defaults to ${localEnv:MANDU_MCP_TOKEN} placeholder.

Required invariants — must hold after your changes:
- Four IDEs: claude, cursor, continue, aider — `--ide=all` covers them all
- JSON-C comments (Claude/Cursor/Continue) are tolerated on read; stripped on write with a warning
- YAML (Aider) merge preserves preamble and trailing keys verbatim
- Every modified file gets a `.bak.<unix-ms>` sibling — atomic rename semantics
- Tokens default to `${localEnv:MANDU_MCP_TOKEN}` placeholder — never embedded inline unless explicitly requested

Then:
1. Make the change in my codebase consistent with the page.
2. Run `bun run guard` and `bun run check` to verify nothing
   in src/ or app/ breaks Mandu's invariants.
3. Show me the diff and any guard violations.

For Agents

{
  "schema": "mandu.mcp.register/v0.25",
  "command": "mandu mcp register",
  "ides": ["claude", "cursor", "continue", "aider"],
  "config_paths": {
    "claude": "~/.claude/mcp.json",
    "cursor": "~/.cursor/mcp.json",
    "continue": "~/.continue/config.json",
    "aider": "<cwd>/.aider.conf.yml"
  },
  "merge_strategy": "key-level — only `mcpServers.mandu` / `mcp_servers.mandu` is touched",
  "backup_pattern": "<config>.bak.<unix-ms>",
  "token_strategies": ["placeholder (default)", "custom env (--token=env:X)", "generated (--token=generate)", "literal"],
  "rules": [
    "Never overwrite sibling keys — merge only the Mandu entry",
    "Back up every modified file before writing",
    "Default to `${localEnv:MANDU_MCP_TOKEN}` placeholder — never embed raw tokens without --token=<literal>"
  ]
}

For Agents

AI hint

`mandu mcp register` merges `mcpServers.mandu` into ~/.claude/mcp.json (Claude Code), ~/.cursor/mcp.json (Cursor), ~/.continue/config.json (Continue), <cwd>/.aider.conf.yml (Aider). Never overwrites sibling keys. Stashes <config>.bak.<ms> before every write. Token defaults to ${localEnv:MANDU_MCP_TOKEN} placeholder.

Invariants
  • Four IDEs: claude, cursor, continue, aider — `--ide=all` covers them all
  • JSON-C comments (Claude/Cursor/Continue) are tolerated on read; stripped on write with a warning
  • YAML (Aider) merge preserves preamble and trailing keys verbatim
  • Every modified file gets a `.bak.<unix-ms>` sibling — atomic rename semantics
  • Tokens default to `${localEnv:MANDU_MCP_TOKEN}` placeholder — never embedded inline unless explicitly requested
Guard scope
mcp-register