Skip to main content

Agents & Actions

MCP Tools

Spruce exposes a set of tools over the Model Context Protocol (MCP) so that agents like Claude Code can read and write artifacts without leaving their terminal session. The tools are namespaced under mcp__spruce__ and cover the same operations available through the Spruce UI.

Tool categories

Artifact tools

ToolWhat it does
artifact_getFetch an artifact by ID; returns fields + body
artifact_searchSearch by text, type, or field filters
artifact_createCreate a new artifact from a template
artifact_updateUpdate fields or replace the body
artifact_body_editTargeted string replacement in the body

Comment tools

ToolWhat it does
artifact_comment_listList comments on an artifact
artifact_comment_addAdd a top-level comment
artifact_comment_claimClaim a comment for the agent's session (stamps processingBy, fetches full thread)
artifact_comment_replyReply to an existing comment
artifact_comment_resolveMark a comment resolved

Template tools

ToolWhat it does
template_listList all templates in the project
template_getFetch a template by name or by artifact ID

The claim-first-then-reply pattern

Agents working on comments follow a specific loop:

  1. Call artifact_comment_claim with a session_id and a short note describing the work. This stamps processingBy on the comment, which the Spruce UI renders as a "being addressed" spinner with the note next to it.
  2. Do the work (edit code, run tests, etc.).
  3. Call artifact_comment_reply with the response. The claim auto-clears on reply.

This loop prevents duplicate responses when multiple agent sessions are listening, and gives the user a live indicator of what the agent is doing.

Comment origins

Every comment created via these tools is tagged with origin: 'agent'; comments created by users through the UI have origin: 'user'. The tag is set by the write path (agents can't spoof it). See Comments for the user-facing behaviour.

  • Actions — how the MCP connection gets wired up when launching an agent, plus comment forwarding via forward: [comment-added].
  • Comments — the user-facing comment system.
  • MCP Tool Reference — full tool-by-tool reference with parameters.