dotsagent.io
Language:English
OpenAI

Add MCP servers to OpenAI Codex CLI

Codex keeps servers in config.toml, one [mcp_servers.<name>] table each, and can add them with codex mcp add.

macOS
~/.codex/config.toml
Windows
~/.codex/config.toml
Linux
~/.codex/config.toml
Project file
.codex/config.toml (trusted projects only)
Top-level key
mcp_servers
Format
toml
OAuth for remote servers
Yes

Example config

This example adds GitHub's hosted server and Playwright as a local server, in the shape this client expects.

.codex/config.toml
[mcp_servers.github]
url = "https://api.githubcopilot.com/mcp/"

[mcp_servers.playwright]
command = "npx"
args = ["@playwright/mcp@latest"]
shell
codex mcp add github --url https://api.githubcopilot.com/mcp/
codex mcp add playwright -- npx @playwright/mcp@latest

Notes and quirks

  • The same config.toml is read by Codex CLI, the Codex IDE extension and the ChatGPT desktop app.
  • A project .codex/config.toml is read only in trusted projects.
  • env_vars forwards variables from your shell by name; bearer_token_env_var sends a token from a variable to a remote server.
  • Per-server options include startup_timeout_sec, tool_timeout_sec, enabled_tools and disabled_tools.
  • codex mcp login <name> runs OAuth, with both CIMD and dynamic registration supported.

Build a OpenAI Codex CLI config →

Other clients

Sources

  1. developers.openai.com/codex/mcp

Independent reference for people who build AI agents. Not affiliated with any vendor named here.

© 2026 DotsAgent · Facts checked October 1, 2026