Claude Code

How do you add an MCP server to Claude Code?

QUICK ANSWER

Add an MCP server to Claude Code by editing the local config file or using the slash command: '/mcp add <server-name> <command> [args...]'.

Using the Slash Command

Run the following interactive command inside the Claude Code prompt:

/mcp add postgres-mcp npx -y @modelcontextprotocol/server-postgres --conn postgresql://localhost/dev

Config File Modification

Alternatively, write the configuration directly inside the claude-code.config.json under the mcpServers block.

Verified against: Claude Code CLI v0.2.5