MCP Servers
Connect Claude Code to external tools using the Model Context Protocol (MCP) — databases, GitHub, file systems, and custom integrations.
What is MCP?
The Model Context Protocol (MCP) is an open standard that lets AI tools connect to external data sources and services. Think of MCP servers as plugins that extend Claude Code's capabilities beyond reading and writing local files.
With MCP, Claude Code can query databases, interact with GitHub, access documentation, and communicate with any API — all securely and with your explicit configuration.
How MCP Works
- MCP Server — A lightweight process that exposes tools and resources to the AI agent
- MCP Client — Claude Code itself, which connects to configured servers
- Tools — Actions the server exposes (e.g., "query database", "create GitHub issue")
- Resources — Data the server can provide (e.g., database schemas, API documentation)
Configuring MCP Servers
MCP servers are configured in your project's .claude/ directory or globally:
Project-Level Configuration
Use the Claude Code CLI to add MCP servers:
# Add a GitHub MCP server
claude mcp add github-server -e GITHUB_TOKEN=ghp_your_token -- npx -y @modelcontextprotocol/server-github
# Add a PostgreSQL MCP server
claude mcp add postgres-server -e DATABASE_URL=postgresql://user:pass@localhost/mydb -- npx -y @modelcontextprotocol/server-postgres
# Add a filesystem MCP server for docs
claude mcp add docs-server -- npx -y @modelcontextprotocol/server-filesystem /path/to/docs
Project-Level Config File
You can also manually edit .claude/mcp.json:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "ghp_your_token_here"
}
},
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "postgresql://user:pass@localhost:5432/mydb"
}
}
}
}
Popular MCP Servers
| Server | What It Does | Package |
|---|---|---|
| GitHub | Read PRs, issues, repo files | @modelcontextprotocol/server-github |
| PostgreSQL | Query databases, read schemas | @modelcontextprotocol/server-postgres |
| Filesystem | Access files outside your project | @modelcontextprotocol/server-filesystem |
| Puppeteer | Browser automation | @modelcontextprotocol/server-puppeteer |
Managing MCP Servers
# List all configured servers
claude mcp list
# Remove a server
claude mcp remove github-server
# Check server status
claude mcp list
Security Best Practices
- Use read-only database credentials — Prevent accidental data modifications
- Scope GitHub tokens — Only grant the permissions Claude actually needs
- Don't commit secrets — Add
.claude/mcp.jsonto.gitignoreif it contains tokens - Use environment variables — Reference
$ENV_VARinstead of hardcoding credentials
What's Next
In the next episode, we'll learn about Subagents — how Claude Code can spawn child agents to handle complex multi-step tasks concurrently.