Skip to main content

How to Setup Claude Code MCP Servers

Model Context Protocol (MCP) servers extend Claude Code's capabilities by connecting to external APIs and services. I configure MCP servers to give Claude access to real-time web search through Brave's Search API and up-to-date documentation through Context7, enabling current information retrieval and accurate API references during development workflows.



How to Use It

Configuration File Location - Create MCP configuration in ~/.claude.json for reliability:

{
"projects": {
"/path/to/your/project": {
"mcpServers": {
"brave-search": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-brave-search"]
},
"context7": {
"command": "npx",
"args": ["-y", "context7-mcp"]
}
}
}
}
}

Alternative Configuration Locations - MCP servers can also be configured in:

  • .claude/settings.local.json (project-specific)
  • ~/.claude/settings.local.json (user-specific local)
  • ~/.claude/settings.json (user-specific global)
  • ~/.claude/mcp_servers.json (dedicated MCP file)


Why Use MCP Servers

MCP servers bridge the gap between Claude Code's built-in capabilities and external tools, providing Claude with specialized access to systems and services that enhance coding workflows.

Benefits:

  • Project Customization - Configure different MCP servers for different projects based on specific needs
  • External API Access - Connect Claude to specialized services beyond built-in capabilities
  • Up-to-Date Information - Get fresh search results instead of relying on training data cutoffs
  • Modular Architecture - Add or remove specific capabilities without affecting core Claude Code functionality

I use MCP servers when I need Claude to access current information that isn't in its training data. Brave Search is particularly useful for finding recent documentation and troubleshooting information, while Context7 provides up-to-date, version-specific API references and code examples directly from official sources.


Managing MCP Servers

Enable/Disable via @Mentioning - Toggle MCP servers on or off during your session by @mentioning them:

@brave-search disable
@context7 enable

Interactive Management with /mcp - Use the /mcp slash command to view and manage all configured MCP servers:

/mcp

This opens an interactive interface showing all MCP servers with their current status (enabled/disabled) and allows you to toggle them on or off.

Context Window Optimization - Disabling unused MCP servers reduces context window usage. Each enabled MCP server adds tool definitions to Claude's system prompt, consuming part of your context window even when not actively used. I disable MCP servers when:

  • Approaching context window limits during long coding sessions
  • Working on focused tasks that don't require external data access
  • Running extended thinking operations (ultrathink) that need maximum context space
  • Performing large refactoring or multi-file operations
  • Optimizing token costs for smaller, self-contained tasks

Use the /context command to monitor how much context each MCP server consumes and identify optimization opportunities.

Configuration Reliability

Use ~/.claude.json as the primary configuration location rather than the various alternative locations. This approach provides the most consistent behavior across different Claude Code versions.

Server Installation

MCP servers using npx commands will automatically install when first accessed. Ensure you have Node.js installed for npm-based MCP servers to function properly.


See Also: Configuration Guide|Brave Search MCP|Context7 MCP|Context Inspection|Add-ons