Best MCP Servers for Claude Code: Lean Setup & Token Tradeoffs
Pick the best MCP servers for Claude Code with a lean 5-server stack, project-scoped .mcp.json configs, and deferred loading to cut context bloat.
The best MCP servers for Claude Code are not a 25-tool catalog—they are a lean five-server stack covering live docs (Context7), repository workflows (GitHub MCP), accessibility-tree browser checks (Playwright MCP), production telemetry (Sentry MCP), and read-only database inspection (Postgres or Supabase). Loading five to ten unfiltered Model Context Protocol servers into a single session can inject 200+ tool schemas and burn 40,000 to 65,000 tokens before your first prompt even lands. A disciplined Context-Budget Approach pairs three to five high-leverage servers with project-scoped .mcp.json configuration, deferred tool loading, and routine /context audits.
Key Takeaways
- Skip redundant local tools: Generic filesystem, shell, and basic git MCP servers duplicate Claude Code's native capabilities and inflate prompt overhead for zero gain.
- Cap active servers at 3–5 per repository: Context7, GitHub MCP, Playwright MCP, Sentry MCP, and a read-only Postgres/Supabase MCP cover external knowledge, verification, and production context cleanly.
- Standardize via
.mcp.jsonand env interpolation: Commit repo-shared server definitions with--scope projectand${GITHUB_PAT}placeholders so teammates share the same setup without leaking credentials.- Use deferred loading and
/context: Anthropic's Tool Search Tool withdefer_loading: truekeeps large tool catalogs out of the initial prompt prefix, preserving prompt caching and tool-selection accuracy.
Why Most Claude Code MCP Lists Hurt Your Agent
Connecting every trending server from a "best MCP servers for coding" roundup degrades Claude Code before it writes a single line of code. Every registered MCP tool serializes its name, description, and JSON input schema into the model's context window, and piling on five to ten unfiltered servers routinely registers 200+ schemas that consume 40,000–65,000 tokens upfront.
That 50k+ token tax hurts in two ways. First, you lose working memory for repository files, diffs, and test output right out of the gate. Second, large overlapping tool catalogs degrade tool-selection accuracy: when the model sees three different ways to read a file or inspect a git diff, it wastes turns picking the wrong tool or passing malformed arguments.
The biggest offender is installing MCP servers that duplicate tools Claude Code already ships natively. Skip these categories outright:
- Generic filesystem MCPs: Claude Code already has native file reading, editing, and search tools tuned for its harness.
- Local shell or bash MCPs: Wrapping terminal execution inside an extra MCP layer adds schema weight without improving on Claude Code's built-in shell execution—and if your team wants cleaner command automation, solid Bash scripting and shell workflows beat another MCP wrapper.
- Basic local git MCPs: Running
git status,git diff, orgit logworks directly through native tooling; you only need a GitHub MCP for remote PR reviews, issue triage, and cross-repository queries.
Before adding anything new, measure what your current session is paying. Inside Claude Code, run /context to inspect token allocation across system instructions, conversation history, and MCP tool definitions, and use /mcp (documented in the official Claude Code MCP guide) to check connected server status and prune unused integrations.
The High-Leverage 5-Server Stack for Real Codebases
A production-ready Claude Code MCP setup only connects servers that give the agent external state it cannot get from your local working tree. The five servers below earn their token budget because each closes a concrete engineering blind spot: stale framework docs, remote repo workflows, live browser rendering, production errors, and real database schemas.
| MCP Server | Transport | Core Tools / Capability | Blind Spot Solved | Recommended Scope |
|---|---|---|---|---|
Context7 (@upstash/context7-mcp) |
Local stdio |
resolve-library-id, query-docs |
Outdated API guesses and version drift | --scope user or --scope project |
GitHub MCP (github/github-mcp-server) |
Remote HTTP (https://api.githubcopilot.com/mcp/) |
PR reviews, issue triage, cross-repo code search | Context trapped outside the local Git clone | --scope project |
Playwright MCP (@playwright/mcp@latest) |
Local stdio |
Accessibility-tree browser control and DOM assertions | Unverified frontend edits and screenshot bloat | --scope local or --scope project |
Sentry MCP (mcp.sentry.dev) |
Remote HTTP | Production stack traces, performance spans, issue context | Copy-pasting error logs into local debugging | --scope project |
| Database MCP (Postgres / Supabase) | Local stdio or Remote HTTP |
Read-only schema inspection, EXPLAIN ANALYZE profiling |
Blind ORM changes and unindexed query plans | --scope local (read-only role) |
Context7 for Version-Pinned Library Documentation
Upstash Context7 eliminates the most common failure mode in AI-assisted development: hallucinating deprecated methods or mixing syntax across major framework versions. Running @upstash/context7-mcp exposes just two focused tools—resolve-library-id and query-docs—so Claude Code fetches live, version-specific documentation on demand without bloating the tool list. Because its schema footprint is tiny, it pays for itself in almost every modern web, backend, or AI coding agent porting workflow.
GitHub MCP for PR Workflows and Cross-Repo Search
Local Git history stops at your current checkout, which leaves the agent blind to open pull request discussions, linked issues, and code living in sibling services. GitHub's official MCP server supports both local execution and a hosted remote HTTP endpoint (https://api.githubcopilot.com/mcp/). Using the hosted HTTP endpoint avoids local binary maintenance while giving Claude Code structured access to PR diffs, review threads, issue triage, and cross-repo search.
Playwright MCP for Accessibility-Tree Browser Verification
Microsoft Playwright MCP (npx @playwright/mcp@latest) lets Claude Code open your local dev server, click through flows, and verify its own UI fixes. Crucially, it operates on structured accessibility trees rather than passing full-page screenshots on every step. Compared to vision-heavy loops, accessibility snapshots cost far fewer tokens and give the model deterministic element references—making it a strong complement to traditional cross-browser testing tools.
Sentry MCP for Production Stack Traces and Spans
Debugging a production incident normally starts with copying stack traces, breadcrumbs, and request metadata out of a browser tab. Sentry's official MCP server (mcp.sentry.dev) pulls live production stack traces, performance traces, and issue context straight into your Claude Code session. The agent can correlate an active Sentry issue with local source files, propose a regression test, and verify the fix in one loop.
Database MCP for Read-Only Schema and Query Profiling
Application code rarely tells the full story about real production indexes, constraints, or row distributions. Connecting a strictly read-only Postgres or Supabase MCP server lets Claude Code inspect actual table schemas and run EXPLAIN ANALYZE to profile slow queries before suggesting migrations or index additions. Keep this server scoped tightly to read-only credentials so an exploratory debugging prompt can never alter schema or data.
Working Setup: CLI Commands and Team-Shared .mcp.json
Setting up Claude Code MCP servers cleanly comes down to matching transport (http vs. stdio) and configuration scope (local, user, or project) to how your team works. As detailed in the Claude Code MCP documentation, you register servers through claude mcp add, verify active definitions with claude mcp list, and manage runtime authentication interactively via /mcp.
For hosted remote endpoints, use --transport http; for local Node packages, pass -- before the npx command so flags are not parsed by the Claude CLI:
# Remote HTTP servers (hosted endpoints)
claude mcp add --transport http --scope project github https://api.githubcopilot.com/mcp/
claude mcp add --transport http --scope project sentry https://mcp.sentry.dev
# Local stdio servers
claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp
claude mcp add --scope local playwright -- npx -y @playwright/mcp@latest
# Verify registered servers and transports
claude mcp listChoosing Between Local, User, and Project Scopes
Putting every server into your global user config is how engineers end up paying a 50k-token tax on every tiny script repo. Scope each integration to the narrowest layer where it actually adds value:
| Scope Flag | Where Config Lives | Committed to Git? | Best Used For |
|---|---|---|---|
--scope local |
Local project-specific config (private to you) | No | Machine-specific tools, personal Playwright debugging, read-only dev DB credentials |
--scope user |
~/.claude.json |
No | Universal, low-token tools you want in every repo (such as Context7) |
--scope project |
.mcp.json at repository root |
Yes | Team-standard repo tools (GitHub, Sentry, shared frontend test setup) |
A Copy-Pasteable .mcp.json Template Without Hardcoded Secrets
When you standardize a Claude Code .mcp.json file in Git, never commit raw API keys or personal access tokens. Use environment variable interpolation (${GITHUB_PAT}) so every engineer supplies their own scoped token via shell environment or secret manager:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"]
},
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer ${GITHUB_PAT}"
}
},
"playwright": {
"command": "npx",
"args": ["-y", "@playwright/mcp@latest"]
},
"sentry": {
"type": "http",
"url": "https://mcp.sentry.dev"
}
}
}Pair this committed .mcp.json with a private --scope local registration for your read-only Postgres or Supabase MCP so connection strings never appear in repository history. Anyone cloning the repo gets the same core stack immediately after approving the project config and authenticating via /mcp.
Controlling Token Overhead With Deferred Tool Loading
MCP deferred tool loading solves the context-bloat problem architecturally by keeping full JSON schemas out of the initial prompt prefix until the model actually asks for them. In Anthropic Engineering's breakdown of advanced tool use, the Tool Search Tool pattern marks non-core tools with defer_loading: true, leaving only essential always-on tools and lightweight discovery metadata loaded at session start.
{
"type": "mcp_toolset",
"mcp_server_name": "github",
"default_config": {
"defer_loading": true
}
}When the agent needs a specific capability—say, fetching a pull request review comment or inspecting a Sentry performance trace—it invokes Tool Search to pull only the matching tool definitions into context. That architecture delivers two major wins for coding agents:
- Prompt cache preservation: Because the initial system and tool prefix stays small and stable across turns, prompt caching stays effective instead of thrashing under massive static tool catalogs.
- Higher tool-selection accuracy: With fewer irrelevant schemas competing for attention on routine code-editing turns, the model picks the right native or MCP tool far more reliably.
Deferred loading is a safety net, not an excuse to wire up 20 random servers. Treat it alongside three practical guardrails: cap always-on servers to three to five per repository, move single-purpose servers (like Playwright in a backend-only service) out of --scope user, and run /context after changing .mcp.json to confirm active versus deferred token counts.
Security and Permission Guardrails for Production Teams
Every MCP server you attach inherits whatever privileges its credentials grant, which means an over-permissioned token turns an autonomous coding loop into a production risk. Treat MCP credentials with the same least-privilege discipline you apply to CI runners.
Apply three non-negotiable boundaries before rolling out .mcp.json across an engineering org:
- Enforce least-privilege credentials everywhere: Connect database MCPs strictly with a read-only database role (
SELECTandEXPLAINonly—noINSERT,UPDATE,DELETE, or DDL). For GitHub, issue fine-grained, repository-scoped PATs rather than broad classic personal tokens, or use interactive OAuth flows via/mcpwhere supported. - Separate read/research MCPs from write/deploy MCPs: Keep your default
.mcp.jsonrestricted to read, verification, and PR-level workflows. Do not mix infrastructure mutation, production deploy, or database-write MCPs into the same always-on config used for autonomous bug-fix loops. - Keep secrets out of version control: Rely on
${ENV_VAR}interpolation in.mcp.jsonand OAuth sessions managed through/mcp, and review diffs to.mcp.jsonduring normal PR review just like CI workflow files.
Frequently Asked Questions
How Many MCP Servers Should I Connect to Claude Code at Once?
Cap always-on MCP servers to three to five per repository. Connecting five to ten unfiltered servers can register 200+ tool schemas and burn 40,000–65,000 tokens before your first prompt, shrinking working context and hurting tool-selection accuracy.
What Is the Difference Between claude mcp add --scope user and .mcp.json in Claude Code?
claude mcp add --scope user stores a server in your personal ~/.claude.json file so it loads across every repository on your machine. Using --scope project writes a .mcp.json file at the repository root that you commit to Git so the entire team shares the exact same repo-specific tool setup.
How Do I Check How Many Tokens My MCP Servers Are Using in Claude Code?
Run /context inside a live Claude Code session to inspect how many tokens your active and deferred MCP tool schemas consume. Pair that with claude mcp list from the terminal or /mcp inside the session to audit which servers are connected and disable unused ones.
Should I Install a Filesystem or Bash MCP Server for Claude Code?
No—skip generic filesystem, local bash, and basic local git MCP servers. Claude Code already provides native file, shell, and git workflows, so adding duplicate MCP servers wastes context tokens and increases tool-selection confusion without adding new capabilities.
Engineering workflows, AI coding tools, and developer guides published on DuneBook.