Add a local MCP server that runs a command
mcp, agents & hooks
// what it does
claude mcp add <name> -- <command> registers a stdio MCP server that Claude launches as a local subprocess. Everything after the -- separator is the command run untouched, so quoting and flags pass through. Add environment variables with -e KEY=value before the separator. Local scope is the default: the server is private to you in the current project, stored in ~/.claude.json.
// shell
$ claude mcp add my-server -- npx -y my-mcp-server$ claude mcp add -e API_KEY=secret my-server -- npx -y server// gotcha
The -- is mandatory for stdio servers: it splits Claude's own options (--transport, --env, --scope) from the server command. Omit it and Claude Code tries to parse your server's flags as its own.