---
title: "OpenAI Codex CLI MCP config: file path, key, example · DotsAgent"
description: "Add MCP servers to OpenAI Codex CLI from OpenAI: where the config file lives, the top-level key and format, remote OAuth support and a sample config."
url: https://dotsagent.io/mcp/clients/codex-cli
---

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**: 

## 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 →](https://dotsagent.io/mcp/config#client=codex-cli)

## Other clients

[Claude Desktop](https://dotsagent.io/mcp/clients/claude-desktop)

[Claude Code](https://dotsagent.io/mcp/clients/claude-code)

[Cursor](https://dotsagent.io/mcp/clients/cursor)

[VS Code (GitHub Copilot)](https://dotsagent.io/mcp/clients/vscode-copilot)

[Windsurf / Devin Desktop](https://dotsagent.io/mcp/clients/windsurf)

[Zed](https://dotsagent.io/mcp/clients/zed)

[Gemini CLI](https://dotsagent.io/mcp/clients/gemini-cli)

[ChatGPT](https://dotsagent.io/mcp/clients/chatgpt)

[OpenClaw](https://dotsagent.io/mcp/clients/openclaw)

[Cline](https://dotsagent.io/mcp/clients/cline)

[Continue](https://dotsagent.io/mcp/clients/continue)

[JetBrains AI Assistant](https://dotsagent.io/mcp/clients/jetbrains-ai)

## Sources

1. [developers.openai.com](https://developers.openai.com/codex/mcp)/codex/mcp

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

© 2026 DotsAgent · Facts checked October 1, 2026
