Claude Code MCP Server Setup: Complete Guide 2026
The Model Context Protocol (MCP) serves as the backbone for extending Claude Code’s capabilities Whether you need to integrate external APIs, connect to databases, or automate custom workflows, MCP servers provide the infrastructure. This guide walks you through setting up MCP servers from scratch in 2026.
Understanding MCP Architecture
MCP follows a client-server model where Claude Code acts as the client connecting to one or more servers Each server exposes specific tools and resources that Claude can invoke during conversations. This architecture keeps your setup modular—you can add, remove, or update servers without affecting others.
The protocol supports three primary connection types: stdio (standard input/output), SSE (Server-Sent Events), and WebSocket. Stdio works best for local processes, while SSE and WebSocket suit remote server deployments.
Installing Required Dependencies
Before configuring MCP servers, ensure your environment meets the basic requirements. Claude Code runs on Node.js 18 or later, and many MCP servers require Python 3.10 or higher. Check your versions:
node --version # Should be 18.0.0 or higher
python3 --version # Should be 3.10 or higher
Create a dedicated directory for your MCP configuration:
mkdir -p ~/claude-mcp/servers
cd ~/claude-mcp
Setting Up Your First MCP Server
The most straightforward way to start is with a simple stdio-based server. Create a file named hello-server.js:
#!/usr/bin/env node
const { Server } = require('@modelcontextprotocol/sdk/server/index.js');
const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
const { CallToolRequestSchema } = require('@modelcontextprotocol/sdk/types.js');
const server = new Server({
name: 'hello-server',
version: '1.0.0'
}, {
capabilities: {
tools: {}
}
});
server.setRequestHandler(CallToolRequestSchema, async (request) => {
if (request.params.name === 'greet') {
const name = request.params.arguments.name || 'User';
return {
content: [{
type: 'text',
text: `Hello, ${name}! Your MCP server is working correctly.`
}]
};
}
throw new Error(`Unknown tool: ${request.params.name}`);
});
const transport = new StdioServerTransport();
server.connect(transport);
Register this server in your Claude Code configuration at ~/.claude/settings.json:
{
"mcpServers": {
"hello": {
"command": "node",
"args": ["~/claude-mcp/servers/hello-server.js"]
}
}
}
Restart Claude Code, and the greet tool becomes available in your conversations.
Building a Custom Skill with MCP
For more complex integrations, combine MCP servers with the skill-creator skill. This approach lets you define custom behaviors while using Claude’s built-in tool infrastructure.
Suppose you want to create a skill that manages GitHub issues. First, create an MCP server that authenticates with GitHub’s API:
from github import Github
from mcp.server import Server
from mcp.server.stdio import StdioServer
import os
class GitHubMCP:
def __init__(self, token):
self.github = Github(token)
def create_issue(self, repo, title, body):
repository = self.github.get_repo(repo)
issue = repository.create_issue(title=title, body=body)
return {"number": issue.number, "url": issue.html_url}
def list_issues(self, repo, state="open"):
repository = self.github.get_repo(repo)
return [{"number": i.number, "title": i.title}
for i in repository.get_issues(state=state)]
# Run with: python github-mcp.py
if __name__ == "__main__":
token = os.environ.get("GITHUB_TOKEN")
server = GitHubMCP(token)
# Initialize and connect to stdio
Then use the skill-creator skill to define how Claude interacts with this server. The skill provides templates for wrapping MCP tools with natural language prompts, making your custom functionality feel native to Claude Code.
Connecting to Production Services
Beyond local stdio connections, you can run MCP servers as persistent services. This approach works well for databases, API gateways, and microservices. Here’s a configuration for an SSE-based server:
{
"mcpServers": {
"database": {
"url": "http://localhost:3000/sse",
"transport": "sse"
},
"memory": {
"command": "npx",
"args": ["-y", "@supermemory/mcp-server"],
"env": {
"SUPERMEMORY_API_KEY": "your-api-key"
}
}
}
}
The supermemory skill integrates with this MCP server to index your codebase, documentation, and conversations. Setting up the supermemory MCP server enables semantic search across your entire development context.
Using Claude Skills with MCP
Many built-in Claude skills work directly with MCP servers. The pdf skill can process documents retrieved through MCP tools. The xlsx skill handles spreadsheet operations on data fetched from external sources. The webapp-testing skill validates frontend behavior while MCP servers provide test data.
For example, combine the tdd skill with a database MCP server to generate tests against live data fixtures:
// MCP server provides test data
const testData = await mcp.callTool('database', 'fetchUsers', { limit: 10 });
// tdd skill generates appropriate test cases
describe('UserService', () => {
testData.forEach(user => {
it(`should handle user ${user.id}`, async () => {
const result = await UserService.process(user);
expect(result.success).toBe(true);
});
});
});
Securing Your MCP Setup
MCP servers often handle sensitive credentials and data. Follow these security practices:
Never commit API keys or tokens to configuration files. Use environment variables instead:
export GITHUB_TOKEN="ghp_xxxx"
export DATABASE_URL="postgresql://..."
For production deployments, run MCP servers in isolated containers with minimal permissions. The skill-creator skill includes templates for containerized MCP deployments that follow security best practices.
Troubleshooting Common Issues
When MCP servers fail to connect, check these common problems:
- Stdio timeout: Ensure the server process starts quickly. Add logging to confirm initialization.
- Authentication errors: Verify environment variables are passed correctly in your config.
- Tool not found: Confirm the tool name matches exactly in both server registration and your prompts.
Restart Claude Code after any configuration changes. The server reinitializes on startup.
Extending Your Setup
As your needs grow, add more MCP servers to handle specialized tasks. The canvas-design skill can work with MCP servers that provide design assets. The pptx skill integrates with presentation APIs through MCP. The docx skill connects to document management systems.
Each additional server follows the same pattern: implement the server, register it in your configuration, and restart Claude Code. This modular approach keeps your setup maintainable as requirements evolve.
Related Reading
- Best Claude Code Skills for Frontend Development — Top frontend skills with examples
- Best Claude Skills for Developers in 2026 — Broader developer skill overview
- Claude Skills Auto Invocation: How It Works — How skills activate automatically
Built by theluckystrike — More at zovo.one