Agents and background runs
A mutation run takes minutes to hours. A coding agent, a script or a CI step that starts one shouldn’t have to sit on it, and shouldn’t lose it when its own session ends. A detached run goes on in the background, writes its state to disk, and every other command reads that state.
The MCP server
Section titled “The MCP server”mutato mcp is an MCP server on stdio. Add it to an agent with one line, e.g. for
Claude Code:
claude mcp add mutato -- dnx --yes dotnet-mutato mcpOn Windows, where dnx is a .cmd shim, start it through cmd:
claude mcp add mutato -- cmd /c dnx --yes dotnet-mutato mcp.
| Tool | What it does | CLI |
|---|---|---|
describe_setup |
What a run would use (targets, test projects, config), and any run in progress. Nothing is built. | mutato setup --json |
start_run |
Starts a detached run and returns its id at once. Scope: since, files, filter, or scope: "all"; with none, the working tree’s changes against the default branch. |
mutato run --detach |
run_status |
Phase, progress, time left, and the outcome in words. waitSeconds (up to 50) waits for the run to end. |
mutato status --wait |
list_survivors |
The survivors, a page at a time, in three groups. | mutato survivors --json |
get_mutant |
One mutant in full: the diff with context, the verdict and why, the covering tests with their baselines. | mutato mutant <handle> --json |
recheck |
After new tests, looks at the given handles again in a run over their files; its status gives each one’s verdict before and now. | mutato recheck <handle>... |
cancel_run |
Stops a run; the partial results stay readable. | mutato cancel |
Every tool takes an optional path, the repo directory; the default is the
directory the server started in. Runs are detached: ending the agent’s session
leaves a run going, and the next session’s server picks it up. The server only
reads and runs, and never edits code. It describes this workflow to the agent
when they connect (start narrow, wait rather than poll, treat a survivor as a
signal, not a hard rule).
Start a run in the background
Section titled “Start a run in the background”mutato run --detach # prints the run id, e.g. 20261127-142501-3fa9mutato run takes the same flags as mutato. With --detach the run starts in
its own process group, outlives the shell (or agent) that started it, and the
command returns at once with the run’s id on stdout.
With no --since, --files or --filter, on the command line or in
.mutato/config.json, a detached run mutates only the working tree’s changes
against the default branch (origin/HEAD, else origin/main, origin/master,
main or master), uncommitted edits included. So nobody starts a two-hour
whole-repo run by accident. --all widens it to the whole repo.
One run at a time per clone. Every worktree of a clone shares the lock, as they share the run history. A second start is refused and names the run already going.
Follow it
Section titled “Follow it”mutato status # the latest runmutato status <id> --wait 60 # block until it ends, or 60 s passmutato status --json # the run state, for a scriptstatus prints the phase (setup, build, baseline, scoring, then done,
failed or cancelled), the progress and the time left. Once the run has ended
it gives the outcome in words: what the exit code
means and what to do about it, such as baseline red: the tests fail with no
mutation at all … fix the failing tests first. A failed run also shows the end
of its log. A run whose process died without saying how it ended (killed, out of
memory) reads as failed, with the signal when there was one.
Read the survivors
Section titled “Read the survivors”mutato survivors # the latest run: a page of each groupmutato survivors --group survived --offset 10 --limit 10mutato survivors --files "Parser*.cs" --jsonmutato setup # what a run here would use; nothing is builtsurvivors lists the run’s mutants in three groups, a page at a time (10 per
group by default, 100 at most):
- survived: covering tests ran and all passed with the mutant active. These are the gaps a test could close.
- untrusted: verdicts Mutato doesn’t stand behind. Some were never scored, some timed out instead of failing a test, and some were decided where an earlier mutant could have filled a cache first. Don’t write tests for these.
- noCoverage: mutants no test runs at all.
Each entry gives the mutant’s handle, file:line, operator, the change on one
line (qty > 10 → qty >= 10), the containing member, and the names of the
covering tests. The handle is stable across runs: adding tests, or editing
elsewhere in the file, leaves it alone, and editing the mutant’s own lines makes
it a different mutant. The totals and the score come first.
A survivor is a signal, not a hard rule. Some mutants change the code without changing what it does (equivalent mutants), and no test can kill them; leave those alone. A test that exists only to pin an implementation detail is worse than a survivor.
setup (and setup --json) shows what a run here would use, without building
anything: the config, the targets and test projects (from the config, or
discovered), whether the tests reference Mutato.Testing, what a detached run
with no scope would mutate, and any run in progress.
Look closer, then recheck
Section titled “Look closer, then recheck”mutato mutant f43b3da04765 # the diff with context, the verdict and why, the covering testsmutato recheck f43b3da04765 89c7fbac7215 --wait 120mutant shows one mutant in full. The diff is taken from the source as it is
now, with a few lines of context. If those lines have changed since the run, it
shows the change alone and says so. The covering tests come with their
unmutated durations.
After writing tests, recheck the handles you aimed at rather than starting a
fresh run. It is a detached run over just the files those mutants are in, with
the flags and scope of the run they came from (a --since run’s recheck
stays within that change), and the run history reuses everything
nothing changed for, so it is quick. It reads .mutato/config.json as it is
then, so a config edited in between applies to the recheck too. Once it ends,
its status gives each handle’s verdict before and now:
outcome : completed: score 100% (36 killed, 0 survived, 0 with no coverage); recheck of 3: 3 now killed recheck : 3 mutant(s) from run 20261127-191504-de5f f43b3da04765 SampleLib/Maths.cs:70 survived → killed: killed by SampleLib.Tests.DiscountTests.Exactly_ten_is_not_bulkA handle the recheck has no result for is reported as gone when its own
code changed, so it is a different mutant now, and as outOfScope when its
code is as it was but the run’s scope no longer reaches it (a --since base
that has moved since can do that). A handle the recheck found somewhere other
than where it was shows both places, src/Maths.cs:70 (now src/Maths.cs:74):
adding an identical copy of a mutant above it in the same member is the one
edit elsewhere that passes its handle on to the copy. Rechecking handles from
two different runs at once is refused: each run’s handles are rechecked under
that run’s setup.
Stop it
Section titled “Stop it”mutato cancel # the run going in this clonemutato cancel <id>cancel stops a run the way Ctrl-C stops one in a terminal: it finishes the
mutants in flight and writes its partial results, which stay readable. Whatever
is still running a minute later is killed. (On Windows the run’s processes are
killed at once, and no partial report is written.)
What a run leaves on disk
Section titled “What a run leaves on disk”Each detached run has a folder, .mutato/runs/<id>/:
| File | What it holds |
|---|---|
status.json |
The run state: phase, progress, time left, scope, pid, and at the end the exit code and its meaning. Always written whole, so a reader never sees half of one. |
run.log |
Everything the run printed (what --plain prints in a terminal). |
mutation-report.html |
The report, unless --html or the config sends it elsewhere. |
results.json |
Every mutant with its handle, change, verdict and covering tests: what survivors reads. |
The folder hides itself from git. A new run deletes the oldest ended runs beyond the latest 20.