codex-cli-mcp
Allows MCP clients to run OpenAI Codex CLI sessions in headless mode, enabling code generation and execution via prompts.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@codex-cli-mcpRefactor the authentication module to use JWT"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Bridge OpenAI Codex CLI to any MCP client
English | 한국어
npm · GitHub · Issues
Overview
An MCP (Model Context Protocol) server that wraps OpenAI Codex CLI as tools. It enables MCP clients like Claude Desktop, Cursor, and Windsurf to run Codex CLI sessions in headless mode.
Related MCP server: mcacp
Prerequisites
1. Install Codex CLI
Install Codex CLI (docs) and make sure it is available in your PATH:
# npm
npm install -g @openai/codex
# Homebrew (macOS)
brew install --cask codexOr download the binary from GitHub Releases.
2. Authenticate
Option A — ChatGPT Login (Recommended)
Run codex and select "Sign in with ChatGPT". Requires a Plus, Pro, Team, Edu, or Enterprise plan.
Option B — API Key
For headless / CI environments:
export OPENAI_API_KEY="your-api-key"See the Codex Authentication docs for more details.
Tools
See Codex Models for available models.
codex
Start a new Codex CLI session.
Parameter | Type | Required | Description |
| string | Yes | The prompt to send to Codex |
| string | No | Model name override |
| enum | No | Reasoning effort: |
| enum | No |
|
| string | No | Working directory for the session |
| string | No | Configuration profile from config.toml |
| object | No | Config overrides as key-value pairs |
| number | No | Timeout in ms (default: |
codex-reply
Continue an existing Codex CLI session.
Parameter | Type | Required | Description |
| string | Yes | The follow-up prompt |
| string | Yes | Thread ID from a previous |
| string | No | Model name override |
| enum | No | Reasoning effort: |
| object | No | Config overrides as key-value pairs |
| number | No | Timeout in ms (default: |
Setup
For Humans
Copy the prompt below and paste it into your LLM agent — it will install and configure everything automatically:
Install and configure @nayagamez/codex-cli-mcp by following: https://raw.githubusercontent.com/nayagamez/codex-cli-mcp/main/docs/guide/installation.mdOr set it up manually — see Manual Setup below.
For LLM Agents
curl -s https://raw.githubusercontent.com/nayagamez/codex-cli-mcp/main/docs/guide/installation.mdManual Setup
Add to your claude_desktop_config.json:
{
"mcpServers": {
"codex-cli-mcp": {
"command": "npx",
"args": ["-y", "@nayagamez/codex-cli-mcp"]
}
}
}Add to your MCP settings:
{
"mcpServers": {
"codex-cli-mcp": {
"command": "npx",
"args": ["-y", "@nayagamez/codex-cli-mcp"]
}
}
}claude mcp add codex-cli-mcp -- npx -y @nayagamez/codex-cli-mcpProgress Notifications
The server sends MCP progress notifications in real-time as Codex processes your request. This lets MCP clients know the server is alive and working, not hanging.
Progress messages include:
[5s] Session started (thread: ...)— session initialized[12s] Command executed: npm test— a command was run[18s] Message: Refactoring the auth module...— agent reasoning[25s] Turn completed— turn finished
Idle-based Timeout
The timeout is idle-based, not absolute. The timer resets every time the server receives an event from Codex. This means long-running tasks with continuous activity will never timeout, while truly stuck processes will be killed after the configured idle period.
Default idle timeout: 10 minutes
Override per-call via
timeoutparameter, or globally viaCODEX_TIMEOUT_MS
Environment Variables
Variable | Default | Description |
|
| Path to the Codex CLI binary |
|
| Idle timeout for Codex process |
| (unset) | Set to enable debug logging to stderr |
How It Works
MCP Client → Tool Call (codex / codex-reply)
→ Spawn `codex exec --json --full-auto` as subprocess
→ Stream JSONL events from stdout
→ Send progress notifications back to client
→ Return formatted results when doneThe MCP client sends a tool call (
codexorcodex-reply)The server spawns Codex CLI with
--jsonand--full-autoflagsThe prompt is passed via stdin
JSONL events are streamed and parsed in real-time
Progress notifications are sent to the client on each event (idle timer resets)
Results (messages, commands, errors, token usage) are formatted as markdown and returned
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/nayagamez/codex-cli-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server