MCP: Extending Claude's Reach
Out of the box, Claude Code can read files, run shell commands, and search your codebase. That's powerful, but it's a closed system. What if Claude could query your production database directly? Or control a browser? Or interact with your GitHub issues without you copy-pasting context?
That's what MCP does.
What is MCP?
The Model Context Protocol is an open standard for connecting AI models to external tools and data sources. Think of it as USB for AI -- a universal interface that lets Claude plug into anything.
An MCP server exposes tools (functions Claude can call), resources (data Claude can read), and prompts (templates Claude can use). Claude Code acts as an MCP client, discovering and calling these tools as needed.
Without MCP, Claude Code operates on your local files and terminal. With MCP, it can query databases, control browsers, manage cloud infrastructure, interact with APIs, and more. Every MCP server you add expands what Claude can do without you writing glue code.
Adding MCP Servers
There are two ways to add an MCP server: the CLI command, or editing a config file directly.
Via CLI
# stdio transport (local process)
claude mcp add --transport stdio my-server npx -y @modelcontextprotocol/server-filesystem /path/to/dir
# HTTP transport (remote server)
claude mcp add --transport http my-api-server https://api.example.com/mcp
# SSE transport (server-sent events)
claude mcp add --transport sse my-sse-server https://example.com/mcp/sseTransport Types
| Transport | How it works | Best for |
|---|---|---|
| stdio | Spawns a local process, communicates via stdin/stdout | Local tools (filesystem, databases, CLI wrappers) |
| http | HTTP request/response to a remote URL | Hosted MCP services, remote APIs |
| sse | Server-sent events for streaming from a remote URL | Long-running connections, real-time data |
Most MCP servers you'll use are stdio -- they run as local processes on your machine.
Configuration Files
MCP servers are configured in two places:
Project-level: .mcp.json
Lives in your project root. Committed to git so your whole team gets the same tools.
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "./src"]
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "your-token-here"
}
},
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "postgresql://localhost:5432/mydb"
}
}
}
}User-level: ~/.claude.json
Personal config that applies to all your projects. Good for tools you always want available.
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["-y", "@playwright/mcp", "--browser", "chromium"]
}
}
}Project-level .mcp.json is for tools the whole team needs (database access, project-specific APIs). User-level ~/.claude.json is for personal tools (browser automation, personal API keys). Project config takes precedence when both define the same server name.
Lazy Loading and Tool Search
When you have many MCP servers configured, loading all their tools at startup wastes context window space. Claude Code solves this with lazy loading via the ENABLE_TOOL_SEARCH environment variable (enabled by default).
With tool search enabled, Claude doesn't load all MCP tools upfront. Instead, it discovers tools on-demand -- when a task requires a specific capability, Claude searches for matching tools and loads only what it needs.
This means you can have dozens of MCP servers configured without paying a context cost for tools you're not using in the current conversation.
Practical Examples
Filesystem MCP
Gives Claude structured access to specific directories with fine-grained permissions:
claude mcp add --transport stdio filesystem npx -y @modelcontextprotocol/server-filesystem /Users/me/projectsGitHub MCP
Lets Claude interact with GitHub issues, PRs, and repositories directly:
claude mcp add --transport stdio github npx -y @modelcontextprotocol/server-githubNow Claude can list issues, create PRs, read PR comments, and search code -- all without you leaving the terminal.
Database MCP
Connect Claude to a Postgres database for direct queries:
claude mcp add --transport stdio postgres npx -y @modelcontextprotocol/server-postgresClaude can then inspect schemas, run queries, and help debug data issues with full context.
Playwright MCP
Give Claude a browser it can control for testing and verification:
claude mcp add --transport stdio playwright npx -y @playwright/mcp --browser chromiumClaude can navigate pages, take screenshots, fill forms, and verify your UI works correctly.
MCP servers run with your local permissions. A filesystem server can read anything in its configured directory. A database server has whatever access its connection string grants. Be deliberate about what you expose -- especially in .mcp.json files committed to git. Never commit secrets directly; use environment variables or .env files.
Exercises
Add a filesystem MCP server
Add a filesystem MCP server scoped to your project's src directory, then ask Claude to list the files it can see.
claude mcp add with the --transport stdio flag and the @modelcontextprotocol/server-filesystem package.# Add the server
claude mcp add --transport stdio filesystem npx -y @modelcontextprotocol/server-filesystem ./src
# Verify it's configured
cat .mcp.json
# Start Claude Code and ask:
# "What files can you see via the filesystem MCP?"The server will appear in your .mcp.json. Claude can now use filesystem tools to list, read, and search files in ./src.
Add the GitHub MCP server
Add the GitHub MCP server, then ask Claude to list open issues on one of your repositories.
GITHUB_TOKEN env var in the MCP config.# Add with environment variable
claude mcp add --transport stdio github npx -y @modelcontextprotocol/server-github
# Then edit .mcp.json to add the env block:{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "ghp_your_token_here"
}
}
}
}# Start Claude Code and ask:
# "List open issues on my-org/my-repo"The filesystem and GitHub servers are the best starting demos because they're zero-config beyond a token. For more advanced audiences, Playwright is impressive -- show Claude navigating a deployed app and taking screenshots to verify a feature works.
What's Next
MCP extends Claude's capabilities externally. In the next section, we'll look at how sub-agents extend Claude's capabilities internally -- by running multiple Claude instances in parallel.