How to Use MCP Servers: A Complete Beginner's Guide
Learn how to set up and use MCP (Model Context Protocol) servers with Claude Code and other AI tools. Extend your AI coding agent with custom tools, APIs, and data sources.
What Are MCP Servers?
MCP (Model Context Protocol) servers are a game-changer for AI coding agents. They let you give your AI agent access to external tools and data sources — databases, APIs, file systems, search engines, and more.
Think of MCP as USB-C for AI — a standard protocol that any AI agent can use to connect to any tool. Instead of each AI tool reinventing its own plugin system, MCP provides a universal interface.
How MCP Works
┌─────────────────┐ MCP Protocol ┌─────────────────┐
│ │ ◄────────────────────► │ │
│ AI Agent │ │ MCP Server │
│ (Claude Code, │ │ (File system, │
│ Cursor, etc.) │ │ Database, │
│ │ │ API, etc.) │
└─────────────────┘ └─────────────────┘
The AI agent sends requests (in natural language), and the MCP server executes actions and returns results.
Why You Need MCP Servers
Without MCP, your AI coding agent is limited to: - Reading and writing files in your project - Running shell commands - Using its internal knowledge
With MCP, it can: - Query databases (PostgreSQL, SQLite, MySQL) - Search the web (Google, Bing, custom APIs) - Access APIs (GitHub, Slack, Jira, Notion) - Read external files (PDFs, images, Excel spreadsheets) - Interact with services (AWS, Docker, Kubernetes)
Getting Started: Your First MCP Server
Step 1: Install the MCP CLI
npm install -g @anthropic-ai/mcp-cli
Step 2: Configure MCP Servers
MCP servers are configured in your AI tool's config file. For Claude Code, create or edit ~/.claude/config.json:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-filesystem"],
"env": {
"ALLOWED_PATHS": "/Users/you/projects"
}
},
"github": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-github"],
"env": {
"GITHUB_TOKEN": "your-github-personal-access-token"
}
}
}
}
Step 3: Use the MCP Server
Once configured, restart Claude Code and you can use the tools naturally:
Can you check if there are any recent issues filed against the main branch on GitHub?
Claude Code will use the GitHub MCP server to access the API and return results.
5 Essential MCP Servers for Developers
1. Filesystem Server
Gives your AI agent controlled access to your file system beyond the current project:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-filesystem"],
"env": {
"ALLOWED_PATHS": "/Users/you/projects,/Users/you/Documents"
}
}
}
}
Use cases: Search across multiple projects, read configuration files, batch rename files.
2. GitHub Server
Full GitHub API access — issues, PRs, repos, actions:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-github"],
"env": {
"GITHUB_TOKEN": "ghp_xxxxxxxxxxxx"
}
}
}
}
Use cases: Create PRs from Claude Code, review issues, trigger GitHub Actions, manage repos.
3. Database Server (PostgreSQL)
Query your production or staging database directly:
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-postgres"],
"env": {
"DATABASE_URL": "postgresql://user:pass@localhost:5432/mydb"
}
}
}
}
Use cases: Debug data issues, run analytics queries, generate reports.
4. Web Search Server
Give your AI agent real-time internet access:
{
"mcpServers": {
"search": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-search"],
"env": {
"SERP_API_KEY": "your-key"
}
}
}
}
Use cases: Research latest documentation, check package versions, find error solutions.
5. Docker Server
Manage containers and images from your AI agent:
{
"mcpServers": {
"docker": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-docker"]
}
}
}
Use cases: Start/stop containers, check logs, rebuild images, deploy services.
Real-World MCP Workflows
Workflow 1: Debug a Production Bug
1. Claude Code checks GitHub issues (GitHub MCP)
2. Queries the database for related error logs (PostgreSQL MCP)
3. Searches the web for similar bugs (Search MCP)
4. Reads relevant source files (Filesystem MCP)
5. Runs the fix and deploys (Docker MCP)
Workflow 2: Automated Release Process
Create a new release step by step:
1. Update version in package.json
2. Generate changelog from recent commits (GitHub MCP)
3. Run the test suite
4. Build and tag the release
5. Deploy the new version (Docker MCP)
6. Create a GitHub release (GitHub MCP)
Workflow 3: Onboarding to a New Codebase
I'm new to this project. Help me understand it:
1. Read the README and docs (Filesystem MCP)
2. Show me the database schema (PostgreSQL MCP)
3. List recent PRs and issues (GitHub MCP)
4. Check the CI pipeline configuration
5. Summarize the architecture
Troubleshooting Common MCP Issues
Issue 1: MCP Server Not Found
# Check if the package is installed
npx @anthropic-ai/mcp-filesystem --version# Reinstall if needed
npm install -g @anthropic-ai/mcp-cli
Issue 2: Permission Denied
# Check allowed paths in config
# Filesystem MCP only allows paths specified in ALLOWED_PATHS
# Update the config to include the path you need
Issue 3: Connection Timeout
# Some MCP servers need network access
# Check your firewall and proxy settings
# For local servers, ensure the service is running
Building Your Own MCP Server
You're not limited to pre-built servers. Here's a minimal MCP server in TypeScript:
import { Server } from "@anthropic-ai/mcp-sdk";const server = new Server({
name: "custom-server",
version: "1.0.0",
tools: [
{
name: "greet",
description: "Greet someone by name",
inputSchema: {
type: "object",
properties: {
name: { type: "string" }
}
}
}
]
});
server.setRequestHandler("greet", (request) => {
return {
content: [{ type: "text", text: Hello, ${request.params.arguments.name}! }]
};
});
server.listen();
MCP vs Traditional Plugins
| Feature | MCP | Traditional Plugins | |---------|-----|-------------------| | Protocol | Standardized | Vendor-specific | | Portability | Works with any MCP-compatible AI | Locked to one platform | | Setup | Config file only | Installation + registration | | Security | Sandboxed by design | Varies by platform | | Community | Growing fast | Established but fragmented |
Next Steps
1. Start simple: Add the Filesystem MCP server to Claude Code 2. Try one server: GitHub MCP is the most practical for daily use 3. Combine them: Use 2-3 MCP servers for a complete workflow 4. Build custom: Create your own MCP server for internal tools
MCP is still early, but it's rapidly becoming the standard way to extend AI coding agents. The tools you build with MCP today will work with future AI agents tomorrow.
---
New to Claude Code? Read our Claude Code installation guide first, then come back to add MCP servers.
Related Articles
Fix: MCP Server Connection Failed — Complete Troubleshooting Guide
Step-by-step guide to fixing MCP server connection errors in Claude Code and other AI agents. Covers port conflicts, configuration mistakes, authentication issues, and network problems.
How to Set Up Claude Code with DeepSeek API (Save 97% on AI Coding Costs)
Step-by-step guide to using Claude Code with DeepSeek as the backend model instead of Anthropic. Cut your AI coding costs by 97% while keeping the same workflow and tools.
How to Build a Full-Stack App with Claude Code: From Zero to Deploy
Step-by-step tutorial on building a complete full-stack application using Claude Code as your AI pair programmer — from project setup through database, API, frontend, and deployment.