Skip to main content
Glama

claude-mcp-swarm

An MCP server that wraps Anthropic's Claude Code CLI (claude) with true parallel execution, live task monitoring, git worktree isolation, and MCP Tasks support. Powered by stdlib-only mcp-swarm-core (zero third-party runtime dependencies).

Why?

Run multiple Claude Code (claude -p) agents concurrently from Codex, Antigravity, Claude Code, or any MCP client without serial queueing, with live visibility into tool calls, token usage, structured output, tool errors, permission denials, and isolated HEAD-based git worktrees.

Key features:

  • True parallel fan-out - each task runs as an independent claude -p --output-format=stream-json --verbose subprocess

  • Worktree isolation - worktree: true creates an isolated HEAD-based git worktree (claude-swarm/<id>) per task so parallel runs never edit past each other

  • Batch wait & MCP Tasks - supports both explicit fan-out (claude_async + claude_wait) and the official MCP 2026-07-28 Tasks extension (io.modelcontextprotocol/tasks)

  • Live JSONL streaming status - parses system, assistant, user, and terminal result NDJSON events incrementally for live tool counts, last tool call, token usage, tool errors, and permission denials

  • Non-interactive claude -p flag support - --model, --fallback-model, --effort, --permission-mode, --dangerously-skip-permissions, --tools, --allowed-tools, --disallowed-tools, --add-dir, --agent, --agents, --system-prompt, --append-system-prompt, --json-schema, --settings, --setting-sources, --mcp-config, --strict-mcp-config, --max-turns, --max-budget-usd, --disable-slash-commands, --no-session-persistence, --bare, --resume, and --fork-session

  • Safe stdin transport - prompts are sent via UTF-8 stdin and all value options use --flag=value syntax, avoiding OS argv length limits, leading-- option injection, Commander.js variadic greediness, and Windows shell quoting issues

Related MCP server: Roundtable AI MCP Server

MCP Protocol Support

  • Stateless MCP 2026-07-28 - supports server/discover, per-request _meta["io.modelcontextprotocol/protocolVersion"] and _meta["io.modelcontextprotocol/clientCapabilities"], resultType discriminators, and unsupported-version rejection (-32022).

  • Official Tasks extension (io.modelcontextprotocol/tasks) - when a client advertises io.modelcontextprotocol/tasks, claude and claude_reply immediately return a CreateTaskResult (resultType: "task") with a 128-bit taskId. Clients poll tasks/get and cancel via tasks/cancel per SEP-2663.

  • Backward-compatible stateful MCP (2024-11-05 through 2025-11-25) - supports initialize negotiation, top-level server instructions, ping, tool annotations, outputSchema + structuredContent, accurate isError flags, enriched notifications/progress, and JSON-RPC 2.0 §4.1 silent handling of unknown notifications.

Tools

Tool

Description

claude

Synchronous execution (or native MCP Task when client supports io.modelcontextprotocol/tasks); returns text, session_id, token usage, optional structured_output, tool_errors, permission_denials, and structured failure details

claude_async

Launch a task, get a task_id immediately (fan-out). Not fire-and-forget: results come back only via claude_wait. Pass session_id to resume a session (with optional fork_session: true)

claude_reply

Continue a previous session via claude --resume=<session_id>. Automatically reuses the original session's working directory (including its worktree path) when cwd is omitted

claude_status

Live read-only peek: tools called, last tool call, permission mode, tool errors, token usage, and failure cause

claude_wait

Block until multiple tasks complete and return results or structured failure details

claude_cancel

Kill a running async task and its child process tree (preserves worktree for inspection); if already completed or failed, preserves and reports that outcome

claude_models

List available Claude Code model aliases/identifiers, resolved model IDs, and supported effort levels (queried live without starting a turn, persisting a session, or running hooks)

Installation

PyPI

uvx --upgrade claude-mcp-swarm --model opus

Local checkout (development)

uvx --from /path/to/claude-mcp-swarm --with /path/to/mcp-swarm-core claude-mcp-swarm --model opus

Codex (~/.codex/config.toml)

[mcp_servers.claude-swarm]
command = "uvx"
args = ["--upgrade", "claude-mcp-swarm", "--model", "opus", "--dangerously-skip-permissions"]

Unattended permissions & MCP isolation

  • Pass --dangerously-skip-permissions or --permission-mode bypassPermissions / acceptEdits / dontAsk in server defaults (or per call) for unattended runs in trusted repos or sandboxes.

  • If you want spawned Claude workers to skip loading your user MCP servers (faster startup and avoids recursive MCP server loading), pass --strict-mcp-config (optionally with --mcp-config <file-or-json>).

Usage

Parallel execution

1. Call claude_async(prompt="Audit module A", worktree=true)  ->  task_id: "a1b2c3d4"
2. Call claude_async(prompt="Audit module B", worktree=true)  ->  task_id: "e5f60718"
3. Call claude_wait(task_ids=["a1b2c3d4", "e5f60718"])
   -> blocks until all finish, returns all results

claude_async and claude_wait belong in the same turn: task_id is internal to this server and not tracked by legacy MCP clients. Short timeout values on claude_wait are raised to a floor (default 150s, configurable via CLAUDE_SWARM_MIN_WAIT) so long waits cross the client's 2-minute auto-backgrounding threshold; already-finished tasks return immediately.

Session continuity & worktree cwd preservation

  • When cwd is omitted on claude_reply (or claude_async(session_id=...)), the server automatically reuses the original session's working directory (including its worktree path if it still exists; persisted on disk for async and worktree runs, and tracked in-process for non-worktree sync runs).

  • Pass fork_session: true alongside session_id to branch a conversation into a new session_id without mutating the original transcript.

  • Note that no_session_persistence: true disables writing session transcripts to disk, so those sessions cannot be resumed later.

Structured output (json_schema)

Pass json_schema (JSON object or string) to forward --json-schema to Claude Code so it can emit validated JSON via its StructuredOutput tool. When claude returns result.structured_output, it is exposed on structuredContent.structured_output. Callers should still check that structured_output is present, because Claude CLI can exit 0 without it on short-circuited CLI commands or prose fallbacks.

Credentials in config flags

Inline JSON passed via --settings or --mcp-config is redacted from the claude-swarm:///config resource, while file paths remain visible. Prefer file paths (e.g. --mcp-config /path/to/mcp.json) over inline tokens or env secrets so credentials are not passed on process command lines or stored in .meta files.

Worktree isolation

Caveats:

  • Because worktrees branch from HEAD (git worktree add -b claude-swarm/<id> ... HEAD), uncommitted and untracked changes in your working tree are not included in the worktree. Commit prerequisite edits first if the task needs them.

  • Expired worktrees (older than CLAUDE_SWARM_TASK_MAX_AGE, default 24 hours) are lazily removed on a subsequent task launch via git worktree remove --force and git branch -D. Merge or cherry-pick before expiry.

Server flags

Flag

Description

--version

Show version and exit

--model MODEL

Default model alias or full name (e.g. opus, sonnet, haiku, fable)

--fallback-model MODEL

Default fallback model(s), comma-separated

--effort LEVEL

Default reasoning effort (low, medium, high, xhigh, max)

--permission-mode MODE

Default permission mode (acceptEdits, auto, bypassPermissions, manual, dontAsk, plan)

--dangerously-skip-permissions

Bypass all permission checks by default

--tools TOOLS

Built-in tools to expose ("" for none, "default", or comma-separated names)

--allowed-tools TOOL

Tool rule to allow by default (repeatable)

--disallowed-tools TOOL

Tool rule to deny by default (repeatable)

--add-dir DIR

Additional directory Claude can access by default (repeatable)

--agent NAME

Default agent name

--agents JSON_OR_PATH

Default custom agents JSON object or file path

--system-prompt TEXT

Default system prompt override

--append-system-prompt TEXT

Default text appended to the system prompt

--settings JSON_OR_PATH

Default extra settings JSON object or file path

--setting-sources SOURCES

Comma-separated setting sources (user,project,local)

--mcp-config JSON_OR_PATH

Default MCP config file or JSON string (repeatable)

--strict-mcp-config

Only use MCP servers from --mcp-config by default

--max-turns N

Default maximum agentic turns per invocation

--max-budget-usd AMOUNT

Default maximum API budget in USD per invocation

--disable-slash-commands

Disable skills and slash commands by default

--no-session-persistence

Do not persist sessions to disk by default

--bare

Minimal headless mode (skip hooks, plugins, CLAUDE.md discovery, OAuth/keychain; API-key / provider auth only)

Boolean server flags can be explicitly overridden to false on any individual tool call.

MCP Resources

URI

Description

claude-swarm:///server-info

Version, capabilities, directories, CLI protocol contract

claude-swarm:///config

Current server-level CLI defaults

claude-swarm:///models

Available Claude Code model aliases, resolved IDs, and supported effort levels

claude-swarm:///tasks

All known tasks and their state, usage, tool errors, permission denials, and failure details

Environment variables

Variable

Default

Description

CLAUDE_SWARM_LOG

<user-runtime>/claude-swarm/claude_mcp_swarm.log

Log file path

CLAUDE_SWARM_LOG_LEVEL

WARNING

Log level (DEBUG, INFO, WARNING, ERROR)

CLAUDE_SWARM_TASK_DIR

<user-runtime>/claude-swarm/tasks

Task output storage directory (owner-only 0700 when using default)

CLAUDE_SWARM_WORKTREE_DIR

<user-cache>/claude-swarm/worktrees

Worktree storage directory (owner-only 0700 when using default)

CLAUDE_SWARM_TASK_MAX_AGE

86400 (24h)

Seconds after completion / last reply activity before task artifacts and worktrees are cleaned up

CLAUDE_SWARM_MIN_WAIT

150

Floor in seconds for claude_wait

CLAUDE_SWARM_BIN

(auto)

Explicit path or command name for claude (auto-searches PATH and ~/.local/bin/claude)

Requirements

  • Python 3.8+

  • Claude Code CLI (claude) installed and authenticated

  • Only depends on stdlib-only mcp-swarm-core (no third-party packages)

License

MIT

Available Tools

7 tools
claudeA
Destructive

Run a Claude Code (claude -p) session synchronously (or as a native MCP Task when the client advertises io.modelcontextprotocol/tasks). This server applies NO timeout of its own, but legacy MCP clients typically cut a tool call around 300s -- use claude_async + claude_wait for long runs or parallel fan-out on non-Tasks clients.

Inputs: prompt (required), cwd, bare, agent, +24 more. Returns: text, model, usage, effort, +16 more

claude_asyncA
Destructive

Launch a Claude Code task and return immediately with a task_id for parallel fan-out, then collect with a single claude_wait. CRITICAL: the task_id is internal to this server and NOT tracked by your MCP client -- you MUST call claude_wait in the same turn or results are stranded on disk. Pass session_id to resume an existing session asynchronously, and set worktree=true to isolate parallel edits in a HEAD-based git worktree.

Inputs: prompt (required), cwd, bare, agent, +24 more. Returns: error, model, status, task_id, +2 more

claude_cancelA
DestructiveIdempotent

Kill a running async Claude Code task and its child processes. Any worktree and partial output are preserved for inspection. If the task had already failed, the response includes its structured failure details.

Inputs: task_id (required). Returns: error, model, status, message, +10 more

claude_modelsA
Read-onlyIdempotent

List available Claude Code model aliases/identifiers, their resolved model IDs, and supported effort levels (queried live from the Claude Code CLI without starting a turn or persisting a session). Use this before passing a model override to claude / claude_async / claude_reply.

Inputs: no named parameters. Returns: error, models, source, warning, +1 more

claude_replyA
Destructive

Continue a Claude Code session via claude --resume=<session_id> (runs synchronously, or as a native MCP Task when the client advertises io.modelcontextprotocol/tasks). Automatically reuses the original session's cwd/worktree when cwd is omitted. Pass fork_session=true to branch into a new session_id. For long follow-ups on non-Tasks clients, prefer claude_async(session_id=..., prompt=...) + claude_wait.

Inputs: prompt (required), session_id (required), cwd, bare, +23 more. Returns: text, model, usage, effort, +14 more

claude_statusA
Read-onlyIdempotent

Get live status of async Claude Code tasks (tool calls, tool errors, permission mode, token usage, and terminal failure details). This is a read-only peek: it collects nothing and does not keep a task attached to your session -- only claude_wait does that. A FAILED verdict here is not always authoritative when inferred without a terminal event or exit code (flagged explicitly in the output).

Inputs: task_ids (required). Returns: tasks

claude_waitA
Read-onlyIdempotent

Block until one or more async Claude Code tasks complete, then return all results. Pass every task_id you launched in ONE call. Let it run long past your client's backgrounding threshold (short timeouts are raised to a floor; finished tasks return instantly). A wait timeout does NOT kill tasks -- call claude_wait again to keep waiting.

Inputs: task_ids (required), timeout. Returns: tasks

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 7 tools

    Disambiguation4/5

    Most tools are clearly distinct: launch (claude/claude_async), resume (claude_reply), inspect (claude_status), collect (claude_wait), cancel, and model listing. The main overlap is between claude (synchronous) and claude_async (asynchronous launch), plus claude_reply versus claude_async with a session_id, but the descriptions explicitly clarify these boundaries.

    Naming Consistency4/5

    Six of seven tools follow a predictable claude_<verb> snake_case pattern: claude_async, claude_reply, claude_status, claude_wait, claude_cancel, claude_models. The base synchronous runner is just named 'claude', which is a minor but understandable deviation.

    Tool Count5/5

    Seven tools is well-scoped for managing Claude Code sessions and async tasks. Each tool maps to a distinct lifecycle operation: run, launch, resume, inspect, wait, cancel, and list models.

    Completeness4/5

    The surface covers the core lifecycle well: synchronous execution, asynchronous launch, resumption, status inspection, result collection, cancellation, and model discovery. Minor gaps include no explicit session/task listing or worktree cleanup/management tool, though worktrees are handled implicitly through launch and cancel.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables coordinating Claude Code and Codex on one machine by fanning out tasks to multiple agents in isolated Git worktrees, comparing results, picking a winning candidate, and handing off work between harnesses. It provides MCP stdio tools, a CLI, and a local loopback web cockpit.
      Apache 2.0
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables a primary AI assistant in an IDE to delegate tasks to multiple specialized AI coding assistants via MCP, running them in parallel with shared project context and synthesizing a single response. It uses existing CLI tools and subscriptions, supporting Codex, Claude, Cursor, Gemini, and 26+ MCP-compatible clients.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP clients to delegate work to nested subagents running on Codex and Claude Code, keeping each task's session, turn history and results durable in SQLite while the main chat continues. Supports async or blocking waits, mid-session context updates, git worktree isolation, read-only-by-default permission inheritance, and cancelling whole subagent trees.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP clients to fan out multiple Google Antigravity (agy) CLI agents in true parallel, monitor their live progress and token usage, wait on batches, and cancel tasks. Adds git worktree isolation per task, conversation resume, structured output, and native MCP Tasks support so concurrent agent runs never block or edit over each other.
      MIT