Repository navigation
Your agent runs the team: start, watch, wait for and stop local workers through MCP - #56
Merged
Merged
Conversation
This was referenced Nov 28, 2026
…cal workers - factory-mcp (as the supervisor, root) gets factory_start_worker, factory_workers, factory_wait and factory_stop_worker, plus MCP instructions that teach the agent how to run a team. A worker's own connection (--actor) explains its job instead and cannot start workers. - A local worker runs claude -p or codex exec in the background, bound to its agent. Between turns its runner waits for the board at no model cost and wakes it when there is something new (a review, findings to fix); it ends when nothing assigned to it is left open, after 30 turns, or on an error. Records and output are kept in <board>.workers/. - factory.workers (LocalWorkers) does the same from code. - Claude Code started from inside a Claude session drops that session's settings (Claude Code refuses to nest) but keeps the person's login. - Fixed: Claude Code read a lite worker's prompt as an MCP config file, because --mcp-config takes several values; the prompt now comes first. - scripts/local-team-smoke.mjs runs a real builder and reviewer through the MCP tools, scripted or led by a real Claude Code from a plain request.
flujo-app
force-pushed
the
lead-worker-tools
branch
from
November 28, 2026 16:12
9f5ed67 to
9977879
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #52, on top of #55. Covers item 6 of #46 (a FACTORY MCP server for the supervisor) for workers on this computer; fleets come later.
The agent you already use (Claude Code, Codex, any MCP client) can now run a team through
factory-mcp: create it, assign the work, start each worker, wait for news, read the result, stop workers. Nobody has to write code.What changes
factory-mcp(only when it runs as the supervisor,root):factory_start_worker {agentId, provider: claude|codex, instructions?, cwd?, model?, endpointFile?}starts one agent as its ownclaude -porcodex execin the background, bound to that agent.factory_workersshows each worker's state and its last steps, read from its output.factory_wait {seconds}returns as soon as a task or worker changes, so the agent does not have to poll or sleep.factory_stop_workerstops a worker and everything it started.<board>.workers/.ANTHROPIC_API_KEY,CLAUDE_CODE_OAUTH_TOKEN,CLAUDE_CONFIG_DIR). A Codex worker uses the normal Codex login with--ignore-user-config.factory.workers(LocalWorkers):start,list,get,stop.--mcp-configtakes several values and Claude Code read the prompt as a config file ("MCP config file not found"). The prompt now comes first.Checked for real
scripts/local-team-smoke.mjs(npm run smoke:local-team) runs a builder and a reviewer through the MCP tools only, on this Windows PC:That last run showed that Claude Code does not hand its own login to the MCP servers it starts, so the guide explains how to pass one (
claude mcp add factory -e CLAUDE_CODE_OAUTH_TOKEN=... -- factory-mcp team.sqlite), which the third run used. The records are in #57 (evidence/local-team-20261128.json).Also checked: Claude Code 2.1.289 on Windows starts the installed
factory-mcpfrom the packed tarball, with and withoutcmd /c, and sees the new tools.Tests
test/local-workers.test.mjs(new, in the CI list, and its MCP test also runs against the installed package): headless commands and argument order; nested-session sign-in; built-in instructions; reading Claude Code and Codex output; a worker started in the background, bound to its agent, with the session's settings left out; a waiting worker woken by a hand-in and ended by acceptance; stopping a worker and its program; a program that cannot start; only the supervisor's connection can start workers, andfactory_waitreturns on a change.Local checks (Windows and Linux, as in
public-sdk.yml)Commit
bf340d9(the same files as this branch after rebasing onto main with #54; checked by comparing the git trees), from a cleangit -c core.autocrlf=false archivesnapshot with a cleannpm cieach time. Linux ran in disposablenode:*-bookworm-slimDocker containers as thenodeuser.All four combinations passed.