Codex CLI MCP Setup: Connect MCP Servers to Codex CLI
What it is
OpenAI's open-source coding agent for the terminal, which can read, modify, and run code in your project.
How MCP works in Codex CLI
Codex CLI is an MCP client. You register servers as TOML tables and it launches them over stdio, or connects to remote Streamable HTTP servers; run /mcp in the TUI to list active servers.
Codex uses TOML, not JSON — each server is its own [mcp_servers.<name>] table. You can also run codex mcp to manage servers.
Config file location
~/.codex/config.toml (or a trusted project .codex/config.toml) adds each server as a [mcp_servers.<name>] TOML table.
Add your first server
A good first server is Playwright MCP — Microsoft's browser automation server. It runs locally over stdio via npx, needs no API key, and gives the agent a real browser to drive. Here is the verified Codex CLI config:
[mcp_servers.playwright] command = "npx" args = ["@playwright/mcp@latest"]
Restart or reload Codex CLI after saving, then confirm the server's tools show up. Swap in any other server from the directory using the same structure.
Transports & platforms
| Transports | stdio, Streamable HTTP |
|---|---|
| Platforms | macOS, Linux, Windows |
| License | Open source |
| Vendor | OpenAI |
FAQ
Does Codex CLI support MCP?
Yes. Codex CLI works as an MCP client over stdio, Streamable HTTP. Codex CLI is an MCP client. You register servers as TOML tables and it launches them over stdio, or connects to remote Streamable HTTP servers; run /mcp in the TUI to list active servers.
Where is the Codex CLI MCP config?
~/.codex/config.toml (or a trusted project .codex/config.toml) adds each server as a [mcp_servers.<name>] TOML table. The verified example above shows the exact structure it expects.
Which MCP servers work with Codex CLI?
Any server that speaks a transport Codex CLI supports (stdio, Streamable HTTP). Browse the MCP server directory on this site to find databases, browser automation, API integrations, and dev tools, then add them using the config format above.