Skip to content
MCP Five

The CrewProject #434 / 51

Build it

Twelve stages, their checkpoints, and the queue you cannot yield from inside a callback.

Project #4 copies project #3's lib/ wholesale โ€” the loop, the gate, the notebook, the report card โ€” and makes the loop recursive.

  1. Five minutes that save you a day

    Curl every server you intend to use, before designing anything around them.

    terminal
    https://learn-mcp-5-year-old.vercel.app/api/mcp        -> 200   open
    https://learn-mcp-agent-loop.vercel.app/api/toolbox    -> 401   locked
    https://learn-mcp-agent-guard.vercel.app/api/jar       -> 401   locked

    Two of three locked, by their own author, working exactly as designed.

  2. Scaffold, inherit, and read the types

    Same scaffolding gotcha, fourth time. Then read what is actually installed before writing against it.

  3. The database, and the tree

    One nullable self-reference โ€” runs.parent_run_id โ€” turns a flat list of runs into a tree, and nested replay comes almost free.

  4. The pantry: a job too big for one agent

    Sixty jars, one per tool call, ~250 tokens of report each. Nine tampered, and a rule with two clauses and an exception.

  5. Measure the ceiling BEFORE you fix it

    Do not skip this and do not do it later. If you cannot show the failure, you cannot show the fix โ€” and you might not have one.

    Checkpoint

    At 60 jars the single agent aced it, and the crew cost about the same. That is a result, not a setback โ€” the premise was wrong, and finding that out on stage 5 is the cheapest place to find it.

    At 240 jars, there is the ceiling: 0 of 36 found ยท 440,517 tokens ยท stopped at MAX_ITERATIONS, 180/240 inspected, against the crew's 36 of 36 ยท 245,948 tokens ยท ONE approval.

  6. Local tools, and the event queue

    The fiddliest twenty lines in the repo โ€” see Local tools.

    Checkpoint

    Three lanes update while the workers are working, not in a lump at the end.

  7. spawn_agent

    Multi-agent orchestration, in full, is about eight lines. The care around it is five seatbelts.

    Checkpoint

    bash
    npm run crew -- --boss
  8. The bubble: five agents, one human

    The hard part. origin, partial_results, paused_children โ€” see Five agents, one human.

  9. One drive-and-persist path

    lib/run-driver.ts โ€” the one place a run is driven and written down.

    Two code paths reaching the same feature will drift. A sub-agent gets a real row in runs through the same function the orchestrator does, which is why nested replay needed no new machinery.

  10. The comparison that decides the project

    bash
    npm run compare -- --attempts 5

    And the trap it walked into first is The measurement trap โ€” the one gotcha here worth reading even if you never build any of this.

  11. The UI, then verify and ship

    Lanes, meters, and one card. Then typecheck, lint, build, and exercise the real feature on the deployed URL.

Run it yourself

bash
npm run mcp:list         # transport โ€” 3 servers, 11 tools, no AI
npm run mcp:translate    # schemas + the gate's rules, no AI
npm run agent            # the loop, one agent
npm run approval         # THE GATE โ€” approve and deny
npm run evals            # project #3's six cases, as a regression net
npm run crew             # THE CREW โ€” workers hit the gate, the pause bubbles up
npm run compare          # delegate off vs on: pass rate AND token cost
npm run replay           # rewind, including into each sub-agent

The interesting ones:

bash
npm run crew -- --deny-all      # say no to everything, watch them adapt
npm run crew -- --single        # same job, one agent, no delegation
npm run compare -- --attempts 5 # tighten the numbers

And the regression net still passed

A regression in project #3's suite would have mattered more than any of this working:

terminal
  look-only  chain-dice-to-cookies  no-tools  gate-fires  picks-right-cipher  reads-history
SCORE: 100%   (18/18)

Six cases, three attempts each, unchanged from project #3 โ€” despite a third MCP server, four new tools, a recursive loop and a rewritten persistence path.

The ten gotchas

Project #4's appendix is the longest of the first four. The three called out above โ€” the event queue, the pantry size, the spawn cap โ€” plus the premise being wrong and the eval saying so, a backtick inside a template literal in SQL, a regex that assumed the data would never grow, create table if not exists, a Next.js route module being a bad place for helpers, the measurement trap, and git check-ignore -v still lying about negations.

All of them, with causes and fixes, are in the compendium.