Connect Claude Code to external tools and services via MCP servers
Model Context Protocol (MCP) is an open standard that lets AI models connect to external tools and services. Instead of building custom integrations, you add an MCP server and Claude gets new capabilities instantly.
Think of MCP servers like USB devices — plug them in and they just work.
| Transport | Use Case | Example |
|---|---|---|
| stdio | Local tools that run as processes | Language servers, CLI wrappers |
| HTTP (Streamable) | Remote services with request/response | Cloud APIs, SaaS integrations |
| SSE | Legacy streaming connections | Older MCP servers |
Q: What's the difference between stdio and HTTP transport for MCP servers?
<details> <summary>💡 Reveal Answer</summary>stdio servers run as local processes on your machine — Claude communicates via stdin/stdout. Best for local tools like language servers. HTTP servers are remote services — Claude makes HTTP requests to them. Best for cloud APIs and SaaS integrations. There's also SSE for legacy streaming, but HTTP is the modern standard.
</details>Full access
Unlock all 14 lessons, templates, and resources for Claude Code Mastery. Free.
# Add a stdio server
claude mcp add github -- npx @modelcontextprotocol/server-github
# Add with environment variables
claude mcp add sentry -e SENTRY_AUTH_TOKEN=your-token-here -- \
npx @modelcontextprotocol/server-sentry
# Add a remote HTTP server
claude mcp add remote-tool --transport http --url https://api.example.com/mcp
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "your-github-token-here"
}
},
"remote-api": {
"type": "http",
"url": "https://api.example.com/mcp"
}
}
}
claude --mcp-config ./mcp-servers.json
Use --strict-mcp-config to ignore all other MCP configs.
| Scope | Location | Shared? |
|---|---|---|
| User | ~/.claude/settings.json | Personal, all projects |
| Project | .claude/settings.json | Team via git |
| Local | .claude/settings.local.json | Personal, this project |
# Add to specific scope
claude mcp add github --scope user -- npx @modelcontextprotocol/server-github
claude mcp add sentry --scope project -- npx @modelcontextprotocol/server-sentry
Q: You want everyone on your team to have access to the GitHub MCP server. Which scope should you use?
Project scope — add it to .claude/settings.json which is committed to git and shared with the team. Each developer will still need their own GITHUB_TOKEN, which they can set in their .claude/settings.local.json or as an environment variable.
| Server | Package | Purpose |
|---|---|---|
| GitHub | @modelcontextprotocol/server-github | PRs, issues, repos |
| GitLab | @modelcontextprotocol/server-gitlab | Merge requests, CI |
| Server | Purpose |
|---|---|
| Atlassian (Jira/Confluence) | Issues, docs |
| Linear | Issues, projects |
| Notion | Pages, databases |
| Vercel | Deployments |
| Sentry | Error tracking |
| Server | Purpose |
|---|---|
| PostgreSQL | SQL queries |
| SQLite | Local databases |
Many remote MCP servers use OAuth:
claude mcp add my-service --transport http --url https://api.example.com/mcp
# Claude will prompt for OAuth flow on first use
Tokens are stored securely and refreshed automatically.
Fill in the blanks:
claude mcp ___ <name>/___claude mcp add <name>HTTP/mcpWhen you have many MCP servers, tool definitions consume context. Tool Search automatically defers idle tools and loads them on-demand.
# Trigger when tools exceed 5% of context
export ENABLE_TOOL_SEARCH=auto:5
Each MCP server adds tool definitions to every message. 10 servers with 5 tools each = 50 tool definitions consuming tokens on every turn. Tool Search eliminates this overhead.
Control MCP tool access with permission rules:
{
"permissions": {
"allow": [
"mcp__github__create_pull_request",
"mcp__github__list_issues"
],
"deny": [
"mcp__github__delete_repository",
"mcp__puppeteer__*"
]
}
}
| Pattern | Matches |
|---|---|
mcp__server__tool | Specific tool on specific server |
mcp__server__* | All tools from a server |
Q: Why might you prefer using the gh CLI over the GitHub MCP server?
Context efficiency. The GitHub MCP server adds tool definitions to every message, consuming tokens even when idle. The gh CLI runs via Bash with zero persistent overhead — Claude just runs gh pr list or gh issue create as needed. MCP servers shine for tools without a good CLI equivalent, but when a CLI exists, it's often more token-efficient.
Subagents can have their own MCP servers:
# .claude/agents/db-admin.md
---
description: Database administration tasks
mcpServers:
- postgres
---
You are a database admin. Use the PostgreSQL tools to manage the database.
| Approach | Context Cost | Best For |
|---|---|---|
CLI tools via Bash (gh, aws, sentry-cli) | Zero persistent overhead | Tools with good CLIs |
| MCP servers | Tool definitions in every message | Tools without CLI equivalents, OAuth flows |
Fill in the blanks:
export ENABLE_TOOL_SEARCH=auto:___mcp__servername____10%5mcp__servername__*/mcp
claude mcp add github --scope user -- npx @modelcontextprotocol/server-github
gh pr list via Bash instead/context — notice the difference?Reflection: For your most-used tools, would MCP or CLI be more efficient?
Scenario: Your team uses 8 MCP servers (GitHub, Sentry, Slack, Notion, PostgreSQL, Redis, Vercel, Linear). Sessions are running out of context quickly. What would you do?
Three strategies:
Enable Tool Search with an aggressive threshold:
export ENABLE_TOOL_SEARCH=auto:5
Replace MCP servers with CLIs where possible — gh for GitHub, sentry-cli for Sentry, vercel for Vercel. That's 3 fewer servers consuming context.
Scope servers to subagents instead of the main session:
# .claude/agents/db-admin.md
---
mcpServers: ["postgres", "redis"]
---
The database tools only load when the subagent is spawned.
| Concept | One-Liner |
|---|---|
| What MCP is | Open standard for connecting AI to external tools |
| Transports | stdio (local), HTTP (remote), SSE (legacy) |
| Scopes | user, project, local |
| Add server | claude mcp add <name> -- <command> |
| Tool Search | Auto-defers idle tools when >10% of context |
| Permissions | mcp__server__tool pattern in rules |
| CLI vs MCP | CLI has zero persistent overhead; MCP is better for complex/OAuth tools |
| View servers | /mcp command; /context for usage |
Next up: Plugins & Marketplaces → — Bundle and distribute skills, hooks, and MCP servers as installable packages.