mcp

MCP Servers in Claude Code: What They Are and How to Install Them

Quick Answer

MCP servers are local or remote processes that expose tools to Claude Code via the Model Context Protocol. Claude can call these tools (read a database, search the web, run a browser) just like its built-in tools. Install them via 'claude mcp add' or directly in settings.json.

The Model Context Protocol (MCP) is an open standard that lets AI assistants like Claude talk to external systems through a typed tool interface. An MCP server is a process — Node.js script, Python program, or binary — that implements this protocol and registers one or more callable tools.

When Claude Code starts, it connects to all configured MCP servers and discovers their available tools. Those tools appear alongside Claude's built-in tools (read_file, bash, etc.) and Claude can choose to call them when they are relevant. A Postgres MCP server adds a 'query_database' tool; a Puppeteer server adds 'screenshot' and 'click'; a GitHub server adds 'create_pr' and 'list_issues'.

MCP servers communicate over stdio (local process) or HTTP+SSE (remote). The stdio transport is most common for development — Claude Code spawns the server as a child process and communicates over stdin/stdout. The HTTP transport is used for remote or shared servers.

You can add MCP servers at three scopes: user-level (available in all projects, stored in ~/.claude/settings.json), project-level (stored in .claude/settings.json, checked into git), or local-project (stored in .claude/settings.local.json, gitignored). Use 'claude mcp add' for interactive setup or edit the JSON directly.

Examples

Add an MCP server via CLIbash
# Add a server at user scope (available in all projects)
claude mcp add --scope user filesystem npx @modelcontextprotocol/server-filesystem /home/user/projects

# Add a server at project scope (stored in .claude/settings.json)
claude mcp add --scope project postgres npx @modelcontextprotocol/server-postgres postgresql://localhost/mydb

# List configured servers
claude mcp list

# Remove a server
claude mcp remove filesystem
Manual settings.json configurationjson
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["@modelcontextprotocol/server-filesystem", "/home/user/projects"],
      "env": {}
    },
    "postgres": {
      "command": "npx",
      "args": ["@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"]
    },
    "github": {
      "command": "npx",
      "args": ["@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here"
      }
    }
  }
}
HTTP transport (remote MCP server)json
{
  "mcpServers": {
    "remote-tools": {
      "transport": "http",
      "url": "https://mcp.example.com/sse",
      "headers": {
        "Authorization": "Bearer ${MY_MCP_TOKEN}"
      }
    }
  }
}

Tips

  • Run 'claude mcp list' to see all configured servers and their connection status — useful for debugging.
  • Use project-scope (.claude/settings.json) for team-shared servers and user-scope (~/.claude/settings.json) for personal ones like your local filesystem.
  • MCP server env vars support ${VAR_NAME} substitution from your shell environment — never hardcode secrets in the JSON.
  • If a server fails to start, Claude Code will warn you but continue — check 'claude mcp list' output for errors.
  • The @modelcontextprotocol/server-* packages on npm are the official reference implementations — start there before building custom servers.

FAQ

Do MCP tools count against Claude's context window?+

Yes. Each MCP tool definition is included in the system prompt, and each tool call result is added to the conversation context. Servers with many tools or that return large payloads can eat into your context budget. Prefer servers that return concise, structured data.

Is MCP the same as Claude skills?+

No. Skills are markdown files in .claude/skills/ that provide Claude with instructions for how to behave. MCP servers provide actual executable tools that Claude can invoke to take actions. Think of skills as 'knowledge' and MCP as 'hands.'

Can I use MCP servers in headless/CI mode?+

Yes. When running 'claude --headless' or in GitHub Actions, all configured MCP servers start normally. Just ensure environment variables (API tokens, database URLs) are available in the CI environment.

What is the security model for MCP?+

MCP servers run with the same OS permissions as Claude Code itself. Claude Code will ask for permission before calling an MCP tool that could have side effects (writing files, making network requests) unless you have pre-approved those tool types in your permissions settings.

Related Guides