Codex MCP Reference Docs
Commands, config schema & troubleshooting for OpenAI Codex MCP integration.
Codex MCP Reference Docs
This document serves as the complete reference for integrating the Model Context Protocol (MCP) with the OpenAI Codex CLI. It covers configuration schemas, command-line usage, and common troubleshooting steps.
Configuration Schema (config.toml)
The Codex CLI uses a TOML file for configuration. The MCP settings are nested under the mcpServers table.
Server Definition
Each server is defined as a sub-table of mcpServers (e.g., [mcpServers.my_server]).
| Key | Type | Required | Description |
|---|---|---|---|
command | String | Yes | The executable command to run (e.g., npx, python, uvx). |
args | Array of Strings | No | A list of arguments to pass to the command. |
env | Table | No | A table of key-value pairs representing environment variables to pass to the server process. |
Example Schema
[mcpServers.example]
command = "node"
args = ["/path/to/server.js", "--verbose"]
[mcpServers.example.env]
API_KEY = "your_secret_key"
PORT = "8080"Command Line Interface
The Codex CLI provides several commands for managing and interacting with your MCP servers.
codex mcp list
Lists all configured MCP servers and their current connection status.
Example Output:
SERVER NAME STATUS TOOLS AVAILABLE
filesystem Connected 5
github Failed 0
sqlite Connected 2codex mcp restart <server_name>
Restarts a specific MCP server. This is useful if a server crashes or if you have updated its configuration.
Example:
codex mcp restart filesystemcodex mcp logs <server_name>
Tails the standard error (stderr) output of a specific MCP server, which is essential for debugging server-side issues.
Example:
codex mcp logs githubTroubleshooting
Connection Refused / Server Failed to Start
Symptoms: codex mcp list shows a Failed status for a server.
Solutions:
- ▸Check the executable: Ensure the
command(e.g.,npx,uvx) is installed and available in your system's PATH. - ▸Review the logs: Run
codex mcp logs <server_name>to see why the process crashed. Common reasons include missing dependencies or incorrect arguments. - ▸Verify Node/Python versions: Some servers require specific versions of Node.js (e.g., v18+) or Python (e.g., 3.10+).
Missing Environment Variables
Symptoms: The server connects, but tool executions fail with authentication errors.
Solutions:
- ▸Ensure your API keys are correctly defined in the
[mcpServers.<name>.env]section. - ▸Remember that TOML tables must be defined in order. The
envsub-table must appear after the main server properties.
Tools Not Appearing
Symptoms: The server connects, but Codex says it doesn't have access to the expected tools.
Solutions:
- ▸Verify that the server implementation correctly handles the
tools/listJSON-RPC method. - ▸Try restarting the server using
codex mcp restart <name>to force the Codex CLI to re-fetch the tool list.
Related Guides
How to Build a Custom MCP Server from Scratch
Learn how to create your own MCP server using the TypeScript or Python SDK. Expose custom tools and resources for AI agents to use.
Dev ToolsHow to Use the Puppeteer MCP Server for Web Scraping & Automation
Automate web browsers using the Puppeteer MCP server. Navigate websites, take screenshots, extract data, and automate web interactions through AI.
Dev ToolsHow to Use the Git MCP Server for Version Control Operations
Manage local Git repositories through AI agents. Clone repos, create branches, make commits, and view diffs using the Git MCP server.