Skip to content

Library, MCP, and REST

Every user-facing action is an operation in src/ops/. The CLI, MCP server, and UI call the same functions (ADR-0002).

Programmatic API

The published package exports ops:

ts
import { withProject, briefOf, lint, nextReady } from "pilotbook";

const ctx = withProject(); // or withProject("/path/to/repo")
const { text } = briefOf(ctx, "TASK-001");
const result = lint(ctx);
const ready = nextReady(ctx);

withProject(cwd?) loads config + the markdown index. Types ship next to the JS (dist/ops/index.d.ts). Prefer the CLI in agents; use the library when you are embedding Pilotbook in another tool.

Useful names: createItem, updateItem, verifyItem, analyzeGraph, profileOf, similarItems, groundDemand, generateSkill, parseTypeFilter, instructionsOverview, syncNotion, notionCatalog, bindNotion, listSkills, skillOf. Errors are PilotbookError with code, optional fix, and status (404 → CLI exit 2). generateSkill is the only op that may call an LLM; inject fetch in tests.

MCP tools

pb mcp — JSON-RPC stdio, protocol 2024-11-05, tools only.

ToolInputs
lint
briefid, budget?
next
statusid?
searchq, type? (comma-separated)
similarq, type?
profile
groundq
generateskill, title, demand
list_items
get_itemid
create_itemtype, title, epic?, story?
update_itemid, data?, body?
delete_itemid
explainid
verifyid, force?
schema
promoteid, to, title, epic?, dryRun?
bumpid
impactid
analyze
convergeid, dryRun?
splitid, dryRun?, epic?
rejectid, reason
clarifyid, answers?
instructions— (returns { router, skills })
skillname
synccatalog?, bind?, init?, to?, from?, dryRun?

Results are text (JSON-stringified objects). See Agents for Cursor config.

REST (local UI)

pb ui serves static files from the package ui/ folder and these routes on 127.0.0.1. Not a public API.

MethodPathOp
GET/api/schemaschemaOf
GET/api/itemslistItems
GET/api/lintlint
GET/api/nextnextReady
GET/api/statuslistReady
GET/api/status/:idstatusOf
GET/api/search?q=&type=searchGraph (type is optional, comma-separated)
GET/api/brief/:idbriefOf (includes markdown)
GET/api/graph.dotgraphDot
GET/api/notionnotionCatalog
PUT/api/notionbindNotion ({ databases: { epic: idOrUrl, … } })
GET/api/eventsSSE { type: "reload" } on disk change
POST/api/boardwriteBoard
POST/api/itemscreateItem
POST/api/intakecreate idea + clarifyItem
POST/api/items/:id/clarifyclarifyItem / applyClarifications
GET/api/items/:idgetItem
PATCH/api/items/:idupdateItem
DELETE/api/items/:iddeleteItem

Errors: { error, code?, fix? } with HTTP 400 or 404.

Surface split

CapabilityCLIMCPREST
init, board, graph, ui, export, seed, manifest, hook, completionsyesnoboard + graph.dot only
list/get/update/delete item, schemano*yesyes
similar, profile, ground, generateyesyesno
brief, lint, next, search, verify, …yesyesmost reads + create/clarify

*CLI has pb new / pb verify rather than generic get/update. Edit markdown in git or use MCP/UI to patch frontmatter.

Released under the MIT License.