Skip to content

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 against OpenAI’s docs

Quick facts

Local servers
Yes (stdio)
Remote servers
Streamable HTTP: YesURL field: url
Sign-in
OAuth: Yes · Headers: YesRun 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

Step by step

Add a remote server

Example: a hosted server whose latest check on AI-Powered answered, Context7.

Add with the CLI

Run in a terminal

codex mcp add context7 --url https://mcp.context7.com/mcp

Or add to config.toml

Add to ~/.codex/config.toml

[mcp_servers.context7]
url = "https://mcp.context7.com/mcp"

Add a local server

Example: a popular npm package that needs no keys, Chrome DevTools MCP.

Add with the CLI

Run in a terminal

codex mcp add chrome-devtools-mcp -- npx -y chrome-devtools-mcp

Or add to config.toml

Add to ~/.codex/config.toml

[mcp_servers.chrome-devtools-mcp]
command = "npx"
args = ["-y", "chrome-devtools-mcp"]

Add a server that needs an API key or header

Local servers read keys from environment variables. Replace each <NAME> placeholder with your own value in the file on your computer; never paste real keys into a website.

Example: Context7.

Add with the CLI

Run in a terminal

codex mcp add context7 --env CONTEXT7_API_KEY='<CONTEXT7_API_KEY>' -- npx -y @upstash/context7-mcp

Or add to config.toml

Add to ~/.codex/config.toml

[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
env = { CONTEXT7_API_KEY = "<CONTEXT7_API_KEY>" }

Request headers for remote servers: yes. Run codex mcp login <name> for OAuth. Tokens can come from an environment variable (bearer_token_env_var) or http_headers.

Add a server that signs in with OAuth

OAuth sign-in: yes. Add the server by its URL as a remote server, then sign in when asked. Run codex mcp login <name> for OAuth. Tokens can come from an environment variable (bearer_token_env_var) or http_headers.

Config file locations

ForSystemPath
You (every project)All systems~/.codex/config.toml
One projectAll systems.codex/config.toml

Get the config for any server

Search the MCP servers on AI-Powered and copy the Codex snippet for one.

Adding several servers? Build one config with the MCP config generator.

Servers that work in Codex

Popular servers with an install config for Codex and no failing latest check.
  1. REA

    MCP server

    CLI and MCP server that lets coding agents reverse engineer apps and binaries

    Runs locally
    • Open source
    • 476K GitHub stars
    • Developer tools
  2. Browser Use

    MCP server

    Browser agents and cloud browsers for AI, with an MCP server for web tasks

    • 7 tools
    • Remote
    • Freemium
    • 122K GitHub stars
    • Browser automation
  3. MCP server for AI clients to scrape sites with HTTP and stealth browser sessions

    Runs locally
    • 17 tools
    • Open source
    • 105K GitHub stars
    • Web search and scraping
  4. Hosted MCP connector for creating and rendering videos from HTML through AI chat

    • Remote
    • Freemium
    • 89K GitHub stars
    • Design and media
  5. Context7

    MCP server

    Version-specific library docs and code examples piped into coding agents via MCP

    • 2 tools
    • Remote
    • Freemium
    • 65.4K GitHub stars
    • Developer tools
  6. MCP server and CLI that let coding agents drive and inspect a live Chrome browser

    Runs locally
    • Open source
    • 59.1K GitHub stars
    • Browser automation
  7. Codebase Memory

    MCP server

    Local MCP server that builds a code knowledge graph for AI coding agents

    Runs locally
    • Open source
    • 49.1K GitHub stars
    • Knowledge and memory
  8. GitHub

    MCP server

    Official MCP server connecting AI assistants to GitHub repos, issues and workflows

    • Remote
    • Open source
    • 34.7K GitHub stars
    • Developer tools
  9. MCP toolkit giving coding agents symbol-level code retrieval and editing

    Runs locally
    • Open source
    • 31.7K GitHub stars
    • Developer tools
  10. ffmpeg-skill

    MCP server

    Local FFmpeg video and audio editing tools for coding agents over MCP

    Runs locally
    • Open source
    • 10.3K GitHub stars
    • Design and media
  11. Ha MCP

    MCP server

    MCP server for managing and automating Home Assistant from AI assistants

    Runs locally
    • 8 tools
    • Open source
    • 8.1K GitHub stars
    • Productivity
  12. Open-source analytics app where an AI agent builds charts and dashboards from your data

    • Remote
    • Open source
    • 7.8K GitHub stars
    • Analytics and 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.

Where to find logs

  • Run /mcp in the Codex TUI or the desktop app composer to see configured servers.

Safety notes

  • 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 about MCP in Codex

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.

Other MCP clients