Codex MCP Sidecar
A local MCP server that lets Claude Code start, resume, and wait for Codex app-server sessions while humans inspect live sessions from a terminal.
README
Codex MCP Sidecar
Codex MCP Sidecar is a local MCP server for letting Claude Code start, resume,
and wait for Codex app-server sessions while a human can inspect those live
sessions from a terminal.
It is designed for a specific collaboration pattern:
- Claude starts Codex through MCP and gets back a small run handle.
- The Codex turn keeps running in the background by default.
- A human opens
codex-runs, selects the active run, and attaches to the same live Codex session. - Claude calls
codex_waituntil the final result is ready.
This project is a local sidecar around the Codex CLI. It is not an official OpenAI product.
Why
When Claude Code calls another agent through a normal MCP tool, the human often sees only one opaque tool-call placeholder. That makes supervision difficult, especially for long running Codex work.
This sidecar keeps the Claude-facing MCP response compact, but stores the full audit trail under the project working directory and exposes a local picker for human inspection.
Features
- Uses Codex
app-serverinstead ofcodex execfor Claude-facing calls. - Defaults
codex_runandcodex_resumeto async mode so live turns remain inspectable. - Provides
codex_waitwith a 240 second soft wait slice by default, helping Claude keep prompt cache warm during long Codex work. - Stores audit artifacts in
<project-root>/.codex/codex-mcp/runs/. - Maintains a small user-level run pointer index in
$CODEX_HOME/mcp-wrapper/runs.index.jsonl. - Lets humans inspect active and completed runs through the
codex-runsCLI. - Keeps MCP tool payloads small and leaves detailed audit data on disk.
- Avoids exposing direct inspect commands, backend details, file paths, command logs, parse errors, or deep links in normal MCP responses.
Requirements
- Node.js 20 or newer.
- npm.
- Codex CLI available as
codex. - A Codex CLI build that supports
codex app-serverandcodex resume --remote. - Claude Code or another MCP client that can run stdio MCP servers.
Installation
Clone the repository and install dependencies:
git clone git@github.com:0Pinky0/codex-mcp-sidecar.git
cd codex-mcp-sidecar
npm ci
Optional local bin setup:
npm link
That exposes:
codex-mcp-sidecar: stdio MCP server entrypoint.codex-mcp-wrapper: compatibility alias for the same server.codex-runs: terminal picker for inspecting Codex runs.
You can also run the server directly with node <repo-path>/server.mjs.
Claude Code Configuration
Register the server with Claude Code. The MCP server name can be codex if you
want Claude to see this sidecar as the main Codex integration:
claude mcp add-json codex '{
"type": "stdio",
"command": "node",
"args": ["<repo-path>/server.mjs"],
"env": {
"CODEX_HOME": "~/.codex",
"CODEX_MCP_WRAPPER_CODEX_HOME": "~/.codex"
}
}' --scope user
Replace <repo-path> with the absolute path to this repository.
After registration, call codex_wrapper_check from Claude. A healthy local
configuration returns ok: true and the detected Codex CLI version.
Exposed MCP Tools
codex_run
Starts a new persisted Codex app-server turn.
Important defaults:
async: truepermissions: "yolo"- app-server mode:
shared - audit directory:
<cwd>/.codex/codex-mcp/runs/
Example:
{
"prompt": "Audit the current diff. Return findings first, then residual risk.",
"run_name": "diff-audit",
"cwd": "<project-root>",
"approval_policy": "never",
"timeout_ms": 1800000
}
Async calls return a compact running handle, typically including runId,
status, threadId, and timeout state.
codex_resume
Resumes a previous Codex session by wrapper run_id.
The caller does not need to know the internal Codex thread id. The sidecar resolves it from the active run metadata, the project run index, the user-level pointer index, or compatible old audit artifacts.
Example:
{
"run_id": "<previous wrapper run id>",
"prompt": "Continue from the previous audit and focus on test coverage.",
"cwd": "<project-root>",
"timeout_ms": 1800000
}
codex_wait
Waits for an async codex_run or codex_resume turn.
By default, codex_wait soft-returns after 240 seconds if Codex is still
working. The Codex turn is not stopped. Claude should call codex_wait again
with the same run_id.
Example:
{
"run_id": "<run id from codex_run or codex_resume>",
"timeout_ms": 1800000,
"soft_timeout_ms": 240000
}
A soft timeout response looks like this:
{
"runId": "<same run id>",
"status": "still_running",
"threadId": "<codex thread id>",
"timedOut": false,
"waitElapsedMs": 240000,
"nextWaitMs": 240000,
"progress": {
"events": 12,
"totalTokens": 120,
"outputTokens": 20,
"reasoningTokens": 5
}
}
Set soft_timeout_ms to 0 only when the caller deliberately wants one long
blocking wait.
codex_active_runs
Lists currently active app-server turns from the audit directory. The response is intentionally compact and does not include inspect commands or artifact paths.
codex_runs
Lists recent wrapper run handles without calling Codex.
Returned items are limited to:
{
"runId": "<wrapper run id>",
"status": "completed",
"title": "Readable title"
}
codex_wrapper_check
Checks the local Codex binary, Codex home, run directory, pointer index, default timeouts, and detected Codex CLI version.
Human Inspection
The MCP tools do not return direct inspect commands. Humans inspect locally with the terminal picker:
cd <project-root>
codex-runs
The picker shows two columns:
Running: active background Codex turns.Completed: recent completed turns.
Use arrow keys to move, PageUp/PageDown to change pages, Enter to attach, and
q, Esc, or Ctrl-C to quit.
When a run is selected, the picker attaches using the underlying Codex command:
codex resume --remote ws://127.0.0.1:45123 <threadId>
After the attached Codex CLI exits, the picker returns to the main list instead of closing.
Other useful modes:
codex-runs --all # Read the user-level pointer index across projects.
codex-runs --json # Print machine-readable session data.
codex-runs --no-watch # Disable automatic refresh.
Audit Artifacts
For each run, the sidecar writes audit files under:
<project-root>/.codex/codex-mcp/runs/
Typical files:
<runId>.jsonl: raw Codex event stream.<runId>.stderr.log: Codex stderr.<runId>.md: human-readable audit summary.index.jsonl: append-only project run index.active/<runId>.json: active run metadata while Codex is still working.
The sidecar also writes a small pointer index under:
$CODEX_HOME/mcp-wrapper/runs.index.jsonl
That pointer index is used to resolve codex_resume(run_id) across projects.
Security Notes
The default permissions profile is yolo, which maps to Codex's built-in
:danger-full-access profile. This is intentional for the local orchestration
workflow, but it is powerful.
Recommended precautions:
- Run the sidecar only on a machine and workspace you trust.
- Do not expose the shared app-server WebSocket to untrusted networks.
- Treat
.codex/codex-mcp/runs/as audit data that may contain prompts, command output, file paths, and model responses. - Review audit artifacts before sharing them.
Pass sandbox explicitly when a narrower Codex sandbox is needed. An explicit
sandbox overrides the default permissions profile.
Environment Variables
The environment variable names still use the historical
CODEX_MCP_WRAPPER_* prefix for compatibility.
CODEX_BIN: Codex binary. Defaults tocodex.CODEX_MCP_WRAPPER_CODEX_HOME: Codex home used by the sidecar. Defaults toCODEX_HOMEor~/.codex.CODEX_MCP_WRAPPER_RUN_DIR: audit directory override. Defaults to<cwd>/.codex/codex-mcp/runs.CODEX_MCP_WRAPPER_POINTER_DIR: user-level pointer index directory. Defaults to$CODEX_HOME/mcp-wrapper.CODEX_MCP_WRAPPER_TIMEOUT_MS: default hard timeout. Defaults to 30 minutes.CODEX_MCP_WRAPPER_WAIT_SOFT_TIMEOUT_MS: default soft wait slice. Defaults to240000. Set to0to disable soft returns.CODEX_MCP_WRAPPER_APP_SERVER_MODE:sharedorprivate. Defaults toshared.CODEX_MCP_WRAPPER_APP_SERVER_URL: shared app-server WebSocket URL. Defaults tows://127.0.0.1:45123.CODEX_MCP_WRAPPER_APP_SERVER_LISTEN: compatibility alias forCODEX_MCP_WRAPPER_APP_SERVER_URL.CODEX_MCP_WRAPPER_DEFAULT_PERMISSIONS: default app-server permissions profile. Defaults toyolo.
Development
Install dependencies:
npm ci
Run tests and syntax checks:
npm run ci
Run the local configuration smoke check:
npm run check-config
npm run check-config depends on a local Codex CLI installation and is not part
of the GitHub Actions workflow.
Repository Hygiene
The repository intentionally ignores local state:
node_modules/.codex/runs/.serena/- editor folders and environment files
Keep audit artifacts out of commits unless a sanitized fixture is deliberately added for a test.
License
UNLICENSED.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。