AgentKit
ReferenceCLI commands
BetaYou are reading docs for the beta channel (2.4.1-beta.1) — updated automatically on every beta release.Switch to stable →

CLI commands

ak mcp add

Add or update an MCP server

ak mcp add writes a single MCP server entry into a selected Claude-style MCP config file, giving scripts, CI jobs, and reviewers a deterministic way to edit MCP configuration.

When to use it: Reach for it after reviewing your existing MCP inventory with ak mcp list. Supply the server's --command, repeat --arg to preserve argument order, and pass --env KEY=VALUE for environment assignments — env values are written but never displayed. By default it writes the project's .mcp.json; use --source to target a different MCP config path.

Usage

ak mcp add <name> [flags]

Examples

ak mcp add memory --command npx --arg -y --arg @modelcontextprotocol/server-memory
ak mcp add db --command node --arg server.js --env MCP_ENV_ONE=value --source .mcp.json --json

Flags

FlagDescription
--arg stringArrayServer argument; repeat to preserve order
--command stringServer command to execute
--env stringArrayServer env assignment KEY=VALUE; values are written but never displayed
-h, --helphelp for add
--jsonEmit machine-readable JSON (implies --no-interactive)
--no-interactiveDisable interactive prompts (CI-safe)
-q, --quietSuppress non-error output on stderr
--source stringMCP config path to edit; defaults to project .mcp.json
-V, --verboseExtra diagnostic output on stderr (loses to --quiet)
-y, --yesAssume yes for all prompts

Inherited flags

FlagDescription
--claude-home stringClaude home override; defaults to AGENTKIT_CLAUDE_HOME or ~/.claude
--cwd stringProject directory override; defaults to current working directory

Output modes

ModeBehavior
prettydefault on TTY (colors, ASCII markers)
plainauto when stdout piped or --no-interactive
json--json (single-object envelope, NDJSON-safe)

Exit codes

CodeMeaning
0success
1runtime error
2invalid flags
3user-cancel (SIGINT, prompt-cancel)
  • ak mcp — Inspect local MCP server configuration

On this page