Last Wednesday I was breaking down a cross-file refactor. The task split into five parts, three terminals open at once: Claude writing the shared types, Codex changing the call sites, omp running the dependency scan.
Forty minutes later I was tracking in a notes app who had finished. Claude on the left was stuck at a permission prompt, Codex in the middle was scrolling too fast to read, omp on the right had finished ages ago and nobody told me. Token spend got reconciled after the fact. By the time I wrapped up that night, two of the three sessions were dead, context gone.
That wasn’t “the model isn’t strong enough”. That was nobody doing the scheduling.
Problem
Opening more terminals is easy. The hard part:
- What if a subtask runs wild?
- How do you queue when all slots are full?
- How do you steer when you realize the direction is wrong mid-way?
- The main agent can’t idle while waiting for results — but dumb polling would blow up the context.
- Who’s running, where, and how much is burning — all tracked by a human.
The chaos really has three layers. Execution: who’s running, who kills the runaway, who reaps the orphaned processes. Protocol: the CLIs don’t speak to each other — some emit JSONL, some only plain text, usage field names differ completely, resume support is hit or miss. Ledger: who burned the tokens and on what, reconciled after the fact by guesswork.
The old solo-dev answer was “human scheduling”: track progress in a notes app, eyes on three screens. Fine for one task and two agents; with five subtasks, three CLIs, plus timeouts and scope changes, the human scheduler is the first thing to crash.
Approach
The agent-mcp README is clear: the point isn’t “open more agents” — it’s turning any CLI into a dispatchable, monitorable, resumable, killable work pool.
The main agent does exactly two things: split and merge.
Dispatch, waiting, steering, timeouts, queueing, resume, and downgrade all go to the control plane. Model inference still happens in each CLI’s native runtime; agent-mcp doesn’t rewrite the agent loop or lock you to a single model.
The other principle: match the model to the task.
Read-heavy exploration goes to fast models (omp / pi / grok); deep-reasoning planning goes to strong ones (claude). Cost and quality get matched on the spot, not “one model for everything”.
Three layers, one sentence each. On top, the MCP tool surface: any MCP-capable host (Claude Code, DeepSeek Harness, …) plugs in and calls. In the middle, the daemon control plane: scheduling, queueing, timeouts, the token ledger — all here. At the bottom, CLI adapters: event streams, usage, and sessions of 11 CLIs normalized into one language. A CLI not on the list just needs a JSON config — no code changes.
A Run is the only unit of execution. A Run’s lifecycle goes: queued → dispatched → running → terminated / merged / resumed. Full slots mean automatic queueing — no manual staggering. A timed-out task kills the whole process tree: SIGTERM first, a chance to exit gracefully; ignore it and SIGKILL follows, no orphaned processes left burning money in the background. Blow the token budget and it reruns at a lower tier, say from a strong model down to a fast one. session_id is the ownership boundary: your session, your responsibility, and a hung run can still resume.
From the outside, agent-mcp is a set of MCP tools, each with its own job:
estimate_complexity: grades S/M/L locally, zero tokens, no spawn — do it directly by default, split only when neededspawn_agent: dispatches a sub-agent, takes CLI / model / timeout, hands you anagent_idimmediatelywait_agent: blocks briefly until termination, returns a summary — no dumb polling, no context blowupsteer_agent: steers mid-flight — kills the current run, continues from the same nodefollowup_task: merges pending messages, triggers the next turnorchestrate_task: task graphs with dependencies — parallel where independent, ordered where not
orchestrate_task deserves a few more words. You declare dependencies as a graph: shared types first, call sites next, review last — the order lives in the graph, not in your head. Independent scans run in parallel. And merging collects only summaries, never dumping five sub-agents’ full outputs into the main context. That’s the key to keeping the context from exploding.
The constraints are practical. Don’t split everything by default. Early versions spawned a pile of sub-agents for tiny things, and coordination cost more than the task itself. That’s why the complexity gate exists: estimate_complexity judges locally, costs zero tokens — S means do it directly, M means maybe, L means split. The most underrated design in the whole system.
The adapter layer is messier than you’d think. Headless modes, event streams, resume, permission flags — every vendor has its own. Normalization is the real engineering. Wiring up a CLI that’s not on the list looks roughly like this (illustrative):
{
"name": "my-cli",
"headless": ["my-cli", "--prompt", "{prompt}"],
"stream": "jsonl",
"usage_path": "$.usage.total_tokens",
"resume": ["my-cli", "--resume", "{session_id}"]
}
The two hardest bits are always how headless mode takes a prompt and where the usage fields actually hide. JSONL-vs-plaintext is just the appetizer.
DeepSeek Harness gets native integration too: one insert patch registers all 34 tools under mcp__agentmcp__*; the daemon auto-starts if down and reconnects with exponential backoff. Plugging into Claude Code is one MCP block in settings.json (see “Try it now” at the end).
The costs deserve honesty too. A thick control plane makes debugging heavy. When something breaks you have to look at the main agent, daemon logs, and subprocesses at once — heavy for a personal project, still being trimmed. The sandbox is mostly “one policy translated into each CLI’s own flags” — not real isolation, so don’t hand it real secrets and expect a safety net. Adapter test coverage is uneven; resume on an obscure CLI may never have been battle-tested.
Status
After building it, my workflow changed: from “I watch everything myself” to “split, dispatch, wait in a loop, merge”.
A cross-file refactor: first estimate_complexity grades it L, then orchestrate_task declares dependencies — shared types first, call sites next, review last. Independent scans run in parallel. Each subtask can name a different CLI: the thinking-heavy type definitions go to claude, the grunt-work dependency scan goes to omp.
Scope crept mid-way; steer_agent narrowed it without reopening a session. Something hung; the timeout caught it, and the session could still resume. What used to mean reopening three terminals and re-explaining the requirements is now one command.
Currently v4.0.0a1: 34 MCP tools, 589 tests passing. It didn’t make me “faster, cheaper, better” — but it did free me from staring at terminals.
Limits remain. Still alpha. Adapter test coverage is uneven; the sandbox is mostly “one policy translated into each CLI’s own flags” — not real isolation; cross-vendor review in complex merges needs more mileage.
Next up: fill in adapter test coverage, enforce policy at the actual execution point, then simplify onboarding.
curl -fsSL https://raw.githubusercontent.com/37chengshan/agent-mcp/main/install.sh | bash
Main repo: 37chengshan/agent-mcp. Issues welcome — complaints too.
Try it now
Don’t just read — run it. Six steps, half an hour:
- Install. One command:
curl -fsSL https://raw.githubusercontent.com/37chengshan/agent-mcp/main/install.sh | bash - Plug it into your host. For Claude Code, add to
settings.json:
Restart the host and confirm all 34{ "mcpServers": { "agentmcp": { "command": "agent-mcp", "args": ["serve"] } } }mcp__agentmcp__*tools show up in the tool list. The daemon auto-starts if it’s down — nothing to run by hand. - Play with the complexity gate first. Take a task at hand, call
estimate_complexity, see whether it’s S, M, or L. If it’s S, don’t split — build the “don’t split by default” muscle memory early. - Dispatch your first sub-agent. Use
spawn_agentwith a fast CLI (say omp) for a read-only scan: grep a directory for TODO comments. Grab theagent_id, thenwait_agentfor the summary. Feel what “dispatch and stop watching” is like. - Run a task graph. Take a small refactor, declare two or three dependent steps with
orchestrate_task, and watch it execute in order while parallelizing the rest. - Reconcile once. After the run, check token usage: which subtask burned the most — that’s the one that gets a cheaper model next time. Half the value of a scheduling system is execution; the other half is the ledger.
FAQ
How is this different from just opening more terminals?
Terminals have no scheduler: runaway subtasks, slot queueing, mid-course correction, token reconciliation — all on a human. In agent-mcp, a Run is the only unit of execution: full slots queue automatically, timed-out tasks kill the whole process tree, blown token budgets rerun at a lower tier, and session_id draws the ownership boundary.
Does it lock me into one model?
No. Inference still happens in each CLI’s native runtime; agent-mcp doesn’t rewrite the agent loop. The principle is match-the-model-to-the-task: read-heavy exploration to fast models (omp / pi / grok), deep-reasoning planning to strong ones (claude), cost and quality matched on the spot.
Do small tasks need splitting into sub-agents too?
No. Early versions spawned a pile of sub-agents for tiny things, and coordination cost more than the task. Now there’s estimate_complexity: local S/M/L grading, zero token cost, do it directly by default, split only when needed.
My CLI isn’t one of the 11 — what then?
One JSON config plugs it in, no code changes. The adapter layer normalizes each vendor’s event streams, usage fields, and sessions; the differences get ironed out there. The two hardest bits are how headless mode takes a prompt and where usage fields hide — check those first.
Is it for me?
It’s for “long tasks, many files, multi-agent collaboration”: cross-file refactors, bulk migrations, parallel research. Not for: one-off tiny tasks (doing it directly is faster), or latency-critical interactive debugging (the control plane adds a hop). Solo-dev note on debugging cost: when something breaks you read three logs.
Is it stable now?
v4.0.0a1, still alpha. Adapter test coverage is uneven; the sandbox is currently just “one policy translated into each CLI’s own flags” — not real isolation; cross-vendor review in complex merges needs more mileage. The author says adapter coverage comes first.
The X-thread version
1/ I opened 3 agent terminals for one cross-file refactor: Claude on types, Codex on call sites, omp on the dependency scan. Forty minutes later, two sessions were dead and token spend was pure guesswork. The problem wasn’t the models — nobody was doing the scheduling.
2/ ① The main agent does exactly two things: split and merge. Dispatch, waiting, timeouts, queueing, resume — all go to the control plane. The human-staring-at-screens approach crashes the moment you scale.
3/ ② A Run is the only unit of execution. Full slots queue automatically; timed-out tasks kill the whole process tree — no orphaned processes burning money in the background.
4/ ③ The main agent can’t dumb-poll while waiting — polling output blows up the context. Short blocking wait, summary on return. Summaries only, never full text is the first rule of keeping context alive.
5/ ④ Direction wrong mid-way?
steer_agentkills the current run and continues from the same node — no session restart. Steer first when requirements change; every restart is tokens down the drain.
6/ ⑤ Blown token budget? Rerun at a lower tier. Read-heavy exploration to fast models, deep-reasoning planning to strong ones — cost and quality matched on the spot, no “one model for the whole family”.
7/ ⑥ Don’t split by default.
estimate_complexitygrades S/M/L locally at zero token cost; do it directly by default. Coordination overhead costing more than the task was the bloody lesson of the early versions.
8/ ⑦ Dependent work goes through
orchestrate_taskas a task graph: parallel where independent, ordered where not. The order lives in the graph, not in your head.
9/ ⑧ The adapter layer normalizes event streams, usage, and sessions across 11 CLIs; anything else plugs in with one JSON config. Messiest two bits: headless mode and usage fields.
10/ ⑨
session_idis the ownership boundary. The sandbox is currently “one policy translated into each CLI’s own flags” — not real isolation. Still on the way.
11/ ⑩ The price of a thick control plane: when something breaks you read three logs — main agent, daemon, subprocesses. Get the full loop working on small tasks before production-grade refactors.
12/ Currently v4.0.0a1: 34 MCP tools, 589 tests passing. It didn’t make me “faster, cheaper, better” — but it freed me from staring at terminals. Full version 👇 https://citygenius-blog.pages.dev/article/project-agent-mcp
上周三,我在拆一个跨文件重构。任务拆成五份,三个终端同时开:Claude 写公共类型,Codex 改调用方,omp 跑依赖扫描。
四十分钟后,我在备忘录里记谁跑完了。左边 Claude 卡在权限确认,中间 Codex 输出刷得看不清,右边 omp 早就跑完,但没人告诉我。token 花了多少,事后对账。那天晚上收工时,三个会话里有两个已经废了,上下文全丢。
这不是「模型不够强」。这是没有人做调度。
问题
多开几个终端很简单。难的是:
- 子任务跑飞了怎么办?
- 槽位满了怎么排队?
- 中途发现方向错了怎么插话?
- 主 Agent 等结果时不能空转,也不能傻轮询把上下文撑爆。
- 谁在跑、跑哪了、烧了多少,全靠人盯。
混乱其实有三层。执行层:谁在跑、跑飞了谁负责杀、杀不干净的孤儿进程谁收。协议层:各家 CLI 互不相通,有的吐 JSONL,有的只吐纯文本,usage 字段名完全不同,resume 有的支持有的不支持。账本层:token 谁烧的、花在哪,事后对账全靠猜。
个人开发者以前的解法是「人肉调度」:备忘录记进度,眼睛盯三块屏幕。一个任务、两个 agent 还行;五个子任务、三个 CLI、再加上超时和改需求,这套人肉系统第一个崩。
做法
agent-mcp 的 README 写得很清楚——核心不是「多开几个 Agent」,而是把任意 CLI 收成一个可派发、可监控、可续接、可终止的工作池。
主 Agent 只做两件事:拆解和汇合。
派发、等待、插话、超时、排队、续接、降档,全部交给控制面。模型推理仍发生在各家 CLI 原生 runtime 里;agent-mcp 不重写 agent loop,也不锁死单一模型。
另一个原则是:按任务匹配底座。
读密集探索丢给快底座(omp / pi / grok),深推理规划丢给强底座(claude)。成本与质量现场匹配,而不是「全家都用同一个模型」。
三层架构,一句话讲清。 最上面是 MCP 工具面:任何支持 MCP 的宿主(Claude Code、DeepSeek Harness 等)挂上就能调。中间是 daemon 控制面:调度、排队、超时、token 账本全在这儿。最下面是 CLI 适配器:把 11 款 CLI 的事件流、usage、session 归一化成同一套语言。不在列表里的 CLI,写一份 JSON 配置也能接,不用改代码。
Run 是唯一的执行单位。 一个 Run 的生命周期走:排队 → 派发 → 运行 → 终止/汇合/续接。槽位满了自动排队,不用你手动错峰。任务超时直接终止整棵进程树——先 SIGTERM,给个体面退出的机会;不听话就 SIGKILL,不留孤儿进程在后台烧钱。token 预算超了可以降档重跑,比如从强模型切到快模型再跑一遍。session_id 是所有权边界:谁的会话谁负责,跑挂了还能 resume 接着来。
对外 agent-mcp 是一组 MCP 工具,常用的几件各有分工:
estimate_complexity:本地判 S/M/L,零 token,不 spawn——默认直接做,按需才拆spawn_agent:派发子 Agent,指定 CLI / 模型 / 超时,马上拿回agent_idwait_agent:短阻塞等终止态,返回摘要——不傻轮询,上下文不爆炸steer_agent:中途插话,终止当前 run,在同一节点接着跑followup_task:合并挂起消息,触发下一 turnorchestrate_task:有依赖的任务图,无依赖并行,有依赖按序
orchestrate_task 值得多说两句。它让你把依赖声明成一张图:先改公共类型,再改调用方,最后 review——顺序写死在图里,不靠人记。无依赖的扫描并行跑。汇合时只收摘要,不把五个子 agent 的全文输出倒进主上下文,这是保住上下文不爆炸的关键。
约束很实际。不要默认什么都拆。 我早期版本遇到小事也 spawn 一堆子 Agent,协调开销比任务本身还大。后来才有复杂度分级门:estimate_complexity 在本地做判断,不花一个 token;S 直接做,M 看情况,L 才拆。这扇门是整套系统里最被低估的设计。
适配层比想象脏。 headless 模式、事件流、resume、权限参数,每家一套。归一化才是真正的工程量。接一个不在列表里的 CLI,大概长这样(示意):
{
"name": "my-cli",
"headless": ["my-cli", "--prompt", "{prompt}"],
"stream": "jsonl",
"usage_path": "$.usage.total_tokens",
"resume": ["my-cli", "--resume", "{session_id}"]
}
最难啃的两块永远是 headless 怎么喂 prompt,以及 usage 字段到底藏在哪。JSONL 和纯文本只是开胃菜。
DeepSeek Harness 也做了原生接入:一行 insert patch,34 个工具以 mcp__agentmcp__* 全量注册;daemon 未起自动拉起,断线指数退避重连。挂到 Claude Code 上也简单,settings.json 里加一段 MCP 配置即可(见文末「现在就能动手」)。
代价也要说在前面。控制面做厚了,调试会变重。 出问题时要同时看主 Agent、daemon 日志、子进程三处,对个人项目偏重,还在砍。沙箱目前主要是「统一策略翻译到各 CLI 自己的参数」,不是真隔离——真密钥别指望它兜底。适配器实测率也不均匀,冷门 CLI 的 resume 可能还没被真实踩过。
现状
写完之后,我的工作流变了:以前是「我自己盯」,现在是「拆完、派出去、循环 wait、汇合」。
一次跨文件重构:先 estimate_complexity 判成 L,再 orchestrate_task 声明依赖——先改公共类型,再改调用方,最后 review。无依赖的扫描并行跑。每个子任务可以指定不同 CLI:类型定义这种要动脑的给 claude,依赖扫描这种体力活给 omp。
中途范围写大了,steer_agent 收窄,不用重开会话。跑挂了,超时兜住,session 还能 resume。以前这种事故=重开三个终端+重讲一遍需求,现在=一条命令。
当前 v4.0.0a1:34 个 MCP 工具,589 个测试通过。它没有让我「多快好省」,但确实把我从盯终端里解放出来了。
局限仍在。项目仍是 alpha。适配器实测率不均匀;沙箱目前主要是「统一策略翻译到各 CLI 自己的参数」,不是真隔离;跨厂商审查在复杂合并场景还要再踩。
下一步优先补适配器实测、把策略真正拦在执行点上,再简化上手路径。
curl -fsSL https://raw.githubusercontent.com/37chengshan/agent-mcp/main/install.sh | bash
主仓库:37chengshan/agent-mcp。欢迎提 issue,也欢迎直接骂。
现在就能动手
别光看,跑起来。六步,半小时:
- 装上。 一行命令:
curl -fsSL https://raw.githubusercontent.com/37chengshan/agent-mcp/main/install.sh | bash - 挂到你的宿主。 Claude Code 的话,在
settings.json里加:
重启宿主,确认 34 个{ "mcpServers": { "agentmcp": { "command": "agent-mcp", "args": ["serve"] } } }mcp__agentmcp__*工具出现在工具列表里。daemon 没起会自动拉起,不用手动跑。 - 先玩复杂度门。 找个手头任务,调
estimate_complexity,看它是 S、M 还是 L。S 就别拆了——先建立「默认不拆」的肌肉记忆。 - 派第一个子 agent。 用
spawn_agent指定一个快 CLI(比如 omp)去跑个只读扫描:扫某个目录的 TODO 注释。拿到agent_id,再用wait_agent收摘要。感受一下「派出去就不用盯」。 - 跑一张任务图。 找个小重构,用
orchestrate_task声明两三个有依赖的步骤,看它按序执行、并行加速。 - 对一次账。 跑完去看 token 用量:哪个子任务最烧钱,下次就给它换更便宜的底座。调度系统的价值,一半在执行,一半在账本。
常见问题
跟直接多开几个终端有什么区别?
多开终端没人调度:子任务跑飞、槽位排队、中途改方向、token 对账全靠人盯。agent-mcp 里 Run 是唯一执行单位,槽位满了自动排队,任务超时会终止整棵进程树,token 预算超了可以降档重跑,session_id 划清所有权边界。
它会锁死我用某个模型吗?
不会。模型推理仍发生在各家 CLI 原生 runtime 里,agent-mcp 不重写 agent loop。原则是按任务匹配底座:读密集探索丢给快底座(omp / pi / grok),深推理规划丢给强底座(claude),成本与质量现场匹配。
小任务也要拆成子 Agent 吗?
不要。作者早期版本小事也 spawn 一堆子 Agent,结果协调开销比任务本身还大。现在有 estimate_complexity:本地判断 S/M/L,零 token 消耗,默认直接做,按需才拆。
我用的 CLI 不在那 11 款里怎么办?
写一份 JSON 配置就能接,不用改代码。适配器层负责把各家的事件流、usage 字段、session 归一化,差异由它抹平。最难啃的是 headless 喂 prompt 的方式和 usage 字段的位置,先看这两处。
它适合我吗?
适合「长任务、多文件、多 agent 协作」的场景:跨文件重构、批量迁移、并行调研。不适合:一次性小任务(直接做更快)、对延迟极度敏感的交互式调试(控制面多一层)。个人项目注意调试成本:出问题要看三处日志。
现在稳定吗?
v4.0.0a1,还是 alpha。适配器实测率不均匀;沙箱目前只是”统一策略翻译到各 CLI 自己的参数”,不是真隔离;复杂合并场景的跨厂商审查还要再踩。作者说下一步先补适配器实测。
本篇的 X 速览版
1/ 我同时开了 3 个 Agent 终端做跨文件重构:Claude 写类型、Codex 改调用方、omp 扫依赖。40 分钟后,2 个会话废了,token 花了多少全靠猜。问题不在模型——在于没人做调度。
2/ ① 主 Agent 只做两件事:拆解,汇合。派发、等待、超时、排队、续接,全部丢给控制面。人肉盯屏的那套,规模一上来就崩。
3/ ② Run 是唯一的执行单位。槽位满了自动排队,任务超时直接砍掉整棵进程树,不留孤儿进程在后台烧钱。
4/ ③ 主 Agent 等结果时不能傻轮询——轮询输出会把上下文撑爆。短阻塞 wait,回来只带摘要。只传摘要不传全文,是保住上下文的第一铁律。
5/ ④ 中途发现方向错了?
steer_agent终止当前 run,在同一个节点接着跑,不用重开会话。需求一变先 steer 别重来,省的都是 token。
6/ ⑤ token 预算超了可以降档重跑。读密集的探索丢给快模型,深推理的规划丢给强模型——成本和质量现场匹配,不搞”全家一个模型”。
7/ ⑥ 默认不要拆。
estimate_complexity本地判 S/M/L,零 token,默认直接做。协调开销比任务本身还大,是早期版本血的教训。
8/ ⑦ 有依赖的任务用
orchestrate_task声明任务图:无依赖并行,有依赖按序。顺序写死在图里,不靠人记。
9/ ⑧ 适配器层把 11 款 CLI 的事件流、用量、会话归一化;不在列表里的写份 JSON 配置就能接。最脏的两块:headless 模式和 usage 字段。
10/ ⑨
session_id是所有权边界。沙箱目前只是”统一策略翻译成各 CLI 自己的参数”,还不是真隔离——这块还在路上。
11/ ⑩ 做厚控制面的代价:出问题要同时看主 Agent、daemon 日志、子进程三处。先在小任务上跑通全链路,再上生产级重构。
12/ 当前 v4.0.0a1:34 个 MCP 工具、589 个测试通过。它没让我”多快好省”,但把我从盯终端里解放出来了。完整版 👇 https://citygenius-blog.pages.dev/article/project-agent-mcp