Understanding MCP
What the Model Context Protocol actually is, how servers connect to your agent, and how to debug them.
MCP (Model Context Protocol) is the open standard for connecting tools to AI agents. Write or install a server once, and it works in Claude Code, Codex CLI, Grok Build, Gemini CLI, Cursor, Goose, and most other runners. Think "USB for agent capabilities."
Created by Anthropic in late 2024, it's now adopted across the ecosystem — OpenAI, Google, Microsoft, GitHub, and thousands of community servers.
The mental model
Your agent (client) ←—— MCP protocol ——→ Server (the capability)
Claude Code Playwright (browser)
Codex CLI GitHub (issues/PRs)
Grok Build Postgres (your data)
Cursor… Sentry (prod errors)
A server exposes three kinds of things to the agent:
| Primitive | What it is | Example |
|---|---|---|
| Tools | Actions the agent can call | browser_click, create_issue, run_query |
| Resources | Data the agent can read | a file, a database schema, a log stream |
| Prompts | Reusable prompt templates the server offers | "summarize this PR" |
Tools are what you'll use 95% of the time.
Local vs. remote servers
| Local (stdio) | Remote (HTTP) | |
|---|---|---|
| Runs | On your machine, launched by the agent | Hosted by the provider |
| Config | A command: npx -y @playwright/mcp@latest | A URL: https://mcp.linear.app/sse |
| Auth | Env vars (API keys) | OAuth flow in the browser |
| Examples | filesystem, Playwright, git | GitHub, Linear, Sentry, Notion |
Remote servers are newer and increasingly preferred for SaaS products — no install, and OAuth beats pasting API keys.
Adding servers, per runner
# Claude Code — local server
claude mcp add playwright -- npx -y @playwright/mcp@latest
# Claude Code — remote server
claude mcp add --transport http github https://api.githubcopilot.com/mcp/
# Claude Code — with an API key
claude mcp add brave-search --env BRAVE_API_KEY=YOUR_KEY -- npx -y @brave/brave-search-mcp-server
Grok Build is MCP-native — it picks up the same servers with zero reconfiguration, so anything you wired up for Claude Code already works there. Other runners use a JSON config with the same shape — Codex CLI (~/.codex/config.toml), Gemini CLI (~/.gemini/settings.json), Cursor (.cursor/mcp.json), Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["-y", "@playwright/mcp@latest"]
}
}
}
Tip for teams (Claude Code): check a .mcp.json into your repo root and every teammate gets the project's servers automatically — full example.
A sane starter set
Don't install twenty servers. Each one's tool definitions consume context on every request. Start with:
- Playwright — a real browser
- Context7 — current library docs, kills hallucinated APIs
- GitHub — if your work lives there
- One data source you actually use — Postgres, Supabase, or Sentry
Add more when a task actually needs them. Browse the full directory.
Security: the part people skip
An MCP server runs with your permissions and feeds output straight into your agent's context. Treat installs like dependencies:
- Prefer official servers (look for the publisher:
@modelcontextprotocol/*,@playwright/mcp, GitHub's, Brave's…) - Prefer read-only modes for data sources — e.g. Supabase's
--read-only, Postgres--access-mode=restricted - Scope filesystem access to specific directories, never
/ - Beware tool-output injection: a malicious web page or issue comment can contain instructions your agent might follow. Browsing + private-data + write-access in one session is the risky combination — drop one of the three when handling untrusted content.
Debugging a server that won't work
- Test it standalone with the official inspector:
npx @modelcontextprotocol/inspector npx -y @playwright/mcp@latest— if it fails here, the problem is the server or its env, not your agent. - Check the runtime exists — npm servers need Node;
uvxservers need uv. - Check env vars — most "server crashed" errors are a missing API key. The inspector shows stderr.
- In Claude Code:
/mcplists servers and their connection status. - Tool exists but isn't used? Tell the agent explicitly ("use the playwright tools to…") once; if it works, the tool descriptions may be getting crowded out — remove servers you're not using.