Issue 00 · Autumn 2026日本語 · RSS
AgentKoji

MCP Servers in Claude Code, Codex and Gemini CLI

How MCP servers plug into coding agents: transports, claude mcp add and scopes, OAuth and headers, output and time limits, tool permissions, and how Codex CLI and Gemini CLI compare. Checked 2026-11-14.

TL;DR

  • MCP servers give an agent tools, resources and prompts. In Claude Code you add one with claude mcp add at local (the default), project (.mcp.json) or user scope, and local wins over project, which wins over user.
  • Use HTTP (Streamable HTTP) for remote servers; SSE is deprecated. Claude Code signs in with OAuth from /mcp or claude mcp login, or sends headers you set.
  • Treat every server as code or text you are trusting. claude -p loads .mcp.json servers without asking, so block servers you don't want with disabledMcpjsonServers or --strict-mcp-config.

This page is a map of MCP servers in coding agents: what MCP provides, how Claude Code adds servers and picks which definition wins, how authentication, limits and permissions work, where Codex CLI and Gemini CLI keep the same settings, and the order in which to read our MCP articles. Every fact was checked against the official docs on 2026-11-14, when the latest Claude Code on npm was 2.1.325 and @modelcontextprotocol/sdk was 1.32.2.

We did not run any command for this hub. Where the docs did not state something, we left it out or marked it “unverified”.

What MCP gives an agent

MCP (Model Context Protocol) is an open standard that connects AI clients to tools, data sources and APIs. A server offers three kinds of things:

Server featureWhat it isHow you use it in Claude Code
ToolsFunctions the model callsNamed mcp__<server>__<tool>, the name permission rules and hook matchers use
ResourcesContent the server exposes@server:protocol://resource/path
PromptsTemplates the server definesRun /mcp__servername__promptname

The current MCP spec version is 2026-07-28, and its transports section lists stdio and Streamable HTTP. Claude Code has a v1 client runtime on TypeScript SDK 1.x and a v2 runtime on SDK 2.0, which adds revision 2026-07-28. MCP_SDK_GENERATION (v1 or v2) picks one yourself.

Transport in Claude CodeHow to addNotes
HTTP (http, or streamable-http in JSON)claude mcp add --transport http <name> <url>Recommended for remote servers. Supports OAuth
SSESame command; it falls back to SSE when the server rejects HTTP (v2.1.265+), or --transport sseDeprecated
stdioclaude mcp add [options] <name> -- <command> [args...]A local process. Everything after -- goes to the server
WebSocket (ws).mcp.json or claude mcp add-json onlyHeader-only auth, no OAuth

(source: https://code.claude.com/docs/en/mcp, checked 2026-11-14) (source: https://modelcontextprotocol.io/docs/2026-07-28/learn/versioning, checked 2026-11-14) (source: https://modelcontextprotocol.io/llms.txt, checked 2026-11-14)

Adding servers to Claude Code

Besides add, claude mcp has add-json, list, get, remove, login, logout, serve and more. In a session, /mcp shows status and lets you sign in, reconnect or turn a server off.

ScopeLoads inSharedStored in
local (default)Current projectNo~/.claude.json, under the project’s path
projectCurrent projectYes, via version control.mcp.json at the project root
userAll your projectsNo~/.claude.json

When a server is defined in several places, Claude Code connects once, from the highest-precedence source: local, project, user, plugin servers, claude.ai connectors. The whole entry is used and fields are not merged. A server from the managedMcpServers managed setting ranks above all of them (v2.1.259+).

An interactive session asks before using .mcp.json servers, and claude mcp list shows ⏸ Pending approval until you approve. A cloned repository can’t approve its own servers: enableAllProjectMcpServers or enabledMcpjsonServers committed to .claude/settings.json is ignored in an untrusted folder.

.mcp.json expands ${VAR} and ${VAR:-default} in command, args, env, url and headers. An unset variable without a default stays as literal ${VAR} text, with a warning.

(source: https://code.claude.com/docs/en/mcp, checked 2026-11-14)

Authentication

OAuth. A remote server that answers 401 or 403 is flagged in /mcp, where you sign in through the browser. claude mcp login <name> runs the same flow from a shell, and --no-browser prints the URL instead. claude mcp logout <name> clears stored credentials; remove deletes local tokens but doesn’t revoke them. A claude -p or Agent SDK run can’t run OAuth, so sign in interactively first.

Headers. --header or a headers object sends static values. headersHelper runs a command at connection time that prints a JSON object of headers, and Claude Code gives up on it after 10 seconds. If the server rejects an Authorization header you configured, the connection fails; there is no fallback to OAuth.

What can’t leak. In a remote server’s url and headers, credential variables read as empty: ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, cloud provider credentials and others such as NPM_TOKEN. A name outside that set, such as API_KEY, expands as written. A project or local-scope headersHelper runs only after you trust the folder.

(source: https://code.claude.com/docs/en/mcp, checked 2026-11-14)

Limits and timeouts

WhatDefaultSetting
Output warningAbove 10,000 tokens—
Output limit25,000 tokensMAX_MCP_OUTPUT_TOKENS
Text result saved to a fileOver 50,000 charactersTool’s _meta["anthropic/maxResultSizeChars"], up to 500,000
Wall clock per callAbout 28 hoursPer-server timeout (ms) or MCP_TOOL_TIMEOUT
Idle (no response or progress)5 min remote, 30 min stdioCLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT
Move to backgroundAfter 2 min in the main conversationCLAUDE_CODE_MCP_AUTO_BACKGROUND_MS

Tool search is on by default: only tool names and server instructions load at startup, and definitions load when needed. ENABLE_TOOL_SEARCH=false loads every tool upfront, and alwaysLoad: true keeps one server’s tools loaded.

(source: https://code.claude.com/docs/en/mcp, checked 2026-11-14)

Permissions for MCP tools

Rules name MCP tools in full. A plugin’s server adds the plugin name, mcp__plugin_<plugin-name>_<server-name>__<tool-name>, in permission rules, allowed-tools, a subagent’s tools and hook matchers.

For subagents, tools: mcp__github__* grants one server’s tools, disallowedTools: mcp__github withholds them and disallowedTools: mcp__* withholds every MCP tool.

A server can mark a tool with _meta["anthropic/requiresUserInteraction"]: true. Claude Code then prompts on every call, even in bypassPermissions, and allow rules don’t skip it.

How allow, ask and deny rules treat MCP globs is on the permissions page, which we did not re-check for this hub (unverified here). Our cheat sheet and choosing article cover it as of their check dates.

(source: https://code.claude.com/docs/en/mcp, checked 2026-11-14) (source: https://code.claude.com/docs/en/sub-agents, checked 2026-11-14)

Codex CLI and Gemini CLI

Claude CodeCodex CLIGemini CLI
Config~/.claude.json, .mcp.json[mcp_servers.<name>] in ~/.codex/config.toml or a trusted project’s .codex/config.tomlmcpServers in ~/.gemini/settings.json or .gemini/settings.json
Addclaude mcp add (default local)codex mcp add <name> -- <command>gemini mcp add (default project, stdio)
Transportsstdio, HTTP, SSE, WebSocketstdio, Streamable HTTPstdio, SSE (url), Streamable HTTP (httpUrl)
AuthOAuth, headers, headersHelperOAuth, bearer_token_env_var, http_headersOAuth (/mcp auth), headers
Limit toolsRules on mcp__<server>__<tool>enabled_tools, disabled_toolsincludeTools, excludeTools
Tool timeouttimeout (ms)tool_timeout_sec, default 60timeout (ms), default 600,000

Gemini CLI names tools mcp_<server>_<tool> and splits on the first underscore, so its docs say not to put _ in server names. Codex CLI saves a secret passed with --oauth-client-secret in config.toml; keep that file out of version control.

(source: https://learn.chatgpt.com/docs/extend/mcp, checked 2026-11-14) (source: https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md, checked 2026-11-14)

Using MCP safely

A server is something you trust. The Claude Code docs say to verify you trust each server before connecting, and that servers fetching external content expose you to prompt injection. A stdio server is a program on your machine; read the command before adding or approving it.

Headless runs skip approval. claude -p, Agent SDK sessions and some cloud sessions load .mcp.json servers without asking. If the job checks out code you didn’t write, block servers with disabledMcpjsonServers, drop project settings with --setting-sources, or pass only your own with --strict-mcp-config and --mcp-config.

Keep secrets out of shared files. Use ${VAR} in .mcp.json. Gemini CLI strips variables like *TOKEN* from a server’s environment unless listed in env. More in Keep Secrets Away from Claude Code.

(source: https://code.claude.com/docs/en/mcp, checked 2026-11-14) (source: https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md, checked 2026-11-14)

Reading order

Starting points, not a ranking. New to MCP? Read top to bottom.

  1. MCP Servers 101 and Five Design Rules: a minimal TypeScript server and five design rules.
  2. How to Choose MCP Servers: maintainer, transport, scope, output size and narrowing permissions.
  3. How to Build Your Own MCP Server: the Python SDK, testing over JSON-RPC and registering with full paths.
  4. Claude Code Permissions and settings.json: A Cheat Sheet: rule syntax, including mcp__ rules.
  5. Permission Design for AI Agents: splitting reads from writes.
  6. Keep Secrets Away from Claude Code: which processes, stdio servers included, see your keys.
  7. Claude Code Headless Mode: claude -p for Scripts and Cron: -p and .mcp.json, and what --bare skips.
  8. How to Define Claude Code Subagents: mcpServers for one subagent and MCP entries in tools.
  9. Codex CLI Config: config.toml, Approvals and Sandbox: [mcp_servers.<id>] among Codex settings.
  10. Gemini CLI vs Claude Code: Config File Map: Gemini’s mcpServers next to .mcp.json.

Summary

FAQ

Where does claude mcp add save a server?
At local scope by default: ~/.claude.json under the current project's path, private to you. --scope project writes .mcp.json at the project root, and --scope user saves in ~/.claude.json for all your projects.
Which definition wins when the same server is in more than one scope?
Claude Code connects once, from the highest-precedence source: local, project, user, plugin servers, then claude.ai connectors. The whole entry is used; fields are not merged.
Do .mcp.json servers always ask for approval?
No. An interactive session asks first, but claude -p runs, Agent SDK sessions and some cloud sessions load them without asking. disabledMcpjsonServers blocks a server in every mode.
How large can an MCP tool result be in Claude Code?
Claude Code warns above 10,000 tokens and the default limit is 25,000 tokens, set with MAX_MCP_OUTPUT_TOKENS. A successful text result over 50,000 characters is saved to a file, unless the tool declares anthropic/maxResultSizeChars, which can go up to 500,000.
Where do Codex CLI and Gemini CLI keep MCP servers?
Codex CLI uses [mcp_servers.<name>] in ~/.codex/config.toml, or .codex/config.toml in a trusted project. Gemini CLI uses mcpServers in ~/.gemini/settings.json or .gemini/settings.json.