claude-code-mcp
claude-code-mcp copied to clipboard
Model Context Protocol (MCP) servers with Claude Code. These tools dramatically enhance Claude Code's capabilities, allowing it to interact with your filesystem, web browsers, and more.
MCP Server Setup
Model Context Protocol (MCP) lets tools run as separate servers that Claude connects to at runtime. Each server exposes one or more capabilities (e.g., filesystem access, running shell commands, browser automation). You register a server with Claude, and Claude starts it with your specified command when needed.
[!Important] Install Node.js 18+ ⮞ node -v
![]()
Install Claude Code ⮞ npm install -g @anthropic-ai/claude-code
![]()
Official Docs You May Want:
Build MCP Server | Build MCP Client | Server Examples | Popular MCP servers
Community Docs You May Want:
Adding soon..
Quick Start
|
Additional Methods:
1. Command Line Addition
|
2. Direct Configuration File Editing
1. Find configuration file location:
2. Edit configuration file:
3. Restart Claude Code to take effect |
3. Project-level Configuration (Recommended for team collaboration)
This will create a
|
MCP Server Scope Detailed
Understanding scope is crucial to avoid "server not found" errors:
1. Local Scope (Default)
- Only available in current directory
- Configuration stored in the projects section of
~/.claude.json - Suitable for: Personal project-specific tools
2. User Scope (Global)
- Available in all projects
- Added using
-s userflag - Suitable for: Common tools like file systems, database clients
3. Project Scope (Team shared)
- Shared through
.mcp.jsonfile - Added using
-s projectflag - Suitable for: Team-shared project-specific tools
Practical MCP Server Recommendations
Here's the most worthwhile MCP server list to install:
1. File System Access
claude mcp add filesystem -s user -- npx -y @modelcontextprotocol/server-filesystem ~/Documents ~/Projects ~/Desktop
Use: Let Claude directly read and write files, modify code
2. GitHub Integration
claude mcp add github -s user -e GITHUB_TOKEN=your-token -- npx -y @modelcontextprotocol/server-github
Use: Manage issues, PRs, code reviews
3. Web Browser Control
claude mcp add puppeteer -s user -- npx -y @modelcontextprotocol/server-puppeteer
Use: Automated web operations, crawling, testing
4. Database Connection (PostgreSQL)
claude mcp add postgres -s user -e DATABASE_URL=your-db-url -- npx -y @modelcontextprotocol/server-postgres
Use: Directly query and manipulate databases
5. Fetch Tool (API Calls)
claude mcp add fetch -s user -- npx -y @kazuph/mcp-fetch
Use: Call various REST APIs
6. Search Engine
claude mcp add search -s user -e BRAVE_API_KEY=your-key -- npx -y @modelcontextprotocol/server-brave-search
Use: Search for latest information
7. Slack Integration
claude mcp add slack -s user -e SLACK_TOKEN=your-token -- npx -y @modelcontextprotocol/server-slack
Use: Send messages, manage channels
8. Time Management
claude mcp add time -s user -- npx -y @modelcontextprotocol/server-time
Use: Time zone conversion, date calculation
9. Memory Storage
claude mcp add memory -s user -- npx -y @modelcontextprotocol/server-memory
Use: Save information across conversations
10. Sequential Thinking (Thought Chain)
claude mcp add thinking -s user -- npx -y @modelcontextprotocol/server-sequential-thinking
Use: Step-by-step thinking for complex problems
Common Errors and Solutions
Error 1: Tool Name Validation Failed
API Error 400: "tools.11.custom.name: String should match pattern '^[a-zA-Z0-9_-]{1,64}$'"
Solution:
- Ensure server name only contains letters, numbers, underscores and hyphens
- Name length should not exceed 64 characters
- Don't use special characters or spaces
Error 2: MCP Server Not Found
MCP server 'my-server' not found
Solution:
- Check if scope settings are correct
- Run
claude mcp listto confirm server has been added - Ensure you're in the correct directory (for local scope)
- Restart Claude Code
Error 3: Protocol Version Error
"protocolVersion": "Required"
Solution: This is a known bug in Claude Code, temporary solutions:
- Use wrapper scripts
- Ensure MCP server returns correct protocol version
- Update to latest version of Claude Code
Error 4: Windows Path Issues
Error: Cannot find module 'C:UsersusernameDocuments'
Solution: Windows paths need to use forward slashes or double backslashes:
# Wrong
claude mcp add fs -- npx -y @modelcontextprotocol/server-filesystem C:\Users\username\Documents
# Correct
claude mcp add fs -- npx -y @modelcontextprotocol/server-filesystem C:/Users/username/Documents
# or
claude mcp add fs -- npx -y @modelcontextprotocol/server-filesystem C:\\Users\\username\\Documents
Error 5: Permission Issues
Permission denied
Solution:
- macOS/Linux: Use
sudo(not recommended) or modify file permissions - Windows: Run as administrator
- Best method: Install MCP servers in user directory
Debugging Techniques
When encountering problems, these debugging methods can help you quickly locate issues:
1. Enable Debug Mode
claude --mcp-debug
2. View MCP Status
In Claude Code, enter:
/mcp
3. View Log Files
macOS/Linux:
tail -f ~/Library/Logs/Claude/mcp*.log
Windows:
type "%APPDATA%\Claude\logs\mcp*.log"
4. Manually Test Server
# Directly run server command to see if there's output
npx -y @modelcontextprotocol/server-filesystem ~/Documents
Special Notes for International Users
1. Non-English Path Issues
Avoid using non-English characters in paths:
# Avoid
claude mcp add fs -- npx -y @modelcontextprotocol/server-filesystem ~/文档
# Recommended
claude mcp add fs -- npx -y @modelcontextprotocol/server-filesystem ~/Documents
2. Proxy Configuration
If you're using a proxy:
# Set npm proxy
npm config set proxy http://your-proxy:port
npm config set https-proxy http://your-proxy:port
# Then add MCP server
claude mcp add ...
3. Mirror Sources
Use mirror sources to accelerate downloads:
# Temporary use
claude mcp add fs -- npx -y --registry=https://registry.npmjs.org @modelcontextprotocol/server-filesystem ~/Documents
# Or permanent setting
npm config set registry https://registry.npmjs.org
Best Practice Recommendations
- Add as needed: Don't add too many MCP servers at once, it will affect performance
- Regular cleanup: Use
claude mcp remove <name>to delete unused servers - Security first: Only add trusted MCP servers, especially those requiring network access
- Backup configuration: Regularly backup
~/.claude.jsonfile - Team collaboration: Use project scope to share common configurations
Advanced Techniques
1. Create Custom MCP Server
If existing MCP servers can't meet your needs, you can create your own:
// my-mcp-server.js
import { Server } from '@modelcontextprotocol/sdk';
const server = new Server({
name: 'my-custom-server',
version: '1.0.0',
});
server.setRequestHandler('tools/list', async () => {
return {
tools: [{
name: 'my_custom_tool',
description: 'Custom tool',
inputSchema: {
type: 'object',
properties: {
input: { type: 'string' }
}
}
}]
};
});
server.start();
2. Batch Configuration Script
Create a script to configure all common MCP servers at once:
#!/bin/bash
# setup-mcp.sh
echo "Configuring common MCP servers..."
# File system
claude mcp add filesystem -s user -- npx -y @modelcontextprotocol/server-filesystem ~/Documents ~/Projects
# GitHub
read -p "Enter GitHub Token: " github_token
claude mcp add github -s user -e GITHUB_TOKEN=$github_token -- npx -y @modelcontextprotocol/server-github
# Other servers...
echo "MCP servers configured successfully!"