Documentation menu

For agents

The MCP tools, their JSON replies and the plan input.

On this page

Hosts start Ktesio Build as an MCP server over stdio (ktb mcp). The server has nine tools, and their schemas cost about 1,250 tokens in total. Each tool has a CLI command with the same name, which takes the same JSON and prints the same JSON. So an agent with only a shell can call ktb <tool> --json. plan reads its input on stdin.

Tools

ToolDoes
statusrepo state: host, tier models, last sync, open assumptions and questions, findings
recallrecords by id, active records by kind, text search, or a walk over links from an id
recordwrites a record and returns its id and path. Assumptions need confidence (0–1) and leash
syncupdates the index from changed files and records
packthe context for a task, cut to the tier budget. Call it before reading code
plantiers, run lines and parallel groups for a slice, and a policy for each call
verifychecks a task and commits it with trailers, then returns next
checkdrift between records and code
digestthe one screen since the last digest. Given accept or reject and an assumption id, it settles that assumption

No reply is longer than [budgets] reply tokens (2,000) unless you ask for more, for example with full or limit.

The loop

  1. pack for the work, then plan.
  2. If card is not empty: show it exactly as given, and wait for the answers. Record each answer as a decision whose subject is that call's subject, then plan again with the same slice.
  3. For a task with needs_triage, get a verdict and pass it back as triage with the same slice.
  4. Run tasks by group, following each task's run and with. Then verify the task with commit, and follow next: done, retry, escalate (to tier) or stop.
  5. When no one is there to answer, ktb run <slice> --json does step 4 headless. Its tasks come back already verified and committed.
  6. Review the slice diff with the review.lenses from the last verify. Commit any fixes with verify on the slice's last task.
  7. Finish with digest, with peek: true.

The kb-build skill encodes this loop for each host.

Plan input

{
  "intent": "int-0ke8et",
  "slice": "",
  "tasks": [
    {"goal": "Add transfer fees", "files": ["src/pay/ledger.rs"], "check": "cargo test fees",
     "depends": [], "kind": "feature", "acs": ["ac1"]}
  ],
  "calls": [
    {"text": "Who pays the fee: sender or receiver?", "confidence": 0.4, "direction": true,
     "recommend": "sender", "options": ["receiver"], "depends": [0], "tags": ["money"]}
  ],
  "triage": [{"task": 0, "tier": "deep", "effort": "high", "kind": "feature"}],
  "tokens": 1200
}
  • intent: a record id, or empty. Record the intent first if it doesn't exist yet.
  • slice: empty for a new plan, or the id from a previous plan to re-plan it.
  • depends: 0-based indexes of earlier tasks. In a call, depends lists the tasks that build on that call; empty means all of them.
  • direction: true when the call changes scope or user-facing behaviour.
  • kind: a short task kind, such as feature, fix, test, refactor, docs or rename. It's inferred from the goal when it's empty.
  • tokens: the tokens spent planning so far, when the host reports them.

Unknown fields are rejected, and the error names the rule that was broken.

Plan output

  • slice: the slice id.
  • tasks[]: each with id, goal, kind, tier, model, effort, run (subagent, exec or inline), with (the agent name or command), group, needs_triage, assumptions, decisions, tags and why.
  • calls[]: each with text, policy (assume, probe, ask or settled), cost, leash, id (the record written for it, or the decision that settles it), subject (on asks) and why.
  • card: the questions for the person, rendered so the model never formats them. It's absent when there's nothing to ask.
  • ledger: questions that didn't fit on the card.

Verify output

  • pass
  • ran[]: each with cmd, ok and ms
  • failure: the failing output, trimmed
  • flags
  • sha: the commit
  • outcome: the row id, 0 when nothing was counted
  • review: lenses and when (task or slice)
  • next
  • tier: set on escalate
  • ms

Exit codes

CodeMeaning
0ok
1a check failed
2usage error. The message says what to change
3environment problem. Run ktb doctor