Skip to main content
Glama

agent-ex

Dispatch and review with external agents.

English README · 中文版 →

agent-ex is an MCP server that treats AI coding agents (Claude Code, OpenCode, …) as external executors. You dispatch a self-contained ticket; the agent works in a detached background process and writes its result back to a SQLite-backed task store — so a long job never blocks your own conversation.

  • The npm package is agent-ex-mcp; the command it installs is agent-ex. (The -mcp suffix only avoids the registry's package-name-similarity rejection for agent-ex.)

  • The data directory is ~/.agent-ex (override with AGENT_EX_HOME).

Three collaboration shapes — all of them are just a different submit prompt, no extra tool:

Shape

How

Delegate implementation

submit(prompt=<self-contained ticket>) → the worker does the job → agent-ex wait brings back the result

Draft a plan independently

submit(prompt="read docs/ and the code, write a design to docs/plans/x.md")

Cross-review

submit(prompt="review docs/plans/x.md, list concrete problems by feasibility / gaps / contradictions")

Features

  • External executors — tasks run in a detached process tree; poll with status, stop with cancel.

  • Task state machine — queued → running → (needs_input → running → …) → completed | failed | cancelled, up to 5 continuation rounds.

  • Multi-agent, multi-provider — built-in claude and opencode executors; each profile carries its own env, model and PATH additions.

  • needs_input continuation — when the agent asks a question the task parks in needs_input; feed the answer back with submit(continue_of=…).

  • Transient-error retry — 429 / 529 / 5xx / connection resets are retried (3 attempts, backoff 30s → 60s). Timeouts and hard failures are never retried.

  • Feishu (Lark) notifications — a card is pushed when a task reaches a terminal state; dry_run lets you debug without sending.

  • No secrets in config.json — the config only holds {env:VAR} placeholders; the real values live in $AGENT_EX_HOME/.env (mode 600, never in git).

  • Self-diagnosis — version reports the build's gitSha; restart makes the server exit so the host respawns it with the current build. Running workers are unaffected.

Related MCP server: basic-mcp

Requirements

  • Node.js >= 22.5 (the server and the runner both use node:sqlite)

  • A local agent CLI — claude or opencode

Security

Workers run with the agent CLI's permission prompts skipped (claude --dangerously-skip-permissions, opencode --auto). There is no second confirmation. Use it on your own machine, in directories you trust, and think about what permissions you are handing the worker.

Install

npm i -g agent-ex-mcp
# or, without installing:
npx -y agent-ex-mcp@latest init

Quick start

agent-ex init

init is interactive: it detects the agent CLIs, asks for the provider and the keys, writes config.json + .env, and then prints a ready-to-paste MCP registration snippet. Copy it into your MCP client config (Trae: TRAE SOLO CN/User/mcp.json; WorkBuddy: ~/.workbuddy/mcp.json):

{
  "mcpServers": {
    "agent-ex": {
      "command": "/abs/path/to/node",          // printed by init
      "args": ["/abs/path/to/node_modules/agent-ex-mcp/dist/server.js"]
    }
  }
}

Use absolute paths. MCP clients spawn the server without inheriting your shell PATH, and node_modules/.bin is only injected for npm run / npx. With PATH=/usr/bin:/bin, a bare "command": "agent-ex" fails with command not found; an absolute path works. init prints the exact absolute paths it used — just copy them.

which node        # e.g. /Users/<you>/.nvm/versions/node/v24.18.0/bin/node

After that, just say "dispatch X to a background worker" in your conversation. When the task reaches a terminal state you get a Feishu notification (if you configured a webhook).

init re-runs are full overwrites of config.json — to change a single setting use agent-ex config set / agent-ex profile set instead. Details: init guide.

Optional: install the dispatch skill

The MCP tools are the low-level capability. The dispatch skill is the convention layered on top: when to delegate, how to write a self-contained ticket, why two write tasks must not run in the same directory, how to continue a needs_input task — and when not to delegate at all.

The skill ships inside the npm package, so installing it is one command:

agent-ex skill install

It does three things:

  1. copies skills/agent-ex-dispatch into ~/.agents/skills/agent-ex-dispatch (the shared directory of the Agent Skills spec);

  2. writes .agent-ex-skill.json next to it, recording the version and a content fingerprint — agent-ex skill status and agent-ex doctor use it to tell "which version is installed";

  3. symlinks it into every host that is present on this machine and should have it (Claude Code, Cursor, Windsurf, Trae, Trae CN, GitHub Copilot, Gemini CLI, OpenCode, Droid, Amp, Qwen Code, MiniMax Code, CodeBuddy, WorkBuddy).

Things worth knowing:

  • Version stays in sync with the CLI — the skill's version is the agent-ex-mcp version that shipped it. Published packages are immutable, so an installed skill always matches your CLI. Re-run agent-ex skill install after upgrading; it asks before replacing anything.

  • It never overwrites foreign content — if the target path already holds a real directory that agent-ex did not install, the command aborts and changes nothing.

  • Hosts that bridge themselves are skipped — WorkBuddy only scans ~/.workbuddy/skills, but most WorkBuddy installs ship an auto-bridge script (~/.workbuddy/hooks/sync-agents-skills.sh) that mirrors ~/.agents/skills itself. Without that script, name it explicitly: agent-ex skill install --agent workbuddy.

  • Hosts that read the shared directory are never linked — Codex, Cline and Zed read ~/.agents/skills itself, so a link could only point back at the canonical copy. agent-ex skill status lists them as "reads ~/.agents/skills — no link needed".

  • Pick hosts yourself with --agent — by default agent-ex links the hosts it finds on this machine (their config directory exists: ~/.claude, ~/.cursor, ~/.config/opencode, …). --agent <name> restricts the install to the hosts you name and links them without asking:

    agent-ex skill install --agent cursor --agent claude-code   # ids and aliases both work
    agent-ex skill install --agent '*'                          # every host that needs a link
    agent-ex skill remove --agent cursor                        # that host only; the rest stays

    An unknown name is an error — nothing gets written.

  • Non-interactive shells refuse to run it (exit code 2) unless you pass --yes: install / remove create, re-point and delete things. --yes means "answer every question with yes", not "link every host".

Inspect with agent-ex skill status (read-only), uninstall with agent-ex skill remove.

CLI commands

agent-ex is both the MCP server and the entry point for a few operational commands:

Command

What it does

agent-ex init

Interactive onboarding (detects CLIs, writes config.json + .env). Re-running overwrites config.json; it lists the diff and asks first, and backs up the old file.

agent-ex doctor

Health check: aggregates the evidence for "does the notification path work" into a verdict + cause + copy-pasteable fix. Also flags a worker PATH gap (a command such as node/npm/bun/git that the worker's own PATH cannot resolve, even though your shell can) with the exact profile set ... path_dirs command to close it. Read-only.

agent-ex doctor --fix

Auto-fixes deterministic defects (empty keyword, stale brand name, a plaintext webhook left in config.json). Never touches dry_run (that is your preference) nor a custom keyword (that is your bot's UI).

agent-ex doctor --send

Additionally sends a self-test card whose body deliberately contains no product name.

agent-ex config list

Shows profiles / executors / notify / defaults.

agent-ex config set <key> <value>

Changes one field. Whitelist: notify.dry_run, notify.keyword, defaults.timeout_sec, and executors.<name>.bin.

agent-ex profile list

Lists all profiles (marks the default one).

agent-ex profile use <profile>

Switches the default profile.

agent-ex profile create <built-in> [--bin <path>]

Materialises a built-in preset (opencode-zen-free — a zero-key opencode free-model profile). Creates only; does not switch.

agent-ex profile set <profile> <KEY> <value>

Changes a profile's env, or executor (which executor it uses), path_dirs (extra absolute PATH directories for the worker), or cost (free / metered — whether dispatching to this profile may cost money).

agent-ex wait <task_id>

Blocks until the task is terminal (or needs input) and prints the worker's final report.

agent-ex skill install

Installs the dispatch skill from the package and links it into the hosts that should have it. --agent <name> restricts it to the hosts you name.

agent-ex skill remove

Uninstalls: removes the host symlinks and the installed copy. Only symlinks — a real directory is never touched; the exit code is non-zero if anything was left behind.

agent-ex skill status

Read-only: where it is installed, which version, which hosts are not linked yet.

There is a matching agent_ex_doctor MCP tool, so an agent can diagnose itself without you copy-pasting commands.

agent-ex wait

agent-ex wait task_abc123                    # wait for a terminal state or needs_input
agent-ex wait task_abc123 --once             # check once and return
agent-ex wait task_abc123 --max-wait-sec 900 # pick your own window

stdout is machine-readable KEY=VALUE; the exit code is the contract: 0 terminal, 5 needs_input (not terminal — answer and wait again on the same id), 2 timeout, 3 not found, 6 database unreadable (an environment problem, not a task problem), 4 bad arguments. Full contract: task lifecycle.

MCP tools

Tool

Arguments

Returns

agent_ex_submit

prompt (required), project_path, profile, continue_of, timeout_sec, allow_metered

{ task_id, status, rounds }

agent_ex_status

task_id, include_finished (0.3.1+), limit

task fields; question when needs_input

agent_ex_cancel

task_id (required)

current state (idempotent on terminal tasks)

agent_ex_version

—

{ version, gitSha, buildTime }

agent_ex_doctor

send (optional)

findings with severity / detail / fix

agent_ex_restart

—

the server exits; the host respawns it

Tool names are sometimes prefixed by the host (e.g. mcp__agent-ex__agent_ex_submit).

The server is stateless — everything lives in tasks.db. restart does not affect running workers (they live in their own process groups) nor other live server instances.

Configuration

{
  "executors": {
    "claude":   { "bin": "/abs/path/to/claude", "extra_flags": ["--dangerously-skip-permissions"] },
    "opencode": { "bin": "/abs/path/to/opencode", "extra_flags": ["--auto"] }
  },
  "profiles": {
    "minimax-3": {
      "executor": "claude",
      "cost": "metered",
      "env": {
        "ANTHROPIC_BASE_URL": "https://api.minimaxi.com/anthropic",
        "ANTHROPIC_AUTH_TOKEN": "{env:MINIMAX_API_KEY}",
        "ANTHROPIC_MODEL": "MiniMax-M3[1m]"
      }
    }
  },
  "notify": {
    "feishu_webhook_url": "{env:FEISHU_WEBHOOK_URL}",
    "dry_run": true,
    "keyword": "agent-ex"
  },
  "defaults": { "profile": "minimax-3", "timeout_sec": 3600 }
}

Field

What it does

executors.<name>.bin

Where the agent CLI lives — a bare command name or an absolute path both work.

profiles.<name>.env

Environment for the agent process. {env:VAR} placeholders are resolved at task runtime. Never put PATH / NODE_OPTIONS / LD_* / DYLD_* here — that is the worker's process-loading surface, i.e. arbitrary code execution.

profiles.<name>.path_dirs

Extra absolute directories appended to the worker's PATH. This is the only supported way to extend the worker's PATH. "path_dirs": [] means "no extras, deliberately" (doctor stops suggesting dirs); an absent field means "never configured" (doctor suggests them).

profiles.<name>.cost

"free" or "metered" — whether dispatching to this profile may cost money. Undeclared means metered, so switching to this profile (when it is not the one currently configured) needs allow_metered: true. Declare "free" only when you are sure it costs nothing — doctor warns when it cannot verify that for you.

notify.dry_run

true (default) prints the card to stderr instead of sending it.

notify.keyword

The keyword appended to every card. Defaults to agent-ex; it must match the keyword registered on the bot side.

defaults.profile / defaults.timeout_sec

Default profile, and the per-round timeout in seconds.

Secrets never live in config.json: write {env:VAR} placeholders there and the real values into $AGENT_EX_HOME/.env (mode 600, auto-loaded by the server at startup).

Cost gate. The gate catches one shape: the agent switching to a paid profile on its own. Dispatching to the profile the user currently has configured (defaults.profile) is never blocked — that is the user's own choice, paid or not — and neither is switching to a free profile. What needs allow_metered: true is a switch to a different, metered profile, and the caller may only pass it when the user explicitly asked for that profile or agreed to pay. The flag is per dispatch: a quota error, an exhausted free pool, a timeout or a failed run is not an agreement to pay, so a failed run must not be retried with the flag added. The effective cost of every dispatch is recorded on the task row and shown by agent_ex_status and in the terminal card footer (计费档 / 免费档 / 未记录).

Full reference — every field, {model:zen-free}, the [1m] context-window trick, path_dirs, the write whitelist: configuration guide.

Notifications

Notifications go to a Feishu (Lark) custom bot webhook. The tool only supports the "keyword" security mode — do not enable signature verification, the tool does not send timestamp/sign and every card would be rejected.

Verify the path with a self-test card instead of a real task report:

agent-ex doctor --send

Feishu code

Meaning

0

delivered

19024

keyword mismatch — the bot's keyword and notify.keyword disagree

19021

signature verification failed — the bot has "加签" enabled; turn it off

19001

the webhook URL itself is invalid — copy a new one

19022

IP allow-list rejected the call

Full walkthrough (bot setup, the security-mode matrix, every error code): notifications guide.

Troubleshooting

Symptom

Likely cause

executor "claude" bin "…" not found or not executable

Wrong path, or the file is not +x. A bare name is resolved against process.env.PATH.

Task fails with failed to spawn runner: … ENOENT

The directory holding bin has no executable. The worker's PATH is rebuilt from dirname(bin) + path_dirs + system dirs — /opt/homebrew/bin is not included unless you declare it in path_dirs.

{env:VAR} fails with not found in process environment

The key is neither in .env nor exported to the server process. Add it to $AGENT_EX_HOME/.env and restart the server.

Feishu sends nothing

notify.dry_run is still true; or the webhook is missing; or the bot has signature verification enabled (code=19021).

Behaviour did not change after editing code

The MCP host reuses a long-lived server process. Rebuild, then restart, then check gitSha with version.

The skill is installed but the host does not load it

Run agent-ex skill status to see which hosts are not linked, then agent-ex skill install --agent <host>.

Documentation

Document

Contents

中文版 README

The same guide in Chinese

配置详解

Every config.json field, secrets, model resolution, worker PATH

飞书通知详解

Bot setup, security modes, error codes

任务生命周期与状态机

State machine, continuation, agent-ex wait contract

init 详解

The onboarding wizard step by step

AGENTS.md

Maintainer guide: hard constraints, release process

CHANGELOG.md

Version history

License

MIT

Available Tools

6 tools
agent_ex_cancelA

取消任务(状态感知、幂等):running 杀整个进程组;已终态则原样返回当前状态。 若返回带warning,说明进程树快照不可用(ps 被拒),组外逃逸的 agent 子进程可能残留。

Inputs: task_id (required).

agent_ex_doctorA

体检:把「通知到底通不通」的证据聚合成结论 + 病因 + 修复命令。 查三类问题:config 本身(关键词/dry_run/webhook/默认profile)、executor 的 bin 是否可执行、 历史通知失败(扫 runner 日志里的飞书拒收记录,按 code 聚合)。 send=true 会额外实发一张正文不含产品名的自检卡——验证通知必须用它, 因为飞书关键词闸门匹配整张卡片,拿真实任务报告当探针会假通过。

Inputs: send.

agent_ex_restartA

主动重启当前 MCP server 进程(process.exit,由 host 自动 respawn 并加载当前 dist)。 server 无状态、in-flight worker 在独立进程组,重启安全;只重启调用方这条连接,不影响其他 live server 或在跑任务。

Inputs: no named parameters.

agent_ex_statusA

查询任务状态。无参数调用返回全部进行中的任务,用于一次性概览; needs_input 任务会返回 question 字段。 include_finished=true 时连已结束的任务(completed/failed/cancelled)一起列,按创建时间倒序—— 会话重启或上下文压缩后要认回「上次派的任务」时用它(默认列表里只有进行中的任务)。

Inputs: limit, task_id, include_finished.

agent_ex_submitA

派发编码任务给外部 worker(detached runner),立即返回 task_id,不阻塞。 prompt 需包含完整上下文、约束与验收标准——worker 不共享当前会话上下文。 任务已提交,卡住/完成会推飞书,无需轮询。 同一 project_path 的写任务并发会互相踩文件——plan 负责串行派发或确保改动文件不重叠;只读分析任务不受此限,可并行。 对 needs_input 任务答疑续跑时传 continue_of=task_id,prompt 填答案,worker 将带着原上下文继续。 切到当前默认档(defaults.profile)以外的计费档 profile 时必须传 allow_metered=true,且只在用户本轮明确指定该 profile 或明确同意付费时传——429、额度上限、超时、失败都不构成同意。

Inputs: prompt (required), profile, continue_of, timeout_sec, +2 more.

agent_ex_versionA

返回当前 MCP server 构建元数据(version / gitSha / buildTime),用于确认重启后新代码已生效。 构建信息缺失时返回 unknown。

Inputs: no named parameters.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 6 tools

    Disambiguation4/5

    The six tools map to clearly different actions: dispatch (submit), inspect (status), stop (cancel), plus server ops (restart, version, doctor). The only mild overlap is between version and doctor, since both are 'check the system' tools, but their descriptions distinguish build metadata from notification/executor health clearly.

    Naming Consistency4/5

    All tools share a consistent agent_ex_ snake_case prefix and use short, predictable suffixes. The only deviation is mixing verbs (submit, restart, cancel) with noun-style query names (status, version, doctor), which is a common and readable convention rather than an inconsistency.

    Tool Count5/5

    Six tools sit squarely in the well-scoped range for a task-orchestration MCP server. Each tool covers a distinct concern (dispatch, inspect, cancel, restart, version, diagnostics) and none feels redundant or bolted on.

    Completeness4/5

    The task lifecycle is fully covered: submit, status (including finished tasks and needs_input questions), cancel, and continuation via continue_of. Operational concerns (restart, version, doctor) round it out; the main minor gap is no dedicated per-task log/result retrieval tool, relying on status or runner logs instead.

    Maintenance

    ActivityActive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables agents to register tasks, dispatch work under explicit caller/owner credentials, amend goals, report and deliver results, read outstanding records, and manage task dependencies through a structured SQLite-backed coordination service. Ships paired collaboration skills for discussing parties and executing owners, keeping a single canonical task identity so work boards reflect the latest reports without monitoring or auto-dispatch.
      -
    • A
      license
      B
      quality
      C
      maintenance
      Enables task management with persistent SQLite storage, along with tools, resources, subscriptions, prompts, and completions over stdio or Streamable HTTP with per-user authentication.
      9
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables agents to manage a local SQLite task backlog over stdio, with tools to create, search, list, get, update, and stat tasks while preserving audit history and idempotency.
      MIT