Collate

December 1, 2026 - 5 min read

Giving coding agents eyes in your diff viewer with MCP

When a coding agent edits six files in ten seconds, the bottleneck shifts from writing code to reviewing it. Most workflows still force a clumsy dance: scan a wall of terminal output, copy file paths and line numbers into chat, explain what looks wrong, and repeat.

Collate turns that into a shared workspace. Instead of keeping your diff viewer blind to your agent, every Collate window exposes a local control socket and a built-in Model Context Protocol server via collate --mcp.

One local socket per window

In src/control.rs, each running Collate window binds a Unix domain socket named by its process ID inside a user-only (0o700) directory: ~/Library/Application Support/Collate/control/<pid>.sock on macOS and $XDG_RUNTIME_DIR/collate/ on Linux.

Requests and responses are newline-delimited JSON objects dispatched onto the UI thread with a timeout (ANSWER_WITHIN = 15s) so a busy diff never wedges an agent. When you launch collate --mcp, it bridges standard-input MCP tool calls to whichever open window matches the agent's working directory (or a specified repo or window ID), automatically pruning stale socket files from windows that exited unexpectedly.

Respecting the agent's context budget

Dumping 90,000 lines of generated lockfile diff into an LLM context window is slow and counterproductive. The control protocol caps broad queries explicitly: collate_state returns up to FILES_CAP = 400 file summaries, and collate_diff cuts full-patch output at DIFF_CAP = 200_000 bytes with an instruction to request one file by path.

That nudges agents to work the way human reviewers do: inspect state first, switch views (all, staged, unstaged, branch, history) with collate_show, pull patches one file at a time, and move your viewport with collate_open_file and collate_select as they walk you through a change.

Comments anchored to code, not fragile line numbers

Both you and an agent can attach comments to diff lines. In src/diff/state.rs, each comment stores an Anchor containing the file path, side, line number, and the exact line text:

pub struct Anchor {
    pub path: String,
    pub side: Side,
    pub line: u32,
    pub text: String,
}

Because the anchor remembers the line's content, comments follow the code when edits above shift line numbers around. Inside Collate, pressing i on selected lines sends your comment straight to the Agent pane running Claude Code alongside the diff - and as soon as the agent saves an edit, FSEvents updates the diff in milliseconds.

Safe boundaries by design

The socket directory uses 0o700 permissions specifically because Collate can stage, commit, discard, and push. The collate skill and MCP instructions separate low-risk navigation from irreversible actions:

  • Free to run: reading state or diffs, switching views, scrolling to lines, selecting ranges, and leaving review comments.
  • Human-gated: commits, pushes, pulls, uncommits, undos, stashes, and discards require asking first, and destructive commands like discard open a native confirmation dialog inside the window that an agent leaves for you to answer.

To connect Claude Code or another MCP client in under a minute, follow the Agents and MCP setup guide.