> mcp & extensions
MCP (Model Context Protocol) lets Codex talk to external tools — docs servers, design tools, databases — and Codex can also act as an MCP server other agents call. This section covers adding local and remote MCP servers, managing them, and exposing Codex itself. Servers are recorded in config.toml under [mcp_servers.NAME]; the codex mcp subcommands just edit that for you.
// mcp & extensions
4 commands// faq
How do I add an MCP server to Codex?
For a local (stdio) server: codex mcp add NAME -- <command>, e.g. codex mcp add context7 -- npx -y @upstash/context7-mcp. Pass server environment variables with --env VAR=value before the --. This writes a [mcp_servers.NAME] block to ~/.codex/config.toml.
How do I connect a remote HTTP MCP server?
Add a [mcp_servers.NAME] table to config.toml with url = "https://…/mcp", and for auth bearer_token_env_var = "MY_TOKEN" so the secret stays in an env var, not the file. For OAuth servers, run codex mcp login NAME. Inspect the result with codex mcp get NAME.
How do I see or remove configured servers?
codex mcp list shows all servers and their status, codex mcp get NAME prints one server's resolved config, and codex mcp remove NAME deletes it. Inside the TUI, /mcp lists the tools each connected server exposes.
Can other tools use Codex as an MCP server?
Yes. codex mcp-server runs Codex itself as a stdio MCP server so an IDE or another agent can call it as a tool. That is the inverse of codex mcp add (which makes Codex the client). It is currently experimental.