Skip to main content
Glama

License: MIT Python 3.11+ Platform: Windows Protocol: MCP Streamable HTTP Runtime: codex app-server


1. Why Codex Swarm?

Native Codex subagents use a strict parent-child hierarchy where siblings cannot talk to each other, active waits consume turn runtime, and every subagent shares the parent working directory by default. Codex Swarm bridges those gaps using codex app-server + a local Streamable HTTP MCP bus so you can orchestrate a full swarm right inside Codex Desktop App / CLI via $swarm.

Capability

Native Codex Subagents

Codex Swarm (Path 3 · Form A)

Peer-to-Peer @mention Comms

Parent ↔ child relay only

Direct P2P (author ↔ verifier wake each other via @name / @all / @#channel)

Idle Worker Cost

Active wait eats turn timeout

Zero-token parked threads — turns end cleanly and wake on @mention (turn/start / turn/steer)

Workspace Isolation

Shared parent CWD

Automatic git worktree per parallel author (.swarm-worktrees/<id>/<worker>)

Single-Window Experience

Terminal / thread tree only

Auto-opens in Codex Side Browser (iab) next to your chat, plus Desktop shortcut

Live Swarm Visualization

No shared board or graph

4-Tab Web UI with Hive & Mention Graph timeline playback (0.5×–4×)

Model Hot-Switching

Requires fresh spawn

Hot-switch waiting worker models while preserving full threadId history

Stall Detection & Approvals

Manual inspection

Built-in 180s stall watchdog + one-click Allow / Session / Decline UI cards


Related MCP server: agent-bridge

2. Interface Showcase

Light-first, zero-CDN offline Web Dashboard (http://127.0.0.1:8765/) with one-click Dark mode toggle and responsive narrow-pane layout (≤640px) built specifically for Codex's side browser.


3. Architecture

  1. Stay in your Codex chat: Your active Codex Desktop App / CLI thread acts as Coordinator via the $swarm skill and connects to http://127.0.0.1:8765/mcp.

  2. Event-driven worker threads: The local Python Daemon manages a persistent codex app-server --stdio process. Every worker runs in its own threadId and ends its turn immediately after posting to the board — consuming zero tokens while parked.

  3. Instant wakeup & steer: When any worker or coordinator posts @target, the daemon injects unread #seq context via turn/start (if waiting) or turn/steer (if working).

  4. Single-window side browser: On Codex Desktop App, $swarm automatically reveals the built-in In-App Browser (iab) and pins the dashboard tab (markDeliverable) right beside your conversation.


4. Quick Start

Prerequisites

  • Windows 10 / 11 + PowerShell

  • Python 3.11+ (pip install -r requirements.txt — only aiohttp is required)

  • Git (for workspace="share" worktree isolation)

  • OpenAI Codex Desktop App or Codex CLI signed in (auto-discovers CODEX_CLI_PATH, PATH, or bundled WindowsApps\OpenAI.Codex_*\...\codex.exe)

Install in 4 Commands

git clone https://github.com/moonrzz/codex-swarm.git
cd codex-swarm
pip install -r requirements.txt
.\install.ps1

install.ps1 automatically:

  1. Installs the $swarm skill to %USERPROFILE%\.agents\skills\swarm\SKILL.md;

  2. Backs up %USERPROFILE%\.codex\config.toml and registers [mcp_servers.swarm_board] (default_tools_approval_mode = "approve");

  3. Creates a silent one-click 「Codex 蜂群看板」 shortcut on your Desktop (pass -DesktopShortcut:$false to skip).

Launch & Use

# Start background daemon manually (or let $swarm / Desktop shortcut start it automatically)
.\start-swarm-daemon.ps1 -Background

# Stop background daemon
.\stop-swarm-daemon.ps1

Open a new conversation in Codex Desktop App / CLI and type:

$swarm Refactor the auth module into token and session layers, add unit tests, and run a peer review

5. Try Peer-to-Peer Collaboration

Want to verify direct sibling-to-sibling communication without modifying any repository files? Paste this read-only prompt into Codex:

$swarm Verify direct peer-to-peer (P2P) collaboration between sibling workers without editing any files:

1. Spawn two read-only workers (`workspace="inherit"`, `sandbox="read-only"`):
   - `proposer`: Draft a 3-point minimal code review checklist, then post directly to `@reviewer` for critique (do NOT `@coordinator` and do NOT write `[done]`), and end your turn immediately.
   - `reviewer`: Wait for `@reviewer`, point out at least 1 vague rule, and post directly to `@proposer` requesting measurable criteria (do NOT `@coordinator` or `[done]`), then end your turn.
2. Have `proposer` revise the checklist and post v2 back to `@reviewer` (still without `@coordinator`).
3. Have `reviewer` verify v2 and post `@coordinator [done]` summarizing both rounds.
4. As Coordinator, do not relay between them; only report to me after receiving `@coordinator [done]`, listing the P2P `#seq` numbers.

Then open the 关系图 → 提及图 tab to see direct bidirectional arrows (proposer ↔ reviewer) bypassing Coordinator!


6. MCP Tool Reference

Tool

Role

Description

swarm_init

Coordinator

Create a new active swarm bound to repo_root and title

swarm_title

Coordinator

Rename the active swarm

swarm_plan

Coordinator

Publish plan.json (goal, tasks, threads) for Overview & Hive

swarm_models

Coordinator

List available Codex models from codex app-server

swarm_add

Coordinator

Spawn a persistent worker (inherit or isolated share git worktree)

swarm_status

All

Inspect roster states, head #seq, dashboard URL, and pending approvals

swarm_model

Coordinator

Hot-switch a waiting worker's model while keeping its threadId

swarm_kill

Coordinator

Terminate a worker and optionally clean up its worktree/branch

swarm_channel

All

create, list, archive, subscribe, or unsubscribe channels

post_message

All

Post to the board and auto-wake @name / @all / @#channel recipients

read_board

All

Read incremental messages after since #seq

swarm_wait

Coordinator

Block until @coordinator / [done] / [stall] arrives after since


7. Worktree Merge & Project Structure

When parallel authors run with workspace="share", each commits on swarm/<swarm_id>/<worker>:

  1. Have a read-only verifier audit diffs and test results;

  2. Merge verified branches: git merge --no-ff swarm/<swarm_id>/<worker>;

  3. Clean up: swarm_kill(name="<worker>", remove_worktree=True, delete_branch=True).

python -m unittest discover -s tests -v
codex-swarm/
├─ codex_swarm/
│  ├─ app_server.py    # codex app-server --stdio JSON-RPC 2.0 client
│  ├─ orchestrator.py  # @mention wakeup router, model hot-swap, approvals, stall watchdog
│  ├─ mcp_http.py      # Streamable HTTP MCP server (/mcp)
│  ├─ web_ui.py        # Light-first 4-tab Web UI + Hive/Mention Graph & playback
│  ├─ store.py         # SQLite WAL + append-only JSONL persistence
│  ├─ worktree.py      # Git worktree isolation & cleanup
│  └─ config.py        # Settings & automatic codex.exe discovery
├─ docs/assets/        # Vector banner, architecture diagram & UI showcase screenshots
├─ skills/swarm/SKILL.md
├─ assets/swarm-icon.ico
├─ tests/test_swarm_daemon.py
├─ install.ps1
├─ start-swarm-daemon.ps1
├─ stop-swarm-daemon.ps1
├─ launch-dashboard.ps1
└─ launch-dashboard-silent.vbs

License

Released under the MIT License.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers