---
title: "TIL: Setup MCP Server in Claude Code"
url: "https://vanducng.dev/2024/12/04/TIL-Setup-MCP-Server-in-Claude-Code/"
date: "2024-12-04"
categories: ["Notes"]
tags: ["llm"]
---

# TIL: Setup MCP Server in Claude Code

Quick guide to add a Model Context Protocol (MCP) server to Claude Code CLI.

## The Command

```bash
claude mcp add <server-name> -s <scope> -- <command> <args>
```

## Example: Adding a Remote MCP Server

```bash
claude mcp add dbcode -s project -- npx -y mcp-remote http://localhost:5002/mcp
```

This creates `.mcp.json` in your project root:

```json
{
  "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

```bash
# List configured servers
claude mcp list

# Remove a server
claude mcp remove dbcode

# Check if server is running
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.
