Quick guide to add a Model Context Protocol (MCP) server to Claude Code CLI.
The Command
1
| claude mcp add <server-name> -s <scope> -- <command> <args>
|
Example: Adding a Remote MCP Server
1
| claude mcp add dbcode -s project -- npx -y mcp-remote http://localhost:5002/mcp
|
This creates .mcp.json in your project root:
1 2 3 4 5 6 7 8 9 10
| { "mcpServers": { "dbcode": { "type": "stdio", "command": "npx", "args": ["-y", "mcp-remote", "http://localhost:5002/mcp"], "env": {} } } }
|
Scope Options
| Flag |
Scope |
Config Location |
-s project |
Current project only |
.mcp.json in project root |
-s user |
All your projects |
~/.claude/settings.json |
Useful Commands
1 2 3 4 5 6 7 8
| claude mcp list
claude mcp remove dbcode
curl -s -o /dev/null -w "%{http_code}" http://localhost:5002/mcp
|
Note
Restart Claude Code after adding a new MCP server for it to take effect.
Comments