The good news about MCP (Model Context Protocol) is that a server written once works in every agent that speaks the protocol. The annoying part is that every agent wants it configured differently: JSON in one place, TOML in another, a slightly different key name in a third.
This guide shows exactly how to add an MCP server to Cursor, Codex, Gemini CLI and opencode, with copy-paste config for each, plus which features each client supports. We have Codex, Gemini CLI, opencode and Claude Code all installed on the machine this was written on, and every config format was checked against official docs on September 26, 2026. Looking for which servers to install? See our list of the best MCP servers for Claude: every server in it works in these agents too.
- Any MCP server works in Cursor, Codex, Gemini CLI, opencode and Claude Code. All five support local (stdio) servers and remote HTTP servers with OAuth.
- Config files: Cursor uses .cursor/mcp.json, Codex uses ~/.codex/config.toml, Gemini CLI uses .gemini/settings.json, opencode uses opencode.json.
- Codex, Gemini CLI and Claude Code have an mcp add command, so you rarely edit files by hand.
- Gemini CLI uses httpUrl for remote servers, and opencode wants the command as an array. Those two trip people up most.
- Big servers like GitHub (90+ tools) can crowd the context in agents without on-demand tool loading. Use tool filters.
Which clients support what
| Cursor | Codex CLI | Gemini CLI | opencode | Claude Code | |
|---|---|---|---|---|---|
| Local (stdio) servers | Yes | Yes | Yes | Yes | Yes |
| Remote HTTP servers | Yes | Yes | Yes | Yes | Yes |
| OAuth login | Yes | codex mcp login | Yes (oauth block) | Automatic | /mcp |
| Add from command line | No (one-click install instead) | codex mcp add | gemini mcp add | No (edit config) | claude mcp add |
| Project-level config | .cursor/mcp.json | .codex/config.toml (trusted projects) | .gemini/settings.json | opencode.json | .mcp.json |
| Global config | ~/.cursor/mcp.json | ~/.codex/config.toml | ~/.gemini/settings.json | ~/.config/opencode/opencode.json | ~/.claude.json |
| Filter tools per server | No documented option | enabled_tools, disabled_tools | includeTools, excludeTools | Glob patterns in tools | Via toolset flags |
| Loads tools on demand | Not documented | Not documented | Not documented | No | Yes (tool search) |
That last row matters more than it looks. Claude Code only loads a tool's full definition when it needs it. The others load every tool from every enabled server up front, so the GitHub server's 90+ tools cost context on every message. opencode's own docs single out GitHub as a server that "can easily exceed the context limit". Use tool filters in agents that have them.
Gemini CLI's MCP support is excellent, but since June 18, 2026 it only serves Gemini Code Assist Standard or Enterprise licences and paid API keys. Free and Google AI Pro users moved to Antigravity CLI. Details in our Claude Code vs Codex vs Gemini CLI vs opencode comparison.
Setup for each client
The examples below add two servers: Context7 (remote) and Playwright (local). Swap in any server you like.
Cursor
Create .cursor/mcp.json in your project, or ~/.cursor/mcp.json for every project:
{
"mcpServers": {
"context7": {
"url": "https://mcp.context7.com/mcp",
"headers": { "Authorization": "Bearer ${env:CONTEXT7_API_KEY}" }
},
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
}
}Cursor supports ${env:NAME} and ${workspaceFolder} in configs, so keys stay out of the file. OAuth servers show "Needs login" in settings; click it. Many servers also offer a one-click "Add to Cursor" button.
Codex CLI
The quickest way is the command:
codex mcp add playwright -- npx @playwright/mcp@latest
codex mcp add context7 --url https://mcp.context7.com/mcp --bearer-token-env-var CONTEXT7_API_KEY
codex mcp listOr edit ~/.codex/config.toml directly:
[mcp_servers.playwright]
command = "npx"
args = ["@playwright/mcp@latest"]
[mcp_servers.github]
url = "https://api.githubcopilot.com/mcp/"
bearer_token_env_var = "GITHUB_PAT"
enabled_tools = ["list_issues", "get_issue", "create_pull_request"]The same file is shared by the Codex CLI, the IDE extension and the desktop app, so you set a server up once. enabled_tools is the easiest way to tame a big server. Run codex mcp login <name> for OAuth servers.
Gemini CLI
gemini mcp add -s user playwright npx @playwright/mcp@latest
gemini mcp add -s user -t http context7 https://mcp.context7.com/mcpThe default scope is the project; -s user makes it global. In settings.json it looks like this. Note that a streamable HTTP server uses httpUrl, not url (which means the older SSE transport):
{
"mcpServers": {
"context7": { "httpUrl": "https://mcp.context7.com/mcp" },
"github": {
"httpUrl": "https://api.githubcopilot.com/mcp/",
"headers": { "Authorization": "Bearer $GITHUB_PAT" },
"includeTools": ["list_issues", "get_issue"]
}
}
}Type /mcp inside Gemini CLI to see server status.
opencode
opencode has no add command; you edit opencode.json in the project or ~/.config/opencode/opencode.json. Local servers take the command as an array:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"playwright": {
"type": "local",
"command": ["npx", "@playwright/mcp@latest"],
"enabled": true
},
"context7": {
"type": "remote",
"url": "https://mcp.context7.com/mcp"
}
},
"tools": {
"github*": false
}
}OAuth starts automatically for remote servers that need it (opencode mcp auth <name> to do it by hand). The tools block uses glob patterns to switch a server's tools off globally, and you can switch them back on for a single agent. That is a neat way to give only your "review" agent access to GitHub.
Claude Code (for comparison)
claude mcp add playwright -- npx @playwright/mcp@latest
claude mcp add --transport http context7 https://mcp.context7.com/mcp--scope project writes a .mcp.json your team can commit. Full details in our Claude MCP guide.
Five servers to start with
Once your client is set up, these are the servers we would add first. Each one is written up in full, with safety notes, in our best MCP servers for Claude list.
- Context7 (
https://mcp.context7.com/mcp): current library docs, only two tools. - Playwright MCP (
npx @playwright/mcp@latest): lets the agent drive a browser and check its UI work. - GitHub MCP (
https://api.githubcopilot.com/mcp/): issues, PRs and Actions. Filter its tools. - Your database vendor's server: Supabase, Neon or DBHub for plain SQL. Read-only mode on.
- Sentry (
https://mcp.sentry.dev/mcp): errors and stack traces, so "find and fix the new bug" is one prompt.
One config for every agent?
There is no single shared MCP config file yet. Two ways to avoid maintaining five copies:
- Docker MCP Gateway. Configure servers once in Docker's gateway, then connect each client to the gateway (
docker mcp client connect <client>). Each server runs in its own container with managed secrets. - Prefer remote servers. A remote URL with OAuth is one line in every client and needs no local runtime. Most vendors (GitHub, Supabase, Sentry, Linear, Notion, Figma, Cloudflare, Vercel) now offer one.
Some servers restrict which clients can connect. Vercel's MCP server, for example, only accepts approved clients; Cursor, Codex, Gemini CLI, opencode and Claude Code are all on its list.
Security checklist
- Use official vendor servers; read the code of any community server first
- Turn on read-only modes (Supabase
read_only=true, GitHub/readonly, Neonreadonly=true) - Reference secrets as environment variables, never paste them into a committed config
- Filter tools on big servers to cut both context use and blast radius
- Never give an agent production database or live payment credentials
- Treat anything a server returns as untrusted: web pages and tickets can carry prompt injection
Setting up an agent from scratch? Pick one with our comparison of Claude Code, Codex, Gemini CLI and opencode, or go zero-cost with our free AI coding agents guide. If you run a home server, our home lab MCP servers list covers Proxmox, Docker and Home Assistant.
Do MCP servers work in Cursor, Codex and Gemini CLI?
Where is the MCP config file for Codex?
How do I add an MCP server to opencode?
Why does the GitHub MCP server use so much context?
What is the best MCP server for coding?

Sumit
ContributorHi, I'm Sumit, Being an introvert I have always been obsessed with technology-computers and reading dozens of posts to learn, find answers out of my curiosity. I love to write as I explore more.






