OpenAI · Codex CLI · IDE extension · ChatGPT desktop app
How to add MCP servers to OpenAI Codex
Where OpenAI Codex keeps MCP config (~/.codex/config.toml (user), .codex/config.toml (project, trusted projects only)), the exact format, and working examples for local and remote servers.
1. Find the config file
~/.codex/config.toml (user).codex/config.toml (project, trusted projects only)
One [mcp_servers.<name>] table per server. The CLI, IDE extension and ChatGPT desktop app share this config.
2. Add a local (stdio) server
Example: Context7, which runs locally with npx.
terminalcodex mcp add context7 -- npx -y @upstash/context7-mcp
~/.codex/config.toml[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
3. Add a remote (HTTP) server
Example: Notion's hosted server. You sign in with OAuth the first time it connects.
terminalcodex mcp add notion --url https://mcp.notion.com/mcp
~/.codex/config.toml[mcp_servers.notion]
url = "https://mcp.notion.com/mcp"
4. If it won't connect
- Validate the file. One trailing comma breaks the whole file.
- Check the top-level key: VS Code uses
servers; Claude Code, Cursor and Antigravity usemcpServers; Codex uses TOML tables. - If
npxisn't found, the app may not see your shell's PATH (common with nvm). Use the full path tonpx. - Restart the agent or reload the window after editing.
Agent Stack Weekly · free
What changed across coding agents this week
Limit and pricing changes, new MCP servers, and setup fixes for Claude Code, Codex, Cursor, Copilot and Antigravity.
No spam. Unsubscribe anytime. Read past issues
Frequently asked questions
~/.codex/config.toml (user) or .codex/config.toml (project, trusted projects only).