Guide

Best MCP Servers for Coding Agents (2026)

Model Context Protocol (MCP) servers are the connective tissue between your coding agent and the outside world. Connect the right two or three and your agent can pull live library docs, open GitHub PRs, run browser tests, and search the web without leaving the terminal. Connect too many and you drown it in tools it ignores. This guide covers the five most-used MCP servers for coding agents in 2026, shows you the exact commands to add each one in Claude Code, OpenCode, and Codex, and explains the 2-3-not-5-7 rule that keeps agent performance sharp.

By DK, Editor  ·  Last verified: 2026-06-20  · Claude Code v2.1.183 (installed and run 2026-06-20); OpenCode v1.17.8 (installed and run 2026-06-20); Codex CLI v0.141.0 (installed and run 2026-06-20)  ·  How we test

Before you start

  • A recent Node.js LTS release and npm — confirm the current minimum Node version required by each tool on its own documentation before installing
  • Claude Code installed: npm i -g @anthropic-ai/claude-code
  • OpenCode installed: curl -fsSL https://opencode.ai/install | bash OR npm i -g opencode-ai OR brew install sst/tap/opencode
  • Codex CLI installed: npm i -g @openai/codex
  • Auth configured for each client (Claude account or ANTHROPIC_API_KEY for Claude Code; opencode auth for OpenCode; codex login for Codex)
  • API keys or OAuth tokens for any MCP server that requires them (GitHub PAT, Exa API key, etc.) — see each server's own docs

Steps

  1. 01

    Understand the tool-bloat rule before connecting anything

    Every MCP server you connect adds tools to the agent's context window. Coding agents in 2026 work best when they have 2–3 focused servers active at once. Connecting more than 5–7 servers causes tool bloat: the model spends token budget choosing between tools rather than writing code, and performance degrades noticeably. The practical pattern is: add the servers you actually need for the task at hand, and remove or disable others. All three clients let you list and remove servers at any time.

  2. 02

    Context7 — live library documentation (fixes outdated-API hallucination)

    Context7 fetches up-to-date documentation for the libraries in your project and injects it into the agent's context. Without it, agents hallucinate deprecated APIs because their training data is months or years stale. This is the single highest-value server for day-to-day coding work. Add to Claude Code (stdio transport, confirm the exact package name on the Context7 docs):

    claude mcp add context7 -- npx -y @upstash/context7-mcp
  3. 03

    GitHub MCP — repos, issues, PRs, CI, and code search

    The GitHub MCP server exposes your repositories, issues, pull requests, CI status, and code search as agent tools. Your agent can open a PR, check a failing CI run, or search across repos without you switching context. Note: the npm package `@modelcontextprotocol/server-github` is deprecated (last published 2025, npm marks it as no longer supported). GitHub's officially supported server is `github-mcp-server`, available as a hosted remote HTTP endpoint. Add it to Claude Code using the HTTP transport (confirm the exact URL on GitHub's MCP documentation):

    claude mcp add --transport http github https://api.githubcopilot.com/mcp --header "Authorization: Bearer your_pat_here"
  4. 04

    Playwright MCP — browser automation and UI testing

    The Playwright MCP server gives the agent a real browser it can navigate, click, screenshot, and assert against. Use it when you need the agent to test a UI change, scrape a page that requires JavaScript, or run end-to-end checks as part of a coding task. Add to Claude Code (stdio, confirm the exact package name on the Playwright MCP docs):

    claude mcp add playwright -- npx -y @playwright/mcp
  5. 05

    Exa — semantic web search (the most-used search MCP in 2026)

    Exa runs neural/semantic search over the live web. Your agent can research an error message, find an example implementation, or check whether a library has a known issue — without leaving the coding session. It requires an Exa API key. Add to Claude Code (stdio with API key env var — confirm the exact package name on exa.ai docs):

    claude mcp add exa -e EXA_API_KEY=your_exa_key_here -- npx -y exa-mcp-server
  6. 06

    Desktop Commander — terminal and filesystem access

    Desktop Commander exposes shell execution, file read/write, and process management as MCP tools. It is useful for agents that need to run build scripts, inspect logs, or manipulate files as part of a coding workflow — particularly in OpenCode or Codex where you want those operations to go through the structured MCP layer rather than raw tool calls. Add to Claude Code (stdio — confirm the exact package name on the Desktop Commander docs):

    claude mcp add desktop-commander -- npx -y @wonderwhy-er/desktop-commander
  7. 07

    Add MCP servers in OpenCode

    OpenCode uses the same MCP protocol but its own CLI surface. Use `opencode mcp add` to register a server interactively, `opencode mcp list` (alias: `ls`) to see what is connected, and `opencode mcp auth` for servers that use OAuth. List registered servers and their status:

    opencode mcp list
  8. 08

    Add and inspect MCP servers in Codex

    Codex stores server configuration in ~/.codex/config.toml. Use the `codex mcp` subcommands to manage servers from the CLI, or edit the TOML file directly following the format in the Codex docs. If something is wrong, `codex doctor` will diagnose install, config, auth, and runtime health in one pass. List servers registered in Codex:

    codex mcp list
  9. 09

    Verify, get details, and remove servers

    All three clients expose get and remove commands. Use them to inspect a server's registered config or clean up servers you no longer need (keeping active count at 2–3). Claude Code:

    claude mcp get <name>
    claude mcp remove <name>
    claude mcp list
  10. 10

    Handle the approval flow in Claude Code

    When a server is added to a project-scoped .mcp.json file it appears as pending-approval until you explicitly approve it in the Claude Code session. If tools from a newly added server are not showing up, check whether the server is still pending. Run `claude mcp reset-project-choices` to reset all approved/rejected decisions for the project's .mcp.json servers and go through the approval flow again.

    claude mcp reset-project-choices

Popular MCP servers

  • Context7

    Fetches live, version-matched library documentation and injects it into agent context. Prevents agents from hallucinating deprecated APIs. The highest-value server for general coding work.

    claude mcp add context7 -- npx -y @upstash/context7-mcp
  • GitHub MCP

    Exposes GitHub repos, issues, pull requests, CI status, and code search as agent tools. Lets the agent open PRs, check CI failures, and search code without leaving the terminal. Use the officially supported github-mcp-server via its remote HTTP endpoint — the old @modelcontextprotocol/server-github npm package is deprecated. Confirm the exact endpoint URL on GitHub's MCP documentation.

    claude mcp add --transport http github https://api.githubcopilot.com/mcp --header "Authorization: Bearer your_pat_here"
  • Playwright MCP

    Gives the agent a real Chromium browser for navigating pages, clicking, screenshotting, and running end-to-end UI tests as part of a coding task.

    claude mcp add playwright -- npx -y @playwright/mcp
  • Exa

    Neural/semantic search over the live web. The most-used search MCP for coding agents in 2026. Requires an Exa API key (confirm at exa.ai).

    claude mcp add exa -e EXA_API_KEY=your_exa_key_here -- npx -y exa-mcp-server
  • Desktop Commander

    Terminal execution, file read/write, and process management as structured MCP tools. Useful when you want shell operations to flow through the MCP layer rather than raw agent tool calls.

    claude mcp add desktop-commander -- npx -y @wonderwhy-er/desktop-commander

Troubleshooting

Newly added server tools are not showing up in the agent session (Claude Code)
The server may be sitting in pending-approval state. Project-scoped servers added via .mcp.json require explicit approval. Run `claude mcp reset-project-choices` and restart the session to go through the approval flow. Also run `claude mcp list` to confirm the server is registered and check `claude mcp get <name>` for its config.
npx: command not found when Claude Code tries to start an MCP server
Claude Code launches MCP server processes using your shell's PATH. If npx is not on PATH for the shell that Claude Code inherits (common after nvm installs or when launching from an app rather than a terminal), add the node/npm bin directory to your PATH in ~/.zshrc or ~/.bashrc and relaunch the terminal before running claude.
OpenCode shows an MCP server as disconnected after `opencode mcp add`
Run `opencode mcp list` to see the server's status. For servers that require OAuth, use `opencode mcp auth <name>` to authenticate and `opencode mcp debug <name>` to inspect the OAuth connection. For stdio servers, verify the command path is correct and the binary is executable.
Codex does not pick up a server I added to ~/.codex/config.toml
Run `codex doctor` first — it diagnoses install, config, auth, and runtime health in one pass and will surface config parse errors. Then run `codex mcp list` to confirm Codex sees the server. TOML syntax errors (missing quotes, wrong section headers) are the most common cause of silent failures.
Agent performance gets sluggish or it ignores tools after connecting several servers
This is tool bloat. Connecting more than 5–7 MCP servers floods the model's context with tool definitions it does not use for the current task. Remove servers you are not actively using with `claude mcp remove <name>` (or the equivalent in your client) and keep the active count at 2–3 for the task at hand.

FAQ

Can I use the same MCP server in Claude Code, OpenCode, and Codex at the same time?
Yes. MCP servers are independent processes (typically stdio or HTTP). Each client manages its own list of registered servers, so you can register the same server in all three clients independently. They do not share state or interfere with each other.
How do I add an MCP server that requires an HTTP URL rather than a local command?
In Claude Code, pass `--transport http` followed by the URL: `claude mcp add --transport http <name> <url>`. For servers that also require an auth header, add `--header "Authorization: Bearer ..."`. OpenCode and Codex may support remote or HTTP servers via their configuration — their CLI surfaces differ from Claude Code's, so check each client's own docs for the exact approach.
What is the 2-3-not-5-7 rule and why does it matter?
Every connected MCP server adds its tools to the model's context window on every turn. With 2–3 focused servers the model quickly identifies the right tool for the job. With 5–7 or more, the model spends significant token budget evaluating irrelevant tools, and empirically agent quality degrades. The practical approach: add servers for the task you are working on now, and remove or disable others until you need them.
Do I need a running server process or can MCP servers be npm packages?
Both patterns exist. Many MCP servers are distributed as npm packages and launched on demand via `npx -y <package>` — Claude Code and Codex start the process for you when the session begins. Others are persistent HTTP servers you point to with a URL. Confirm which pattern a given server uses in its own documentation.
How do I pass secrets (API keys) to an MCP server without hardcoding them?
In Claude Code, use the `-e KEY=value` flag when running `claude mcp add`: for example `claude mcp add myserver -e API_KEY=xxx -- npx my-mcp-server`. This stores the environment variable binding in the server's registered config rather than in the command itself. For Codex, env vars can be set in ~/.codex/config.toml or passed with `-c key=value` at runtime. Check each server's own docs for which env var name it expects.