codex-mcp-swarm
Wraps OpenAI's Codex CLI with true parallel task execution, worktree isolation for conflict-free runs, and live monitoring of each task.
README
codex-mcp-swarm
An MCP server that wraps OpenAI's Codex CLI with true parallel execution and live task monitoring. Zero dependencies -- single Python file, stdlib only.
Why?
The official codex mcp-server processes requests sequentially. If your MCP client (Claude Code, etc.) needs to run 5 Codex tasks, they queue up one after another. This server spawns each task as an independent subprocess, so they run in parallel.
Unique features no other Codex MCP wrapper has:
- Worktree isolation --
worktree: truecreates an isolated git worktree per task so parallel Codex instances never edit past each other - Batch wait -- launch N tasks, call
codex_waitonce, get all results when they finish - Live status -- see what each Codex task is doing right now (last tool call, current reasoning, progress)
- Full flag parity -- same parameters as the official Codex MCP tool (
sandbox,approval-policy,cwd,model,config, etc.) - Drop-in config -- accepts the same
-c key=valueserver args ascodex mcp-server
Tools
| Tool | Description |
|---|---|
codex |
Synchronous execution (drop-in replacement for official) |
codex_async |
Fire-and-forget -- returns a task_id immediately |
codex_reply |
Continue a previous session via codex exec resume |
codex_status |
Live view: tools called, last command, current thinking |
codex_wait |
Block until multiple tasks complete, return all results |
codex_cancel |
Kill a running async task (preserves worktree for inspection) |
Installation
Claude Code
claude mcp add codex-swarm -- uvx --upgrade codex-mcp-swarm \
-c model=gpt-5.4 \
-c approval_policy=never \
-c sandbox_mode=danger-full-access \
--skip-git-repo-check
That's it. No clone, no setup. uvx downloads and runs it directly from PyPI. The --upgrade flag ensures you always get the latest version on restart.
Note: Requires uv (
curl -LsSf https://astral.sh/uv/install.sh | sh). Alternatively, usepipx run codex-mcp-swarminstead ofuvx codex-mcp-swarm.
Manual (~/.claude.json)
{
"mcpServers": {
"codex-swarm": {
"type": "stdio",
"command": "uvx",
"args": [
"--upgrade",
"codex-mcp-swarm",
"-c", "model=gpt-5.4",
"-c", "approval_policy=never",
"-c", "sandbox_mode=danger-full-access",
"--skip-git-repo-check"
]
}
}
}
The -c flags are identical to codex mcp-server -- copy-paste your existing config.
Usage
Parallel execution
1. Call codex_async with prompt A --> task_id: "abc123"
2. Call codex_async with prompt B --> task_id: "def456"
3. Call codex_async with prompt C --> task_id: "ghi789"
4. Call codex_wait(task_ids=["abc123", "def456", "ghi789"])
--> blocks until all finish, returns all results
Worktree isolation
Prevent parallel tasks from editing the same files:
1. Call codex_async(prompt="Refactor auth", worktree=true)
--> task_id: "abc123"
--> Worktree Branch: codex-swarm/abc123
2. Call codex_async(prompt="Add logging", worktree=true)
--> task_id: "def456"
--> Worktree Branch: codex-swarm/def456
3. codex_wait(task_ids=["abc123", "def456"])
4. git merge codex-swarm/abc123
5. git merge codex-swarm/def456
Each task gets its own git worktree and branch based on HEAD. After completion, merge the branches back. Worktrees are automatically cleaned up after 24 hours (configurable via CODEX_SWARM_TASK_MAX_AGE).
Live monitoring
Call codex_status(task_ids=["abc123"])
-->
=== Task abc123 (45s elapsed) ===
Phase: running
Tools called: 23
Last tool: exec_command(grep -rn "handleError" src/)
Output: Analyzing error handling patterns across the codebase...
Session continuity
1. Call codex(prompt="Review this file") --> result + session persisted
2. Call codex_reply(threadId="<session-uuid>", prompt="Now fix the bug you found")
Server flags
| Flag | Description |
|---|---|
-c key=value |
Config default (repeatable). Same format as codex mcp-server. |
--skip-git-repo-check |
Allow running outside git repos. |
--ephemeral |
Don't persist session files. Disables codex_reply. |
Per-call parameters
All parameters from the official Codex MCP tool are supported:
prompt(required)model-- override server defaultsandbox--read-only,workspace-write,danger-full-accessapproval-policy--untrusted,on-failure,on-request,nevercwd-- working directoryprofile-- config profile fromconfig.tomlconfig-- object of key=value overridesworktree-- run in an isolated git worktree (prevents parallel tasks from conflicting)base-instructions,developer-instructions,compact-prompt
MCP Resources
The server exposes read-only resources for discoverability:
| URI | Description |
|---|---|
codex-swarm:///server-info |
Version, capabilities, directories, config |
codex-swarm:///config |
Current server-level defaults and flags |
codex-swarm:///tasks |
All known tasks and their current state |
Environment variables
| Variable | Default | Description |
|---|---|---|
CODEX_SWARM_LOG |
/tmp/codex_mcp_swarm.log |
Log file path |
CODEX_SWARM_LOG_LEVEL |
WARNING |
Log level (DEBUG, INFO, WARNING, ERROR) |
CODEX_SWARM_TASK_DIR |
/tmp/codex_swarm_tasks |
Task output storage directory |
CODEX_SWARM_WORKTREE_DIR |
/tmp/codex-swarm-worktrees |
Worktree storage directory |
CODEX_SWARM_TASK_MAX_AGE |
86400 (24h) |
Seconds before completed task artifacts (and worktrees) are cleaned up |
Requirements
- Python 3.8+
- Codex CLI installed and authenticated
- No pip dependencies (stdlib only)
- Works on Linux and macOS (Linux gets extra PID reuse protection and zombie detection via
/proc)
Credits
Originally inspired by jeanchristophe13v/codex-mcp-async. Rewritten with full flag parity, JSONL status parsing, batch wait, and session reply support.
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 模型以安全和受控的方式获取实时的网络信息。