agent-worker-mcp
# agent-worker-mcp
An MCP server that lets one main agent, such as Claude Code, give work to the agent CLIs signed in on the same machine: Codex CLI, Claude Code, and the Antigravity CLI (`agy`).
The main agent opens a worker session, sends it a task, and gets the finished job back. With Claude Code, the job comes back by itself as a task notification. The server runs on your machine, next to the CLIs and their sign-ins. It never runs in Docker.
## What it does
- **Same tools for every CLI.** It gives the main agent one set of tools for all three CLIs:
- `catalog`, `create`, `send`, `steer`, `queue`, `interrupt`, `status`, `wait`, `result`, `list`, `fork`, `archive`, `unarchive`, `delete`, and `prune`;
- with Claude Code as the client, also `assign` and `watch`, which return a finished job as an MCP task.
- **Model and effort per session.**
- A session opens with a model and an effort level, checked against the list the CLI itself reports, and keeps them until it ends.
- A family name such as `sonnet`, `opus`, `sol`, or `neon` opens the newest model of that family.
- **Routing table.** `routing.yaml` holds a routing table for coding, office, research, writing, teaching, business, law, marketing, and other work. Each route has a primary and a fallback runtime, model, and effort. The main agent reads it through `catalog` and moves to the fallback itself.
- **Sessions belong to their main session.** Each worker session belongs to the main session that opened it, so two main sessions in one repository do not steer each other's workers.
- **Sub-agents.** A job waits for the sub-agents its worker starts. `subagents: false` in `workers.yaml` stops a worker from starting them.
- **Idle processes.** An idle CLI process closes after `RUNTIME_IDLE` seconds, and its session resumes on the next job.
## Quick start
You install the server once per machine, then set up each repository where a main agent should use it. These are the short steps. [The setup guide](docs/setup.md) explains each one and adds a checksum check and a load check.
1. Install the server from a release into `~/.local/share/agent-worker-mcp`:
```bash
mkdir -p ~/.local/share/agent-worker-mcp && cd ~/.local/share/agent-worker-mcp
gh release download v0.1.0 -R phamviet86/agent-worker-mcp -p 'agent-worker-mcp-0.1.0.tar.gz'
tar -xzf agent-worker-mcp-0.1.0.tar.gz --strip-components=1 && rm agent-worker-mcp-0.1.0.tar.gz
python3.12 -m venv .venv
PIP_CACHE_DIR=$(mktemp -d) .venv/bin/pip install -e .
```
2. In the root of a repository, give it its own copy of `workers.yaml`:
```bash
mkdir -p .claude && cp ~/.local/share/agent-worker-mcp/workers.yaml .claude/workers.yaml
```
3. In the same folder, register the server for that repository only:
```bash
claude mcp add --scope local workers -e 'PYTHONPATH=${HOME}/.local/share/agent-worker-mcp' -e "WORKERS_FILE=$PWD/.claude/workers.yaml" -e 'WORKER_OWNER=${CLAUDE_CODE_HOST_SESSION_ID:-}' -e WORKERS_DISABLED=claude -- '${HOME}/.local/share/agent-worker-mcp/.venv/bin/python' -m gateway.server
```
4. Run `claude mcp get workers` in the repository. It shows `Status: ✔ Connected`.
Then start a new Claude Code session in the repository and ask it to give a task to a worker, as [the usage guide](docs/usage.md) shows.
## Example
You write to the main agent in plain words, for example:
```text
Ask a codex worker to review the changes in src/ for bugs, and tell me what it finds.
```
The main agent calls `catalog`, picks the route for code review, gives the task to a worker with `assign`, and reports the worker's answer when the job ends.
## Documentation
- [Setup guide](docs/setup.md): install, update, and remove the server, set up a repository, and every setting.
- [Usage guide](docs/usage.md): give work to workers, manage sessions, let a worker edit files, and fix common problems.
- [AGENTS.md](AGENTS.md): the layout of the code and how to add a runtime for another CLI.
## Requirements
- macOS or Linux with Python 3.12.
- At least one of these CLIs, installed and signed in: Codex CLI (`codex`), Claude Code (`claude`), or the Antigravity CLI (`agy`).
- The GitHub CLI (`gh`), to download a release.
Tested on macOS with Python 3.12, Codex CLI 0.174.0, Claude Code 2.1.337, and agy 1.5.25.
## Security
- **Your sign-ins.** The workers run under your own CLI sign-ins and quotas.
- **Writing workers.** Give a worker `workspace-write` and `approvals: allow` only for a repository you trust it to change.
- **Local only.** The HTTP transport binds to `127.0.0.1` and has no authentication of its own. Do not expose it to a network.
- **No vendor files.** The server never reads or writes the CLIs' own session files. It drives each CLI through its documented interface: the Codex App Server, the Claude Agent SDK, or ACP.
## Development
- Set up: `python3.12 -m venv .venv`, then `.venv/bin/pip install -e '.[test]'`.
- Lint: `.venv/bin/ruff check .`
- Tests with stub and fake CLIs: `.venv/bin/pytest --basetemp=.pytest-tmp`
- Live test of one CLI: `LIVE_RUNTIME=codex .venv/bin/pytest --basetemp=.pytest-tmp -m live tests/test_codex.py`. The same works for `claude` and `antigravity`. It uses the lowest effort and deletes the sessions it made.
- Claude Code calling the server end to end: `bash tests/agent.sh`.
## License
MIT. See `LICENSE`.
TDQS
Scored across 17 tools
Most tools target a distinct resource+action (create session, fork session, interrupt job, result of job), and the descriptions do real work separating near-pairs like `send` (start now, refuse when busy) vs `queue` (run after prior jobs) vs `assign` (blocking convenience wrapper). The remaining soft spots are `wait` vs `watch` (both return a job when it ends, differing only in blocking vs background delivery) and the trio of job-starting verbs, which an agent could plausibly misselect at first glance.
Every name is a single lowercase word with no case mixing, giving a predictable, readable surface. There is a mild verb/noun split — actions (`send`, `steer`, `fork`, `prune`) alongside state/object nouns (`status`, `result`, `list`, `catalog`) — but the convention is stable enough that no name is surprising.
At 17 tools this sits at the upper edge of comfortable, but each one maps to a real lifecycle operation (session CRUD, job control, discovery, cleanup). Nothing looks like a redundant alias, though a few pairs (wait/watch, archive/unarchive) inflate the count beyond the strictly minimal set.
The surface covers session lifecycle (create/fork/archive/unarchive/delete/prune), job lifecycle (send/queue/steer/interrupt/status/result/wait/watch), and discovery via `catalog`, so there are no dead ends for the core workflow. Gaps are minor but real: there is no way to remove or inspect individual queued jobs (interrupt leaves them queued), and no operation to read a running job's partial output beyond steering it.