Adding an MCP server to Claude Code

Kashish Hora

Kashish Hora

Co-founder of MCPcat

Try out MCPcat

The Quick Answer

Add MCP servers to Claude Code with the command claude mcp add github --scope user. For complex configurations, skip the CLI wizard and edit the config file directly at ~/Library/Application Support/Claude/claude_desktop_config.json.

Popular servers include GitHub for PR management, Perplexity for research, Sequential Thinking for breaking down complex tasks, and Context7 for up-to-date documentation. After making changes, restart Claude Code and verify with claude mcp list.

Why Add MCP Servers to Claude Code?

MCP servers transform Claude Code from a smart assistant into a powerful development hub. Instead of switching between terminal, browser, and IDE, you get:

  • GitHub integration - Review PRs, manage issues, trigger CI/CD
  • Perplexity search - Research APIs and docs without leaving terminal
  • Sequential thinking - Break down complex refactoring tasks
  • Context7 documentation - Get real-time, version-specific library docs
  • File system access - Direct file manipulation beyond @ references

Two Ways to Add MCP Servers

Method 1: CLI Command (Quick but Limited)

$> claude mcp add github --scope user
$Enter GitHub personal access token: [paste token]
$✓ GitHub MCP server added successfully

Problem: One typo = start over. Complex configs = frustration.

$> code ~/Library/Application Support/Claude/claude_desktop_config.json

Add servers directly:

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here"
      }
    },
    "perplexity": {
      "command": "npx",
      "args": ["-y", "perplexity-mcp"],
      "env": {
        "PERPLEXITY_API_KEY": "pplx_your_key_here"
      }
    }
  }
}

Benefits:

  • See all configs at once
  • Copy between machines
  • Version control ready
  • Quick edits without wizards

Essential MCP Servers for Claude Code

1. GitHub - PR Management

"github": {
  "command": "npx",
  "args": ["-y", "@modelcontextprotocol/server-github"],
  "env": {
    "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxxxxxxxxxx"
  }
}

Usage in Claude Code:

$> Review all changes in PR #123 and suggest improvements
 
$I'll analyze PR #123 using the GitHub MCP server...
$[Claude reviews code and provides feedback]

2. Perplexity - Smart Research

"perplexity": {
  "command": "node",
  "args": ["/path/to/perplexity-mcp/build/index.js"],
  "env": {
    "PERPLEXITY_API_KEY": "pplx_xxxxxxxxxxxx",
    "PERPLEXITY_MODEL": "sonar"
  }
}

Usage:

$> Research the latest React Server Components best practices
 
$I'll search for current RSC patterns using Perplexity...
$[Claude provides up-to-date research]

3. Sequential Thinking - Complex Tasks

"sequential-thinking": {
  "command": "npx",
  "args": ["-y", "@modelcontextprotocol/server-sequential-thinking"]
}

Usage:

$> Plan a migration from Redux to Zustand
 
$I'll break this down using sequential thinking...
$[Claude creates step-by-step migration plan]

4. Context7 - Real-time Documentation

"context7": {
  "command": "npx",
  "args": ["-y", "@upstash/context7-mcp@latest"]
}

Usage:

$> Show me the latest Next.js 15 App Router patterns
 
$I'll fetch the current Next.js documentation using Context7...
$[Claude provides version-specific, up-to-date examples]

Platform-Specific Setup

macOS / Linux

# Config location
$~/Library/Application Support/Claude/claude_desktop_config.json
 
# Add server via CLI
$claude mcp add github --scope user

Windows

# Config location
$%APPDATA%\Claude\claude_desktop_config.json
 
# Add server (use cmd /c for npx)
$claude mcp add github --scope user -- cmd /c npx -y @modelcontextprotocol/server-github

Troubleshooting MCP Servers

Server Won't Connect

Test directly:

$echo '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2024-11-05"},"id":1}' | npx @modelcontextprotocol/server-github

Check logs:

# Find logs at
$~/.claude/logs/mcp-server-github.log

Verify config:

$> claude mcp get github
${
$ "command": "npx",
$ "args": ["-y", "@modelcontextprotocol/server-github"],
$ "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "***" }
$}

Permission Errors

# If you see "security: SecKeychainSearchCopyNext" errors
$> claude mcp remove github
$> claude mcp add github --scope project # Try project scope

Multiple Servers Conflict

{
  "mcpServers": {
    "github-work": { /* work config */ },
    "github-personal": { /* personal config */ }
  }
}

Use unique names to run multiple instances.

Power User Tips

1. Batch Server Setup

Create a setup script:

#!/bin/bash
# setup-mcp.sh
$claude mcp add-json github '{"command":"npx","args":["-y","@modelcontextprotocol/server-github"],"env":{"GITHUB_PERSONAL_ACCESS_TOKEN":"'$GITHUB_TOKEN'"}}'
$claude mcp add-json perplexity '{"command":"npx","args":["-y","perplexity-mcp"],"env":{"PERPLEXITY_API_KEY":"'$PERPLEXITY_KEY'"}}'
$claude mcp add context7 -- npx -y @upstash/context7-mcp@latest

2. Environment Variables

Keep secrets safe:

"env": {
  "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"
}

Then: export GITHUB_TOKEN=ghp_xxxx in your shell.

3. Quick Toggle Servers

# Disable without removing
$"github": {
$ "disabled": true, // Add this
$ "command": "npx",
$ ...
$}

4. Server Health Check

$> /mcp status
 
$Active MCP Servers:
$- github: ✓ Connected
$- perplexity: ✓ Connected
$- sequential-thinking: ✗ Failed to initialize
$- context7: ✓ Connected

5. Context7 for Documentation

$> @mycode.ts use context7 to show me proper TypeScript generics syntax
 
$I'll fetch the latest TypeScript documentation...
$[Claude provides current TypeScript patterns with accurate examples]

Security Best Practices

  1. Only install trusted servers - They run with full system access
  2. Use project scope for testing - --scope project limits to current directory
  3. Rotate API keys regularly - Especially for GitHub tokens
  4. Review server code - Check what permissions they request

What's Next?

Now that you have MCP servers configured:

  1. Test each server with simple commands
  2. Create CLAUDE.md to document which servers to use when
  3. Set up project-specific servers for specialized tools
  4. Explore the MCP server directory for more options

Quick Reference

Add server: claude mcp add [name] --scope user
List servers: claude mcp list
Remove server: claude mcp remove [name]
Test server: claude mcp get [name]
Config location:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Remember: Direct config editing beats CLI wizards for complex setups. Restart Claude after changes. Keep your fast intern well-equipped.