# How to add MCP servers to Codex

Codex reads MCP servers from ~/.codex/config.toml (for you) or .codex/config.toml (for one project), one [mcp_servers.<name>] table per server. A local server’s entry is a command with args; a remote server’s entry is its URL in "url". You can also add a server with one terminal command, codex mcp add.

Last checked 25 Nov 2026. Page: https://ai-powered.com/clients/codex

## Quick facts

- Local servers: Yes (stdio)
- Remote servers: Streamable HTTP: Yes (URL field: url)
- Sign-in: OAuth: Yes · Headers: Yes (Run codex mcp login <name> for OAuth. Tokens can come from an environment variable (bearer_token_env_var) or http_headers.)
- Tool approval: Yes
- Platforms: macOS, Windows and Linux

## Codex config files

| Scope | System | Path |
| --- | --- | --- |
| For you | All systems | `~/.codex/config.toml` |
| For one project | All systems | `.codex/config.toml` |

## Servers that work in Codex

- [REA](https://ai-powered.com/mcp/rea): CLI and MCP server that lets coding agents reverse engineer apps and binaries
- [Browser Use](https://ai-powered.com/mcp/browser-use): Browser agents and cloud browsers for AI, with an MCP server for web tasks
- [Scrapling MCP Server](https://ai-powered.com/mcp/scrapling-mcp-server): MCP server for AI clients to scrape sites with HTTP and stealth browser sessions
- [HyperFrames by HeyGen](https://ai-powered.com/mcp/hyperframes-by-heygen): Hosted MCP connector for creating and rendering videos from HTML through AI chat
- [Context7](https://ai-powered.com/mcp/context7): Version-specific library docs and code examples piped into coding agents via MCP
- [Chrome DevTools MCP](https://ai-powered.com/mcp/chrome-devtools-mcp-2): MCP server and CLI that let coding agents drive and inspect a live Chrome browser
- [Codebase Memory](https://ai-powered.com/mcp/codebase-memory): Local MCP server that builds a code knowledge graph for AI coding agents
- [GitHub](https://ai-powered.com/mcp/github): Official MCP server connecting AI assistants to GitHub repos, issues and workflows
- [Serena MCP: the IDE for your agent](https://ai-powered.com/mcp/serena-mcp-the-ide-for-your-agent): MCP toolkit giving coding agents symbol-level code retrieval and editing
- [ffmpeg-skill](https://ai-powered.com/mcp/ffmpeg-skill): Local FFmpeg video and audio editing tools for coding agents over MCP
- [Ha MCP](https://ai-powered.com/mcp/ha-mcp): MCP server for managing and automating Home Assistant from AI assistants
- [Agent-Native Analytics](https://ai-powered.com/mcp/agent-native-analytics): Open-source analytics app where an AI agent builds charts and dashboards from your data

## Troubleshooting

- Pasting a JSON mcpServers block doesn’t work: Codex uses TOML. Each server is its own [mcp_servers.<name>] table in config.toml.
- A server times out on first start: The startup timeout is 10 seconds by default, which a first npx download can exceed. Raise startup_timeout_sec for that server.
- A project’s .codex/config.toml is ignored: Project config only loads in trusted projects. Trust the project, or add the server to ~/.codex/config.toml.
- Sign-in can’t open a browser (SSH or a container): Run codex mcp login <name> --no-browser and open the printed URL yourself.
- A local server fails with “npx” (or uvx, docker) not found: Apps started from a dock or menu may not see your terminal’s PATH. Use the full path of the command (run which npx in a terminal to find it), then restart Codex.
- You can’t tell whether the server or Codex is at fault: Test the server on its own with the MCP Inspector (npx @modelcontextprotocol/inspector). If it lists tools there, check the Codex setup.

## Safety

- Set default_tools_approval_mode (or approval_mode per tool) so Codex asks before tools that change things.
- Limit a server to the tools you need with enabled_tools or disabled_tools.
- Point bearer_token_env_var at an environment variable instead of writing tokens into config.toml.
- A local server runs on your computer with your access to files and the network. Add only servers whose source you trust.

## Questions

### Where does Codex keep MCP servers?
In ~/.codex/config.toml, or .codex/config.toml in a trusted project. The Codex CLI, the IDE extension and the ChatGPT desktop app share this file.

### How do I add an MCP server to Codex from the terminal?
For a local server: codex mcp add <name> --env KEY=value -- <command>. For a remote one: codex mcp add <name> --url <url>. List servers with codex mcp list.

### Does Codex support remote MCP servers?
Yes, over Streamable HTTP, with OAuth (including client ID metadata documents and dynamic registration) or a bearer token.

### Can I add servers without editing TOML?
Yes. In the desktop app open Settings → MCP servers; in the IDE extension open the gear menu → MCP servers, then Add server.

### Can I use local MCP servers in Codex?
Yes. Codex starts a local server as a command on your computer (stdio).

### Can Codex sign in to MCP servers with OAuth?
Yes. Run codex mcp login <name> for OAuth. Tokens can come from an environment variable (bearer_token_env_var) or http_headers.

## Sources

- [Codex docs: MCP (CLI)](https://learn.chatgpt.com/docs/extend/mcp?surface=cli)
- [Codex docs: MCP (IDE extension)](https://learn.chatgpt.com/docs/extend/mcp?surface=ide)