codex-cli-mcp
Bridges OpenAI Codex CLI to any MCP client, allowing headless Codex sessions via tools like codex and codex-reply.
README
<div align="center">
<picture> <img alt="codex-cli-mcp" src="docs/images/banner.svg" width="100%"> </picture>
Bridge OpenAI Codex CLI to any MCP client
English | 한국어
<a href="https://www.npmjs.com/package/@nayagamez/codex-cli-mcp">npm</a> · <a href="https://github.com/nayagamez/codex-cli-mcp">GitHub</a> · <a href="https://github.com/nayagamez/codex-cli-mcp/issues">Issues</a>
</div>
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.
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 codex
Or 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 |
|---|---|---|---|
prompt |
string | Yes | The prompt to send to Codex |
model |
string | No | Model name override |
effort |
enum | No | Reasoning effort: medium, high, xhigh (auto-selected by task complexity) |
sandbox |
enum | No | read-only, workspace-write, or danger-full-access |
cwd |
string | No | Working directory for the session |
profile |
string | No | Configuration profile from config.toml |
config |
object | No | Config overrides as key-value pairs |
timeout |
number | No | Timeout in ms (default: 600000 = 10 min) |
codex-reply
Continue an existing Codex CLI session.
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt |
string | Yes | The follow-up prompt |
threadId |
string | Yes | Thread ID from a previous codex call |
model |
string | No | Model name override |
effort |
enum | No | Reasoning effort: medium, high, xhigh (auto-selected by task complexity) |
config |
object | No | Config overrides as key-value pairs |
timeout |
number | No | Timeout in ms (default: 600000 = 10 min) |
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.md
Or 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.md
Manual Setup
<details> <summary>Claude Desktop</summary>
Add to your claude_desktop_config.json:
{
"mcpServers": {
"codex-cli-mcp": {
"command": "npx",
"args": ["-y", "@nayagamez/codex-cli-mcp"]
}
}
}
</details>
<details> <summary>Cursor / Windsurf</summary>
Add to your MCP settings:
{
"mcpServers": {
"codex-cli-mcp": {
"command": "npx",
"args": ["-y", "@nayagamez/codex-cli-mcp"]
}
}
}
</details>
<details> <summary>Claude Code</summary>
claude mcp add codex-cli-mcp -- npx -y @nayagamez/codex-cli-mcp
</details>
Progress 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 |
|---|---|---|
CODEX_CLI_PATH |
codex |
Path to the Codex CLI binary |
CODEX_TIMEOUT_MS |
600000 (10 min) |
Idle timeout for Codex process |
CODEX_MCP_DEBUG |
(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 done
- The MCP client sends a tool call (
codexorcodex-reply) - The server spawns Codex CLI with
--jsonand--full-autoflags - The 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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。