Claude Code MCP Server Setup

How to configure MCP (Model Context Protocol) servers in Claude Code — add filesystem, database, GitHub, and custom MCP tools using settings.json.

💥 50p impulse-buy: Power Prompts PDF (first 10 buyers) 30 battle-tested Claude Code prompts · 8-page PDF · paste into CLAUDE.md and never re-type a prompt again · 50p impulse-buy, no commitment

MCP lets Claude Code connect to external services — databases, APIs, file systems, and custom tools — using a standardized protocol. This guide walks through setting up the most common servers.

MCP configuration format

// ~/.claude/settings.json or .claude/settings.json
{
  "mcpServers": {
    "server-name": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/dir"],
      "env": {
        "MY_ENV_VAR": "value"
      }
    }
  }
}

Filesystem MCP server

# Allow Claude Code to read/write a specific directory via MCP:
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/projects"]
    }
  }
}

# After adding, restart Claude Code.
# Claude will now have filesystem MCP tools in addition to its built-in tools:
# mcp__filesystem__read_file, mcp__filesystem__write_file,
# mcp__filesystem__list_directory, mcp__filesystem__search_files

GitHub MCP server

// Needs a GitHub personal access token with repo scope
{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here"
      }
    }
  }
}

// Tools exposed:
// mcp__github__create_issue, mcp__github__get_pull_request,
// mcp__github__list_commits, mcp__github__search_code, etc.

PostgreSQL MCP server

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"]
    }
  }
}

// After setup, ask Claude Code:
// "Show me the schema of the users table"
// "Find all users who haven't logged in for 30 days"
// Claude will use mcp__postgres__query to answer these directly.

Slack MCP server

{
  "mcpServers": {
    "slack": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-slack"],
      "env": {
        "SLACK_BOT_TOKEN": "xoxb-your-bot-token",
        "SLACK_TEAM_ID": "T0123456789"
      }
    }
  }
}
// Now Claude can: list channels, read message history, post messages

Custom Python MCP server

# my_mcp_server.py — minimal MCP server skeleton
import asyncio
from mcp.server import Server
from mcp.server.stdio import stdio_server
from mcp import types

app = Server("my-tools")

@app.list_tools()
async def list_tools():
    return [
        types.Tool(
            name="get_deploy_status",
            description="Check current deployment status",
            inputSchema={"type": "object", "properties": {"env": {"type": "string"}}, "required": ["env"]}
        )
    ]

@app.call_tool()
async def call_tool(name: str, arguments: dict):
    if name == "get_deploy_status":
        env = arguments["env"]
        # your logic here
        return [types.TextContent(type="text", text=f"{env}: deployed at 2026-05-18T03:00Z")]

async def main():
    async with stdio_server() as (read_stream, write_stream):
        await app.run(read_stream, write_stream, app.create_initialization_options())

asyncio.run(main())
// settings.json entry for the custom server:
{
  "mcpServers": {
    "my-tools": {
      "command": "python",
      "args": ["/absolute/path/to/my_mcp_server.py"]
    }
  }
}

Debug MCP connections

# Verbose MCP connection logs:
claude --mcp-debug

# Test server manually before adding to settings:
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' |   npx -y @modelcontextprotocol/server-filesystem /tmp

# Check which MCP servers are active in a session:
# Ask Claude: "List your available MCP tools"

For Claude API-based MCP server development with Python, see building MCP servers with the Claude Python SDK.

Frequently asked questions

What is MCP in Claude Code?
MCP (Model Context Protocol) is an open protocol that lets Claude Code connect to external tools and data sources. An MCP server exposes tools (like file read, database query, GitHub API) that Claude can call exactly like its built-in tools.
How do I add an MCP server to Claude Code?
Add the server config to mcpServers in ~/.claude/settings.json (global) or .claude/settings.json (project). Each server needs a name, command to start it, and optional args/env.
Does Claude Code ship with any MCP servers built in?
No. Claude Code's built-in tools (Read, Edit, Bash, Grep) are separate from MCP. MCP is for connecting external servers — like a PostgreSQL MCP server, a Jira MCP server, or a custom internal tool.
Is there a list of available MCP servers?
Yes. The MCP registry at modelcontextprotocol.io lists community-built servers. Popular ones include @modelcontextprotocol/server-filesystem, @modelcontextprotocol/server-github, @modelcontextprotocol/server-postgres, and @modelcontextprotocol/server-slack.
How do I debug MCP connection issues in Claude Code?
Run claude --mcp-debug to see verbose connection logs. Check that the server process starts correctly by running it directly in your terminal first. Verify the command path is absolute or on your PATH.

Free tools

Cost Calculator → API Cookbook → Diff Summarizer → Skills Browser →

More examples

Claude API Python QuickstartClaude API Node.js / TypeScript QuickstartClaude API Streaming in PythonClaude API Streaming in Node.js / TypeScriptClaude API Tool Use in PythonClaude API Tool Use in Node.js / TypeScript