To add an MCP server to Codex, for a local package run codex mcp add <name> --env VAR=value -- <command>.
Steps
- For a local package run
codex mcp add <name> --env VAR=value -- <command>. - Or add an
[mcp_servers.<name>]table to~/.codex/config.tomlwithcommand,argsandenv. - For a hosted server set
url; send secret headers withenv_http_headersorbearer_token_env_var.
Checked against Codex's official MCP documentation on 2026-12-01.
Copy-paste examples
Example: Playwright MCP (local package)
Codex CLI
codex mcp add playwright-mcp -- npx -y @playwright/mcpCodex (~/.codex/config.toml)
[mcp_servers.playwright-mcp]
command = "npx"
args = ["-y", "@playwright/mcp"]From the Playwright MCP server page.
Example: GitHub (hosted (remote) server)
Codex (~/.codex/config.toml)
[mcp_servers.github-mcp-server]
url = "https://api.githubcopilot.com/mcp/"From the GitHub server page.
Find a server
Every server page on getmcpindex has a ready-made setup for Codex under Set up in your MCP client. Search all servers, browse categories or remote servers.