Add a server from the CLI
codex mcp add <server-name> --env VAR1=VALUE1 -- <stdio server command>
For example, OpenAI’s docs use Context7, a documentation server:
codex mcp add context7 -- npx -y @upstash/context7-mcp
Then use codex mcp list to see configured servers, codex mcp login <name> for OAuth servers, and /mcp inside the TUI.
Add a server in the desktop app or IDE extension
- Open Settings, or the gear menu in the extension, then MCP servers.
- Select Add server, choose STDIO or Streamable HTTP, and enter the command or URL.
- Save, then Restart the app or extension.
Configure in config.toml
STDIO server:
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
HTTP server with a bearer token taken from an environment variable:
[mcp_servers.figma]
url = "https://mcp.figma.com/mcp"
bearer_token_env_var = "FIGMA_OAUTH_TOKEN"
Useful per-server options include enabled, required, startup_timeout_sec (default 10), tool_timeout_sec (default 60), enabled_tools and disabled_tools, and default_tools_approval_mode, which takes auto, prompt, writes, or approve.
Be selective
Every MCP server adds tools that Codex can call. Connect servers you trust, limit them to the tools you need with enabled_tools, and set default_tools_approval_mode = "prompt" for anything that can write or send data. Keep secrets in environment variables, not in a config.toml you might commit.