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
Build MCP Server | Build MCP Client | Server Examples | Popular MCP servers
Adding soon..
# Basic syntax
claude mcp add <name> <command> [parameters...]
# Actual example: Add local file system access
claude mcp add my-filesystem -- npx -y @modelcontextprotocol/server-filesystem ~/Documents
# Example with environment variables
claude mcp add api-server -e API_KEY=your-key-here -- /path/to/server |
1. Find configuration file location:
2. Edit configuration file: {
"mcpServers": {
"filesystem": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/username/Documents"],
"env": {}
},
"github": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "your-github-token"
}
}
}
} 3. Restart Claude Code to take effect |
# Add project-level MCP server
claude mcp add shared-tools -s project -- npx -y @your-team/mcp-tools This will create a {
"mcpServers": {
"shared-tools": {
"command": "npx",
"args": ["-y", "@your-team/mcp-tools"],
"env": {}
}
}
} |
Understanding scope is crucial to avoid "server not found" errors:
- Only available in current directory
- Configuration stored in the projects section of
~/.claude.json
- Suitable for: Personal project-specific tools
- Available in all projects
- Added using
-s user
flag - Suitable for: Common tools like file systems, database clients
- Shared through
.mcp.json
file - Added using
-s project
flag - Suitable for: Team-shared project-specific tools
Here's the most worthwhile MCP server list to install:
claude mcp add filesystem -s user -- npx -y @modelcontextprotocol/server-filesystem ~/Documents ~/Projects ~/Desktop
Use: Let Claude directly read and write files, modify code
claude mcp add github -s user -e GITHUB_TOKEN=your-token -- npx -y @modelcontextprotocol/server-github
Use: Manage issues, PRs, code reviews
claude mcp add puppeteer -s user -- npx -y @modelcontextprotocol/server-puppeteer
Use: Automated web operations, crawling, testing
claude mcp add postgres -s user -e DATABASE_URL=your-db-url -- npx -y @modelcontextprotocol/server-postgres
Use: Directly query and manipulate databases
claude mcp add fetch -s user -- npx -y @kazuph/mcp-fetch
Use: Call various REST APIs
claude mcp add search -s user -e BRAVE_API_KEY=your-key -- npx -y @modelcontextprotocol/server-brave-search
Use: Search for latest information
claude mcp add slack -s user -e SLACK_TOKEN=your-token -- npx -y @modelcontextprotocol/server-slack
Use: Send messages, manage channels
claude mcp add time -s user -- npx -y @modelcontextprotocol/server-time
Use: Time zone conversion, date calculation
claude mcp add memory -s user -- npx -y @modelcontextprotocol/server-memory
Use: Save information across conversations
claude mcp add thinking -s user -- npx -y @modelcontextprotocol/server-sequential-thinking
Use: Step-by-step thinking for complex problems
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
MCP server 'my-server' not found
Solution:
- Check if scope settings are correct
- Run
claude mcp list
to confirm server has been added - Ensure you're in the correct directory (for local scope)
- Restart Claude Code
"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: 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
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
When encountering problems, these debugging methods can help you quickly locate issues:
claude --mcp-debug
In Claude Code, enter:
/mcp
macOS/Linux:
tail -f ~/Library/Logs/Claude/mcp*.log
Windows:
type "%APPDATA%\Claude\logs\mcp*.log"
# Directly run server command to see if there's output
npx -y @modelcontextprotocol/server-filesystem ~/Documents
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
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 ...
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
- 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.json
file - Team collaboration: Use project scope to share common configurations
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();
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!"