How to Setup MCP in OpenAI Codex CLI
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
Locate config.toml
Find the configuration file at %USERPROFILE%\.codex\config.toml.
Add MCP server entries
Open the file and add your server definitions inside the configuration schema.
Set environment variables
Provide any required API keys, database URLs, or access tokens in the environment section.
Save and reload
Save config.toml and hot-reload or restart OpenAI Codex CLI.
Verify in chat
Ask OpenAI Codex CLI to list tools or execute a task with the connected MCP server.
OpenAI Codex CLI Protocol Support
Local subprocess transports
Remote HTTP SSE streams
Full autonomous tool calling
Direct schema reads
CLI arguments
Current working directory
codex mcp restart <server>
OpenAI Codex CLI Setup FAQ
Where is the OpenAI Codex CLI MCP config file located?
On Windows: %USERPROFILE%\.codex\config.toml. On macOS: ~/.codex/config.toml. On Linux: ~/.codex/config.toml.
Does OpenAI Codex CLI support MCP tools and stdio transports?
OpenAI Codex CLI supports stdio transports and supports autonomous tool calling.
How do I reload MCP servers in OpenAI Codex CLI?
codex mcp restart <server>