agent-dispatch
ginkida · ginkida/agent-dispatch
MCP server và CLI này cho phép các tác nhân Claude Code ủy quyền nhiệm vụ cho các tác nhân khác trong các thư mục dự án để điều phối đa tác nhân.
MCP server + CLI that lets Claude Code agents delegate tasks to agents in other project directories. Multi-agent orchestration: parallel dispatch, sessions, async jobs, agent dialogues.
Xem trước
Bạn có thể làm gì với nó
- Điều phối nhiều tác nhân chuyên biệt để xây dựng các phần khác nhau của một ứng dụng web phức tạp.
- Ủy quyền phát triển backend cho một tác nhân và các tác vụ UI frontend cho tác nhân khác, sau đó kết hợp kết quả.
- Tạo một nhóm tác nhân để quản lý một dự án microservices, mỗi tác nhân xử lý một dịch vụ cụ thể.
Kiểm tra an toàn
Không thấy dấu hiệu rủi ro trong các file đã quét.
Quét tự động các file trong repo. Luôn xem lại code trước khi chạy.
Trích từ README
agent-dispatch
MCP server that lets Claude Code agents delegate tasks to agents in other project directories.
Each agent runs as a separate claude -p session in its own project directory — inheriting that project's MCP servers, CLAUDE.md, and tools. The calling agent just gets the result back.
Related projects can be bundled into a group — a shared brief plus a member list — so one session can coordinate work across them (e.g. code repos + an infra/Portainer gateway + an analytics gateway).
Works with OAuth, API key, and Claude subscription authentication.
AI agents: this README is the canonical doc for using the tool — setup: Quick Start (every step has a deterministic verify), first call:
dispatch, tool selection: Which Tool to Use, failure handling: Error Recovery. Working on this repo instead? See AGENTS.md.
Quick Start
Prerequisite: the Claude Code CLI must be installed and authenticated. Check first:
claude --version # must print a version — if it fails, install Claude Code before continuing
Then:
pip install agent-dispatch # or: pipx install agent-dispatch
# 1. Create config + register the MCP server with Claude Code (user scope)
agent-dispatch init
# 2. Register project directories as agents — REPLACE the example paths with
# real directories on your machine; they must exist (~ is expanded, relative
# paths are resolved). Descriptions are auto-generated from project files.
# No second project handy? Use the zero-setup block below instead.
agent-dispatch add infra ~/projects/infra
agent-dispatch add backend ~/projects/backend
# 3. Smoke test — dispatches a real task to the agent added in step 2 and prints
# the answer; exit 0 on success. Default task when none given:
# "What project is this? Describe in one sentence."
agent-dispatch test infra
# 4. Verify the whole install — prints "All checks passed." and exits 0 on success
agent-dispatch doctor
Zero-setup alternative for steps 2–3 (no second project needed — registers the current directory):
agent-dispatch add self . && agent-dispatch test self "Say hello"
Every Claude Code session now has the dispatch tools. Independent check: claude mcp list must print a line starting with agent-dispatch:. From inside a Claude Code session, the first MCP calls are list_agents(), then dispatch(...).
If init fails to register the MCP server (prints a warning instead of Registered MCP server), register manually:
claude mcp add-json agent-dispatch "{\"type\":\"stdio\",\"command\":\"$(which agent-dispatch)\",\"args\":[\"serve\"]}" --scope user
If test fails with a permission error (error_type: "permission"), grant tool access and re-test:
agent-dispatch update infra --allowed-tools "Bash,Read,Grep" # least privilege
# or, if the agent needs everything (see SECURITY.md for the trade-off):
agent-dispatch update infra --permission-mode bypassPermissions
When to Dispatch
Do dispatch when a task needs tools, files, or context from another project:
- Check container logs via infra agent's Portainer MCP
- Query a database via db agent's postgres MCP
- Read code or run tests in another repository
Don't dispatch when you can do it yourself — dispatching spawns a full Claude session.
MCP Tools Reference
list_agents
Lists all configured agents. Call this first to see what's available.
// Response (capability + permission fields shown only when populated)
[
{
"name": "infra",
"directory": "/home/user/projects/infra",
"description": "Infrastructure agent. MCP: portainer. Stack: Python, Docker",
"healthy": true,
"has_claude_md": true,
"has_mcp_config": true,
"mcp_servers": ["portainer", "postgres"],
"stacks": ["Python", "Docker"],
"dbs": ["Alembic"],
"capabilities": ["docker_logs", "deploy_debug"],
"risky_capabilities": ["restart_services"],
"permission_mode": "bypassPermissions",
"allowed_tools": ["Bash", "Read", "Grep"],
"typical": {"median_seconds": 143.3, "p90_seconds": 178.3, "median_cost_usd": 0.2666}
}
]
mcp_servers, stacks, and dbs are detected from the agent's project files (.mcp.json, Dockerfile, pyproject.toml, Cargo.toml, prisma/, alembic.ini, etc.) so callers can pick the right agent without dispatching a probe.
typical is measured, not declared: it comes from this agent's own recent dispatches in the usage journal and appears only after a few runs. Use it to size timeout_seconds and to know what a call will cost before you make it. It is absent when the journal is off or the agent has too little history — no data is better than a typical duration derived from two runs.
inspect_agent
Cheap detailed lookup — reads the agent's files without spawning a claude session. Returns the full config (timeout, model, budget, permission mode, allowed/disallowed tools), detected MCP/stacks/DBs, plus short previews of CLAUDE.md and README.md when present.
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | yes | Agent name from list_agents |
preview_lines | int | no | Max lines of CLAUDE.md/README.md (default 40, max 200, 0 disables) |
Use this before dispatch_async/dispatch to confirm an agent has the tools and context for your task — much cheaper than a probe dispatch.
It also carries the agent's instructions (its standing orders) and the full typical block — the trimmed one in list_agents plus dispatches, failed and the outcomes breakdown:
"typical": {
"dispatches": 24, "median_seconds": 143.3, "p90_seconds": 178.3,
"median_cost_usd": 0.2666, "fai