How to configure MCP (Model Context Protocol) servers in Claude Code — add filesystem, database, GitHub, and custom MCP tools using settings.json.
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.
// ~/.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"
}
}
}
}
# 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
// 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.
{
"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.
{
"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
# 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"]
}
}
}
# 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.