Reference
Coding agents (MCP)¶
agentloop mcp runs a local Model Context Protocol
server over stdio. A coding agent that supports MCP can use it to inspect your
traces, findings, source locations and candidate changes. It uses the same APIs
as the CLI, and adds no dependencies.
These are examples for two agents that support MCP. They aren't official integrations with either product.
Or commit a .mcp.json at the repository root:
An agent skill that explains how to use the tools is in
examples/agent_skills/agentloop/SKILL.md.
Copy it into your agent's skills directory.
Tools¶
| Tool | What it returns | Writes anything |
|---|---|---|
list_traces |
JSON files under the root, or a subdirectory | No |
trace_summary |
Runtime, operation counts and models | No |
findings |
Ranked findings with their evidence | No |
patch_plan |
The dry-run patch plan, with source locations | No |
execution_ir |
The execution IR | No |
timing_sensitivity |
Simulated critical-path gains | No |
propose_transformation |
A dry-run transformation candidate with its diff | No |
execute_candidate |
The candidate validated in a temporary git worktree | Only a temporary worktree, which is then removed. Off by default. |
execute_candidate exists only when the server is started with
--allow-execution, and each call needs confirm: true. It re-proposes the
change against HEAD, runs your validation command (an argv list, no shell),
and reports accepted or rejected. Your checkout itself is never edited. The
command gets a minimal environment, without your credentials, and runs on this
machine as you: the worktree is not a sandbox. See
executing a candidate.
Safety¶
- Confined paths. Every path is relative to
--root. Absolute paths,.., and symlinks that lead outside the root are refused. - Redacted text. Model inputs and outputs recorded in traces are replaced
with
[redacted]unless you pass--include-text. - Untrusted content. Results wrap their data with an
untrusted_contentnotice. A trace can contain anything the application saw, including text written to manipulate an agent. The server never acts on trace content, and no trace content can enable execution. - Bounded work. Tool calls have time limits, can be cancelled, and are limited in number. See below for exactly what stops and what doesn't.
Time limits and cancellation¶
Each tool call has a time limit (--timeout, default 60 seconds). A client can
cancel a running call with notifications/cancelled; the call then gets no
response, as the MCP specification asks. Calls run beside the message reader,
so cancellations and other requests are read while a call runs. Every request
gets exactly one outcome: a result, an error, or, once cancelled, nothing.
What happens to the work itself depends on the tool:
| Tool | On cancellation or timeout |
|---|---|
execute_candidate |
Stopped. The validation command and the processes it started are stopped, and the temporary worktree is removed. On a timeout the result says so (validation exceeded … seconds) and includes termination: how the processes were stopped and whether they're gone (process_tree_stopped). |
| All other tools | Not interrupted. They're in-process analyses that run to completion once started. A timed-out one is reported with stoppable: false, stopped: false in structuredContent, then finishes in the background. |
How the processes are stopped:
- Linux and macOS: the validation command runs in its own process group,
which is sent SIGTERM, then SIGKILL, and checked until it's empty. A process
that leaves the group on purpose (
setsid) isn't stopped. - Windows:
taskkill /T /Fstops the command and every process it can still find from it. A process whose parent has already exited is no longer in that tree and isn't stopped.
Validation output goes to a temporary file rather than a pipe, so a process left behind can't hold up the result.
Limits¶
- At most
--max-inflightcalls (default 4) run at once. A call that was cancelled or timed out but can't be interrupted still counts until it finishes. Beyond the limit, calls are refused with a "server busy" tool error rather than queued. - Request ids must be strings or integers. An id that's still in use by a running call is refused, so a duplicate can't answer for, or cancel, another call.
- If the client stops reading the server's output, every running call is cancelled. At the end of input, running calls still finish and answer within their time limit.
Protocol¶
The server speaks JSON-RPC 2.0, one message per line on stdin and stdout. It
supports these protocol versions: 2025-06-18, 2025-03-26 and 2024-11-05.
It implements initialize, ping, tools/list and tools/call, plus the
notifications/initialized and notifications/cancelled notifications. Tool
results carry both a text block and structuredContent.