get/mcp/indexSearch ⌘K

How to add an MCP server to Codex

To add an MCP server to Codex, for a local package run codex mcp add <name> --env VAR=value -- <command>.

Steps

  1. For a local package run codex mcp add <name> --env VAR=value -- <command>.
  2. Or add an [mcp_servers.<name>] table to ~/.codex/config.toml with command, args and env.
  3. For a hosted server set url; send secret headers with env_http_headers or bearer_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/mcp
Codex (~/.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.