Most coding agents ship with basic file and shell tools. When you want an agent to pull up-to-date framework docs (like Context7), query a local database, or inspect a live browser, MCP (Model Context Protocol) acts like a USB-C port for AI tools: build or install one MCP server, and you can reuse it across Claude Code, Codex, and OpenCode.
Two ways MCP servers connect
- Local process (
stdio): the client spawns a child process vianpx,uvx, or a local binary and talks over stdin/stdout. Easy to configure with no open ports, though it requires Node.js or Python installed locally. - Remote service (
http/sse): the client connects to a running server URL with OAuth or an auth header—useful for shared team tools or hosted vendor integrations.
Client configuration
Claude Code
Add a local Context7 server from the command line:
claude mcp add context7 -- npx -y @upstash/context7-mcp
Or commit a project-level .mcp.json:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"]
}
}
}
Codex CLI
Add a block under mcp_servers in ~/.codex/config.toml:
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
Pass any server-specific secrets via the env table rather than polluting your global shell, and keep real keys out of shared files.
OpenCode
Check your version first with opencode --version. In OpenCode V2, declare servers under mcp.servers in opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"servers": {
"context7": {
"type": "local",
"command": ["npx", "-y", "@upstash/context7-mcp"]
}
}
}
}
OpenCode V1 puts server names directly under mcp and toggles them with enabled, whereas V2 uses disabled: true to turn a server off. See the MCP configuration docs and V1 migration notes for details.
Two traps to watch for
1. Every MCP server eats context on every turn
Each connected server injects all of its tool names, descriptions, and JSON parameter schemas into the system prompt on every round-trip. Enabling five or six heavy servers at once can burn 10,000+ tokens before you even ask a question—painful when you are working within a free tier’s tight context or TPM limits. Keep only the one or two servers a project actually needs enabled.
2. Local servers run with your user permissions
A local stdio MCP server can read files and make network requests just like your terminal user. Only run packages you have reviewed, connect database MCPs using read-only credentials, and never commit production passwords into .mcp.json or opencode.json.