Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(mcp): board_status reads Needs-you from projectState [A9,P6]

Corey Olson58da92306a8f
diff --git a/docs/api.md b/docs/api.md
index 2e642d64..c3c21f45 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -198,11 +198,13 @@ It answers `initialize` with `protocolVersion` (the client's, when it is `2025-0
| Tool | Input schema | Mirrors | Result |
| --- | --- | --- | --- |
-| `board_status` | `{}` | `pullboard status` and `pullboard list` | the `status` document plus `items` (open and active items) and `needsYou`: `decisions` (open decisions addressed to the person), `rows` (spec rows that are `pending` or `draft`) and `holds` (held lanes) |
+| `board_status` | `{}` | `pullboard status` and `pullboard list` | the `status` document plus `items` (open and active items) and `needsYou`: the `decisions`, `holds` and `spec` fields of the view's board projection, unshaped, as the view's Needs-you reads them |
| `show_item` | `{id: integer >= 1}` | `pullboard show <id>` | the `show` document |
| `shout` | `{to: string, text: string}` | `pullboard shout <to> <text>` | the `shout` document |
| `capture_idea` | `{text: string}` | `pullboard shout coordinator "idea: <text>"` | the `shout` document; until ideas become their own kind of item, an idea is a shout to the coordinator whose text starts `idea: ` |
+`needsYou` is read-only and comes from the same projection as the local API's board state and the view: `decisions` are the open decisions addressed to the person, `holds` the held lanes, and `spec` every row of the project's spec file with its `status`, so the person's rows are those `pending` or `draft`. Building that projection reads every item and the spec file's history, so `board_status` is slower on large boards than the other tools.
+
Every input schema sets `additionalProperties: false`; an unknown or mistyped argument returns `BAD_REQUEST`. No argument names an author, a seat or a channel: the author of every move is the agent of the checkout the server runs in.
Each tool runs the CLI command it mirrors through the same engine as the terminal and the local API, with the API's move arguments, so a move records the same events and a refusal carries the CLI's own `code`, `message` and `next`. A result's `content` is one `text` part holding the versioned JSON document, which `structuredContent` repeats. A refusal is a result with `isError: true` and the versioned refusal document. A tool name the server does not offer gets JSON-RPC error `-32602` with an `UNKNOWN_TOOL` refusal in `data`.
diff --git a/src/mcp.js b/src/mcp.js
index 9088729a..411fbb0f 100644
--- a/src/mcp.js
+++ b/src/mcp.js
@@ -6,14 +6,12 @@
* terminal and the local API use, with the API's move layer (moveArgs), so a refusal reaches the
* client with the CLI's own code and next step.
*/
-import { join } from 'node:path';
-import * as store from './board.js';
-import { COORDINATOR, loadConfig } from './config.js';
-import { codeIsFromMain, repoInfo } from './git.js';
+import { COORDINATOR } from './config.js';
import { VERSION } from './help.js';
import { refusalDocument } from './json.js';
import { moveArgs } from './api-moves.js';
import { Refused } from './refused.js';
+import { projectState } from './serve.js';
/** MCP revisions this server speaks; the first is offered when a client asks for one it does not know. */
export const MCP_PROTOCOL_VERSIONS = Object.freeze(['2025-06-18', '2025-03-26', '2024-11-05']);
@@ -31,7 +29,7 @@ const PERSON_MOVE = /approv|declin|answer|sign_?off|decide|decision/u;
export const MCP_TOOLS = Object.freeze([
{
name: 'board_status',
- description: 'The board at a glance for this seat\'s agent: who you are, the open and active items, the review queue, unread shouts, and Needs-you (the person\'s open decisions, spec rows waiting for the person, held lanes). Mirrors pullboard status and pullboard list.',
+ description: 'The board at a glance for this seat\'s agent: who you are, the open and active items, the review queue, unread shouts, and needsYou: the decisions, holds and spec fields of the view\'s own board projection, as the view\'s Needs-you reads them. Mirrors pullboard status and pullboard list. It builds the full board projection, so it is slower on large boards.',
inputSchema: { type: 'object', properties: {}, additionalProperties: false },
},
{
@@ -133,19 +131,6 @@ async function runCli(runCommand, cwd, argv) {
return { status, document };
}
-/**
- * The person's calls on this board, as the view's Needs-you list counts them: decisions passed up to the
- * person and held lanes, with the spec file whose waiting rows join them. A read only; it opens the board as pullboard status does and changes nothing.
- */
-function personCalls(cwd) {
- const info = repoInfo(cwd);
- const config = loadConfig(info.root);
- const board = store.openBoard(join(info.commonDir, 'pullboard', 'board.sqlite'), undefined, { isMain: codeIsFromMain() });
- try {
- return { spec: config.spec, decisions: store.openDecisions(board, store.PERSON), holds: store.laneHolds(board) };
- } finally { store.closeBoard(board); }
-}
-
/** A tool result carrying one versioned document, flagged as an error when it is a refusal. */
function toolResult(document, isError) {
return { content: [{ type: 'text', text: JSON.stringify(document, null, 2) }], structuredContent: document, isError };
@@ -165,19 +150,14 @@ async function callTool(runCommand, cwd, name, args) {
if (status.status) return toolResult(status.document, true);
const list = await runCli(runCommand, cwd, ['list', '--json']);
if (list.status) return toolResult(list.document, true);
- const spec = await runCli(runCommand, cwd, ['spec', '--json']);
- if (spec.status) return toolResult(spec.document, true);
- const calls = personCalls(cwd);
+ // Needs-you comes from the view's own projection, unshaped and read-only: one builder, no second query.
+ const { decisions, holds, spec } = projectState(cwd);
const { version, ...summary } = status.document;
return toolResult({
version,
...summary,
items: list.document.items,
- needsYou: {
- decisions: calls.decisions,
- rows: spec.document.rows.filter((row) => row.file === calls.spec && ['pending', 'draft'].includes(row.status)),
- holds: calls.holds,
- },
+ needsYou: { decisions, holds, spec },
}, false);
}
if (name === 'show_item') {
diff --git a/test/mcp.test.js b/test/mcp.test.js
index 9575338e..94844b3d 100644
--- a/test/mcp.test.js
+++ b/test/mcp.test.js
@@ -9,6 +9,7 @@ import { test } from 'node:test';
import { pathToFileURL } from 'node:url';
import { fixtureChildMessage, runFixtureChild, runFixtureGit, startFixtureChild } from './fixture-child.js';
import { AGENT_SHELL_MARKERS, SSH_SHELL_MARKERS } from '../src/person.js';
+import { projectState } from '../src/serve.js';
const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');
const SPEC = `# MCP fixture
@@ -234,7 +235,11 @@ test('[A9,P5] an MCP client reads the board and shouts as its agent', async (t)
assert.equal(status.structuredContent.me.id, box.agent, 'status reads as the seat\'s agent');
assert.ok(status.structuredContent.items.some((item) => item.item_id === itemId && item.item_status === 'open'), 'status lists the open item');
assert.deepEqual(status.structuredContent.needsYou.decisions.map((ask) => ask.shout_id), [decisionId], 'Needs-you carries the person\'s open decision');
- assert.deepEqual(status.structuredContent.needsYou.rows.map((row) => row.id), ['G2'], 'Needs-you carries the draft row');
+ assert.ok(status.structuredContent.needsYou.spec.some((row) => row.id === 'G2' && row.status === 'draft'), 'Needs-you carries the draft row');
+ // One builder: needsYou is the view's own projection, unshaped, never a query of the tool's own.
+ const projection = JSON.parse(JSON.stringify(projectState(box.web)));
+ assert.deepEqual(status.structuredContent.needsYou, { decisions: projection.decisions, holds: projection.holds, spec: projection.spec },
+ 'needsYou is projectState\'s decisions, holds and spec for the same board');
assert.deepEqual(JSON.parse(status.content[0].text), status.structuredContent, 'the text content is the same document');
const shown = await client.call('show_item', { id: itemId });