How to Setup MCP in OpenAI Codex CLI

CLI Agent

Step-by-step setup guide for connecting Model Context Protocol (MCP) servers to OpenAI Codex CLI by OpenAI / Community.

Configuration File: config.toml

%USERPROFILE%\.codex\config.toml

Example config.toml Template

Open in Config Generator
[mcp_servers.github]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-github"]
[mcp_servers.github.env]
GITHUB_PERSONAL_ACCESS_TOKEN = "ghp_..."

Installation Steps

1

Locate config.toml

Find the configuration file at %USERPROFILE%\.codex\config.toml.

2

Add MCP server entries

Open the file and add your server definitions inside the configuration schema.

3

Set environment variables

Provide any required API keys, database URLs, or access tokens in the environment section.

4

Save and reload

Save config.toml and hot-reload or restart OpenAI Codex CLI.

5

Verify in chat

Ask OpenAI Codex CLI to list tools or execute a task with the connected MCP server.

OpenAI Codex CLI Protocol Support

Stdio Transport Supported

Local subprocess transports

SSE / HTTP Transport Supported

Remote HTTP SSE streams

Tool Calling Supported

Full autonomous tool calling

Resources API Supported

Direct schema reads

Prompts API Unsupported

CLI arguments

Roots Boundary Supported

Current working directory

Dynamic Hot-Reload Supported

codex mcp restart <server>