Skip to content

feat: add a read-only dispatch tool to the MCP server - #25

Merged
Karnaukhov-kh merged 2 commits into
mainfrom
claude/mcp-dispatch-tool-8d5bed
Oct 22, 2026
Merged

Karnaukhov-kh merged 2 commits into
mainfrom
claude/mcp-dispatch-tool-8d5bed

Conversation

@Karnaukhov-kh

@Karnaukhov-kh Karnaukhov-kh commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Why

An orchestrator that launches a step agent in the background, such as with a workflow tool that returns before the agent ends, has to copy the message from next into the launch. In a probe on October 22, 2026, the orchestrator sent the launch in the same batch as next on both dispatches, so it launched with a message it guessed before next returned. In a real loop, Fixes: carries guard errors that only Iterward holds, and a guessed message drops them.

With this change, the orchestrator passes the agent only Run: <RUN>, and the agent reads its own message from Iterward.

What changes

  • mcp/tools/dispatch/dispatch.tool.ts: a dispatch tool with one argument, run. It runs the CLI's dispatch command and returns { id, step, agent, attempt, document, openedAt, message }, with message byte for byte as next returned it. It carries readOnlyHint: true, takes no lock, and refuses with dispatch refused: other: - no open dispatch when no dispatch is open.

  • mcp/tools.ts: registers the tool after show, in the CLI's usage-line order.

  • mcp/server.ts: the initialize instructions tell an agent that got only a run path to call dispatch.

  • Specs: dispatch.tool.spec.ts covers an open dispatch (message matches next, run file unchanged), no open dispatch (a refusal), and a malformed call. server.spec.ts lists 12 tools, now one per CLI command but mcp, and adds dispatch to the read-only tools. conformance.spec.ts doesn't list or count the tools, so it's unchanged.

  • docs/mcp.md: the tool count and table, dispatch in the autoApprove list and the readOnlyHint list, a description of the tool in place of the sentence that said the server has no dispatch tool, and a section on launching an agent in the background.

  • README.md and docs/mcp.md: the .mcp.json examples run @push-based/iterward@latest instead of @VERSION. docs/mcp.md says that @latest refuses a run of an earlier minor version, and how to pin the version that started the run.

docs/cli.md, docs/protocol.md, and both READMEs don't name the MCP tool list or count, so they're unchanged.

Compatibility

The run format doesn't change, so a run that 0.4.x started continues. The feat: commit bumps 0.4.1 to 0.4.2, because nx adjusts semver bumps for a 0.x version by default.

Checks

In packages/iterward/, npm test (87 pass), npm run lint, and npm run typecheck pass.

An orchestrator that launches a step agent in the background has to copy
the message from `next` into the launch. One that sends the launch in the
same batch as `next` sends a guessed message, which drops the `Fixes:`
lines that carry guard errors.

The `dispatch` tool runs the CLI's `dispatch` command, so an agent that
gets only the run path reads its own message, byte for byte as `next`
returned it. It takes no lock, writes nothing, and refuses when no
dispatch is open. The server instructions and docs/mcp.md describe the
background launch.
The .mcp.json examples ran @Version, which a reader had to replace. They now run
@latest, and docs/mcp.md says how to pin the version that started a run, because
@latest refuses a run of an earlier minor version.
@Karnaukhov-kh
Karnaukhov-kh merged commit 2846229 into main Oct 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant