Model Context Protocol (MCP) is Anthropic’s open standard for connecting AI assistants to external tools and data sources. Think of MCP servers as plugins — each one gives Claude a new capability: browsing the web, querying a database, executing code, calling APIs.

This guide gets you from zero to a working MCP setup in Claude Code or Claude Desktop.


What MCP Does

Without MCP: Claude knows what you tell it in the conversation.

With MCP: Claude can:

  • Browse live web pages
  • Query your database
  • Read/write files outside its default access
  • Call external APIs
  • Execute code and see the results
  • Interact with your computer’s GUI

Each MCP server exposes specific tools. You choose which servers to connect.


Setting Up MCP in Claude Desktop

1. Find the config file

On macOS:

~/Library/Application Support/Claude/claude_desktop_config.json

On Windows:

%APPDATA%\Claude\claude_desktop_config.json

2. Edit the config

Open the file (create it if it doesn’t exist) and add your MCP servers:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you/Documents"]
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "your-token-here"
      }
    }
  }
}

3. Restart Claude Desktop

Close and reopen Claude Desktop. In a new conversation, you’ll see the hammer icon (🔨) indicating tools are available.


Essential MCP Servers to Install

Filesystem — Access local files

"filesystem": {
  "command": "npx",
  "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/directory"]
}

Gives Claude read/write access to a directory you specify. Useful for: working with documents, analyzing data files, processing codebases.

GitHub — Repository access

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

Lets Claude read repositories, create issues, and interact with GitHub. Useful for: code review, issue analysis, repository exploration.

Brave Search — Web browsing

"brave-search": {
  "command": "npx",
  "args": ["-y", "@modelcontextprotocol/server-brave-search"],
  "env": {
    "BRAVE_API_KEY": "your-brave-api-key"
  }
}

Gives Claude live web search capability. Get a free API key at search.brave.com/help/api.

SQLite / PostgreSQL — Database access

For SQLite:

"sqlite": {
  "command": "npx",
  "args": ["-y", "@modelcontextprotocol/server-sqlite", "--db-path", "/path/to/database.db"]
}

For PostgreSQL (via custom server):

"postgres": {
  "command": "npx",
  "args": ["-y", "mcp-server-postgres"],
  "env": {
    "DATABASE_URL": "postgresql://user:password@localhost:5432/dbname"
  }
}

Useful for: data analysis, query generation, database exploration.


Setting Up MCP in Claude Code

For Claude Code (terminal), MCP servers are configured via the --mcp flag or a config file:

# Add an MCP server permanently
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem /path/to/dir

# List configured servers
claude mcp list

# Run with a specific server for a session
claude --mcp filesystem

Or edit ~/.claude/mcp_servers.json directly with the same format as the Desktop config.


Building Your Own MCP Server

You can build custom MCP servers for any tool or API your workflow needs. Here’s a minimal Python server:

#!/usr/bin/env python3
"""Minimal MCP server that exposes a weather tool."""

import asyncio
import json
from mcp.server import Server
from mcp.server.models import InitializationOptions
import mcp.types as types

server = Server("weather-server")

@server.list_tools()
async def handle_list_tools() -> list[types.Tool]:
    return [
        types.Tool(
            name="get_weather",
            description="Get current weather for a city",
            inputSchema={
                "type": "object",
                "properties": {
                    "city": {"type": "string", "description": "City name"}
                },
                "required": ["city"]
            }
        )
    ]

@server.call_tool()
async def handle_call_tool(name: str, arguments: dict) -> list[types.TextContent]:
    if name == "get_weather":
        city = arguments["city"]
        # Your actual weather API call here
        weather_data = {"city": city, "temp": "72°F", "condition": "Sunny"}
        return [types.TextContent(type="text", text=json.dumps(weather_data))]

async def main():
    from mcp.server.stdio import stdio_server
    async with stdio_server() as (read_stream, write_stream):
        await server.run(read_stream, write_stream, InitializationOptions())

asyncio.run(main())

Install the MCP Python SDK:

pip install mcp

Register it in your config:

"weather": {
  "command": "python",
  "args": ["/path/to/weather_server.py"]
}

Using MCP Tools in Conversations

Once your servers are configured, Claude automatically knows about the available tools. You don’t need to invoke them explicitly — just ask for what you need and Claude will use the tools when appropriate.

Natural requests that trigger tool use:

  • “Read the CSV file at /Users/me/data.csv and tell me the average revenue per customer”
  • “Search the web for recent news about [company]”
  • “Query my database for all users who signed up in the last 30 days”
  • “Look at the issues in my GitHub repo and categorize them by type”

If Claude isn’t using a tool when you expect it to, be more explicit: “Use the filesystem tool to read /path/to/file”


Troubleshooting

“Server failed to start”: Check that the npm package is available. Run npx -y @modelcontextprotocol/server-[name] in your terminal to see the error.

“Tool not found”: The server may have started but Claude isn’t seeing the tools. Restart Claude Desktop/Code. Check that your JSON config is valid (no trailing commas, properly quoted strings).

API key errors: Double-check the env section of your config. Environment variables must be string values.

Permission errors on filesystem: The path you specified must exist and be readable by the Claude process.


Security Considerations

MCP servers have real access to real systems. Some cautions:

  • Give filesystem access only to directories Claude needs, not your entire home folder
  • Use read-only database credentials when possible for MCP database access
  • Be careful with MCP servers from untrusted sources — they execute arbitrary code
  • Don’t put API keys directly in config files that are version-controlled; use environment variable references instead

MCP gives Claude significant capabilities. The principle of least privilege applies: give each server exactly the access it needs, no more.