codex-manager-mcp
Provides management of local OpenAI Codex CLI sessions, enabling starting, monitoring, messaging, stopping, hooking, and adopting Codex tasks.
Click on "Deploy 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-manager-mcp start a codex task to fix the failing test"
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.
Codex Manager MCP
Disclaimer: This project is not affiliated with or endorsed by OpenAI. "OpenAI Codex" is a trademark of OpenAI. This tool merely wraps and manages the locally-installed Codex CLI using the user's own login; it does not bypass authentication, scrape, or redistribute any OpenAI proprietary content.
一个在 Claude Code 里管理本机 codex CLI 会话的 MCP 服务器。它直接 spawn codex exec 子进程并统一管理:启动、状态、消息、中途注入、停止、消息 hook、崩溃自动重启、外部会话采纳。
核心理念: 每个 codex 任务就是一个由本 manager 启动的 codex exec 进程。codex_run 是阻塞式工具调用,Claude Code 客户端会自动后台化超时的调用——因此每个运行中的 codex 任务自动成为 Claude Code 的原生后台任务,计入底部 "N background tasks",完成时任务通知唤醒 agent。UI 展示零成本。
安装
npm install # 安装依赖
npm run build # 编译到 dist/配置到 Claude Code(.mcp.json 或 ~/.claude/settings.json):
{
"mcpServers": {
"codex-manager": {
"command": "node",
"args": ["~/codex-manager/dist/src/index.js"]
}
}
}建议(唤醒/后台化): 启动 Claude Code 时设 CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS=1000,让 codex_run 约 1 秒后自动转入后台,完成时以任务通知唤醒 agent(无需等默认的 2 分钟)。
Related MCP server: Claude Code MCP
工具
工具 | 说明 |
| 启动 codex 任务(镜像 |
| 查询任务状态。 |
| 查询某任务消息。 |
| 向运行中任务注入消息( |
| 停止/杀死任务。 |
| 消息 hook 增/删/列。 |
| 扫描外部 codex 会话(只读,不含已采纳的)。 |
| 把外部会话纳入本 manager 管理(纳入后可 send/messages/stop/hook)。 |
消息分级
codex_messages 的 level 取值:user / commentary(agent 实时评论)/ final(回合最终输出)/ reasoning / tool(工具调用)/ result(工具结果)/ event(会话事件)/ token(用量)。
Hook 示例
codex_hook add {pattern:"ERROR", match:"contains", level:"commentary"}
codex_hook add {pattern:"\\d{3} tokens", match:"regex", id:3} # 仅任务3
codex_hook list
codex_hook remove {hookId:"..."}命中后 hook 的 hitCount 递增。若命中消息属于阻塞中的 codex_run,完成通知会一并携带。
外部会话
codex_discover列出近期外部会话(只读)。codex_adopt {sessionId}纳入管理 → 出现在codex_list,可 send/messages/hook。未采纳的会话不能执行任何操作。
自动重启(失败重连)
启动失败或非正常退出(exit≠0)→ 1 分钟后自动重启,最多
maxAttempts(默认 3)次。第 3 次仍失败 → 任务状态
failed+ 通知。单任务可覆盖:
codex_run {..., maxAttempts:5}。
环境变量
变量 | 作用 | 默认 |
| 状态文件路径 |
|
| 显式指定 codex 可执行文件(否则自动解析) | 自动解析 |
| 设为 | 关闭 |
| 设为 | 关闭 |
| codex 配置/会话目录(若非常规位置) |
|
可选增强
状态行:
scripts/statusline.mjs输出n codex,配置statusLine+refreshInterval:2。codex 任务本身会被自动计入底部后台任务计数,通常无需此脚本。/codex页面:commands/codex.md是 prompt 型斜杠命令,让 Claude 渲染任务状态页。Channels 推送:完成/hook 命中事件主动唤醒 agent(需
CODEX_MANAGER_CHANNELS=1+ 启动 flag,research preview)。
测试
npm test # 单元测试(vitest)
CODEX_MANAGER_INTEGRATION=1 node scripts/smoke-integration.mjs # 真实 codex 端到端(消耗少量 token)Available Tools
8 toolscodex_adoptD
Inputs: sessionId (required), cwd.
codex_discoverD
Inputs: days.
codex_hookD
Inputs: action (required), id, name, level, +4 more.
codex_listD
Inputs: ended, status.
codex_messagesD
Inputs: id (required), tail, level, limit, +3 more.
codex_runD
Inputs: prompt (required), cwd, name, wait, +16 more.
codex_sendD
Inputs: id (required), message (required).
codex_stopD
Inputs: id (required), graceful.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Without descriptions, tools like codex_hook, codex_discover, and codex_adopt are highly ambiguous. codex_send, codex_messages, and codex_run could easily be confused for similar actions.
All tools share the codex_ prefix and mostly use verb-like names (run, list, send, stop, adopt), though codex_messages is a noun, creating a minor deviation.
Eight tools is a well-scoped count for a manager-style server, providing enough varied operations without being overwhelming.
The surface appears to cover run/stop/send/list but lacks evident update/delete or configuration operations. The absence of descriptions makes it impossible to confirm full lifecycle coverage.
Related MCP Connectors
Source-checked CLI guides and model-aware planning for Claude Code, Codex, and Grok Build.
Sync coding-agent sessions and resume them in any other agent: Claude Code, Codex, Cursor, more.
Your AI apps as one team: hand work to Codex or Claude Code on your Mac, with a shared logbook.
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables MCP clients to spawn and control Codex CLI and Claude Code sessions on the host machine, with session management and filesystem access.4MIT
- AlicenseAqualityDmaintenanceEnables AI agents to interact programmatically with Claude Code CLI, managing sessions, streaming outputs, and handling permission requests.76 npm1MIT
- FlicenseNot gradedqualityCmaintenanceEnables ISLI agents and MCP clients to dispatch natural-language coding and terminal tasks to a locally-installed Claude Code CLI, supporting both one-shot execution and persistent sessions with workspace and security controls.-
- AlicenseAqualityCmaintenanceA stdio MCP server that lets Codex Desktop/CLI delegate implementation tasks to Claude Code CLI with workspace validation, Git status checks, and session resume capabilities.24MIT