GPTMap

Codex CLI MCP Servers: The Full mcp_servers Config Field Guide

Codex CLI wires MCP servers via [mcp_servers] in config.toml: command/args/env for stdio, url/bearer_token/http_headers for remote, plus timeouts, tool filters and OAuth.

TL;DR
Codex CLI declares MCP servers under [mcp_servers.<name>] in ~/.codex/config.toml. Stdio servers use command/args/env/env_vars/cwd; remote servers use url/bearer_token (or bearer_token_env_var)/http_headers. Shared controls include startup_timeout_sec, tool_timeout_sec, enabled, required, enabled_tools/disabled_tools, scopes and an oauth block; the auth enum is oauth/chatgpt/ema_auth.
Codex CLI's MCP integration declares local (stdio) or remote (HTTP) MCP servers in the [mcp_servers] table of config.toml, letting the coding agent call external tools and data sources directly.

Codex CLI declares MCP servers in the [mcp_servers] table of ~/.codex/config.toml — each sub-table is a named server, and both stdio (local process) and remote (HTTP) shapes share one field set. This guide walks the fields as defined by RawMcpServerConfig in the codex-rs source, not from memory.

1. Stdio: local processes

[mcp_servers.wave]
command = "python"
args = ["-m", "wave_mcp.server", "--session", "/abs/path/to/session"]
env = { "API_KEY" = "..." }
cwd = "/path/to/workdir"

Five stdio fields:

  • command — the process to launch
  • args — argument array
  • env — literal key/value pairs injected into the process environment
  • env_vars — a list of host environment variable names to pull values from (keeps secrets out of the file)
  • cwd — working directory for the server process

The difference between env and env_vars is whether a secret lands on disk — prefer env_vars for tokens.

2. Remote: HTTP servers

[mcp_servers.linear]
url = "https://mcp.linear.app/mcp"
bearer_token_env_var = "LINEAR_TOKEN"

Remote fields:

  • url — the server endpoint
  • bearer_token / bearer_token_env_var — a literal token or one read from the environment
  • http_headers / env_http_headers — custom request headers (the latter resolving values from env vars)
  • http_headers_helper — a helper-command form that produces header values

3. Shared controls

Fields applying to both shapes:

FieldPurpose
startup_timeout_sec / startup_timeout_msserver startup timeout
tool_timeout_secper-tool-call timeout
enabledmaster switch (false disables)
requiredmandatory marker — session fails rather than degrades if unavailable
enabled_tools / disabled_toolstool whitelist / blacklist
supports_parallel_tool_callswhether this server's tools may run in parallel
omit_tools_fromwhich exposure surfaces show the tools
scopesOAuth scopes

required = true deserves a second look: it does not mean "try harder" — it means "fail the session if this server is missing". Right for hard dependencies, wrong for nice-to-haves.

4. OAuth and auth

The auth field's enum is oauth / chatgpt / ema_auth. Servers needing a full OAuth flow use the [mcp_servers.<name>.oauth] block with client_id, callback_url, callback_port and authorization_server_issuer.

5. Common errors and debugging

  • Server fails to start: check whether command resolves — npx/uvx may not be on PATH when Codex launches from a GUI context; then raise startup_timeout_sec
  • Tools not visible: check disabled_tools and the requirements layer — Codex has plugin/requirements-level MCP filtering, and admin-side required constraints can work in reverse
  • Secrets in the repo: bearer_token and env are plaintext; project-level .codex/config.toml is committed to git — always use the *_env_var forms for secrets

6. Next steps

Key points

  • Stdio fields: command, args, env, env_vars, cwd
  • Remote fields: url, bearer_token / bearer_token_env_var, http_headers / env_http_headers
  • Timeouts: startup_timeout_sec (or startup_timeout_ms), tool_timeout_sec
  • Tool surface: enabled_tools / disabled_tools; required fails the session if the server is unavailable
  • auth enum: oauth / chatgpt / ema_auth; the oauth block takes client_id, callback_url, callback_port

Frequently asked questions

Add a [mcp_servers.my-server] table in ~/.codex/config.toml with command, args and env — the process command line for the server. The `codex mcp add <name> -- <command>` CLI writes into the same config.

Official references

Related articles

Subscribe to GPTMap Weekly

One email every Monday: curated OpenAI updates, deep dives, and best practices. No ads, unsubscribe anytime.

Submitting opens Buttondown in a new tab to confirm your subscription.

GPTMap EditorialPublished 2026-09-23 3 min read
Test environment (EEAT)
Last tested: 2026-09-23
Model used: gpt-6-astra