Claude Code MCP Servers Guide — Setup, Examples, Troubleshooting

9 min read · Claude Code integration guide

Claude Code is useful on its own, but the moment you want it to read a Postgres schema, open a GitHub issue, or list files outside your repo, you hit a wall. That wall is the point where MCP servers start mattering. MCP — the Model Context Protocol — is the standard interface Claude Code uses to talk to external tools and data sources, and knowing how to wire one up cleanly is the difference between a terminal agent that can only see your repo and one that can act across your whole stack.

This guide covers what MCP actually is, when you need a server and when you don't, how Claude Code discovers servers across three config scopes, a copy-pasteable .mcp.json example, how to verify a server is connected, the failure modes worth knowing in advance, and the security model you should assume by default. If you want the adjacent primitives, see the Claude Code hooks guide and the slash commands reference.

What is the Model Context Protocol?

MCP is an open specification for how an AI client (Claude Code, Claude Desktop, Zed, and others) talks to external tools and data sources. An MCP server is a small program — typically a Node or Python process — that exposes three kinds of things over a standard JSON-RPC protocol: tools (functions Claude can call, like query_database or open_issue), resources (read-only data Claude can fetch, like file contents or API responses), and prompts (reusable prompt templates the server ships). Claude Code spawns the server as a child process (stdio transport) or connects to it over HTTP, then routes tool calls across the protocol during a session.

The spec and current SDK list live at modelcontextprotocol.io. The headline point: you don't have to write one to use one. A growing catalog of community and official servers already covers most of what a coding agent wants to reach.

When you actually need MCP servers

Most Claude Code sessions don't need any MCP server. If the task lives inside your repo, the built-in file tools are enough. You start reaching for MCP when the work crosses a boundary:

The anti-pattern is adding a server because it sounds useful. Each server adds startup time, a config surface, and a security boundary. Add them when a specific recurring task justifies the cost.

How Claude Code loads MCP servers

Current Anthropic docs describe three MCP config scopes: local, project, and user. The terminology matters because the storage files are not always what the scope name would suggest.

When the same server name appears in more than one scope, local wins, then project, then user.

.claude/settings.local.json is a general Claude Code settings file — it is not an MCP server scope. Don't put server definitions there; they won't load. For the authoritative layout and any per-release changes, read docs.anthropic.com/claude-code/mcp — this guide covers the mechanism and the stable shape of the config.

Popular MCP servers compared

A representative slice of what's actually useful day-to-day. This is not exhaustive — check the MCP site and the community catalog for the current list.

Server What it does Transport Best for
filesystem Exposes a mounted directory (outside the current project) as readable/writable resources. stdio Reading sibling repos, shared docs folders, or design archives without cd-ing out of the project.
github Search repos, read issues/PRs, open issues, comment, inspect workflows via the GitHub API. stdio Multi-repo work, triaging issues, scripting release notes from PR titles.
postgres Connects to a Postgres instance; exposes schema introspection and SQL execution as tools. stdio Schema review, read-only analytics queries, verifying migration effects on a dev DB.
puppeteer Drives a headless Chromium; navigate, click, screenshot, and read page state. stdio Smoke-testing a deploy, scraping a one-off page, verifying a fix in a live UI.
slack Reads channels, posts messages, searches history across a Slack workspace. stdio Pulling context from a channel before writing code, summarizing a thread into a PR description.
sequential-thinking A structured "think step-by-step" tool that forces the model to decompose a problem before acting. stdio Long planning tasks where you want the model to externalize reasoning into a dedicated tool call.
context7 Fetches up-to-date library documentation on demand so the model doesn't rely on stale training data. stdio or HTTP Working with fast-moving libraries (new frameworks, breaking SDK versions) where hallucinated APIs are a risk.

A minimal working .mcp.json

Drop this at the root of your repo. Claude Code reads it on session start. This example wires up the filesystem server (scoped to a shared notes folder) and the GitHub server (using an env var — never inline a token).

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/you/notes",
        "/Users/you/shared-docs"
      ]
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"
      }
    }
  }
}

Field-by-field:

Token hygiene: secrets belong in user-scope config (claude mcp add --scope user, which writes to ~/.claude.json) or an env var from your shell profile — never inline in the committed .mcp.json. The committed file should reference env vars only, so it's safe to push and safe to share.

How to verify a server is actually connected

Two reliable signals, both release-stable:

The exact chrome for this (labels, pane names, keybindings) shifts between Claude Code releases. For per-release detail, treat docs.anthropic.com/claude-code as the source of truth and this guide as the mechanism-level reference.

Common failure modes and fixes

Security considerations you should default to

MCP servers fall into two broadly different threat models. Reason about each one separately before connecting a server — the "safe" defaults for one class aren't defaults at all for the other.

Local stdio servers

These are programs spawned on your machine as child processes of Claude Code. They run with your user's permissions and can read or write anything your shell can.

Defaults that keep blast radius small:

Remote HTTP / SSE servers (including OAuth)

Remote MCP servers reach a cloud endpoint rather than a local binary. The threat model is different — and often more consequential than local risk, because data flows off-box and actions run under delegated credentials.

Across both classes: if you didn't write the server, read its tool list in the source or README before enabling. "Looks useful" is not a review.

Frequently asked questions

Do I need MCP servers to use Claude Code?

No. Claude Code works on any repo out of the box. MCP servers are optional extensions that connect Claude Code to external tools or data sources — databases, GitHub, Slack, filesystems outside the project — when the task genuinely needs that reach. Most sessions don't need any MCP server.

What's the difference between MCP servers and slash commands?

Slash commands are local prompt shortcuts you define in Markdown files under .claude/commands/. MCP servers are external processes that connect Claude Code to tools and data sources via a standard JSON-RPC protocol. Slash commands shape the prompt; MCP servers expand what Claude Code can actually do.

Can I write my own MCP server?

Yes. The Model Context Protocol spec is public at modelcontextprotocol.io. Any language with a JSON-RPC library works. Reference SDK implementations exist in TypeScript and Python, and the community maintains a growing catalog of servers for common integrations.

Are MCP servers specific to Claude Code?

No. MCP is an open protocol. Servers written for Claude Desktop, Zed, Cline, or any other MCP-compatible client work in Claude Code too, and vice versa. That portability is the point of the protocol.

How do I troubleshoot an MCP server that won't connect?

Check the command path in your config — absolute paths are safer than relying on PATH. Verify required env vars are present in the shell that launched Claude Code. Run the server binary manually outside Claude Code and read its stderr to see why it's crashing. Then restart the Claude Code session so it re-reads the config.

Two kits that cover the Claude Code + Cursor workflow

MCP servers are one piece of a Claude Code workflow. The Claude Code Starter Kit covers the rest — CLAUDE.md templates, slash commands, hooks patterns — so a new repo is productive on day one. The Cursor Rules kit covers the adjacent surface if some of your team drives from the IDE instead of the terminal.

Claude Code Starter Kit

5 CLAUDE.md templates, 10 slash commands, hooks cookbook, 20 power prompts. Pairs directly with the MCP setup patterns on this page.

FREE
Download free →

Cursor Rules Starter Kit

5 .cursorrules templates (including Agent Mode guardrails), 10 Composer prompt snippets, settings + model selection guide.

FREE
Download free →

Saved you time? Tip the maker in BTC — no account, no signup, just paste.

BTC bc1qs04leape97ner4wqa98n94l9n0gv9aa84eg4ux