> For the complete documentation index, see [llms.txt](https://stemma.sh/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stemma.sh/docs/guides/use-with-an-agent.md). Agents can also search and read this documentation through its [MCP server](https://stemma.sh/docs/~gitbook/mcp).

# Use Stemma with an agent

Use this guide when you want an MCP-capable agent to inspect and edit Word documents through a path-based local server. Stemma does not upload the document to a Stemma-operated service. The MCP client or its configured model provider may receive selected document content through tool calls; consult the client's data policy.

The default MCP profile exposes five tools:

`open_docx`, `inspect_docx`, `execute_plan`, `verify_docx`, and `save_docx`.

## 1. Register the server

Released npm packages include prebuilt binaries for Linux, macOS, and Windows. For Claude Code, open the narrowest directory containing the documents and media the agent needs, then register Stemma privately in that project:

```bash
cd /path/to/documents
claude mcp add --scope local stemma -- npx -y @stemma-sh/mcp
claude mcp list
```

The list should show Stemma as connected. Claude Code supplies its stable project directory to the local server, and Stemma automatically confines file access to it. To use a different directory, append `--workspace-root /absolute/path/to/documents` after `@stemma-sh/mcp`.

For a project-scoped configuration with an explicit document boundary, use:

```json
{
  "mcpServers": {
    "stemma": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@stemma-sh/mcp",
        "--workspace-root",
        "/absolute/path/to/documents"
      ]
    }
  }
}
```

Tool paths cannot escape the workspace root. This is an application boundary, not an operating-system sandbox against a hostile process running as the same user.

## 2. Ask for one bounded task

For example:

> Open `agreement.docx`. Replace exactly one occurrence of “30 days” with “45 days” as a tracked change by “Approved Reviewer”. Preview the plan, apply it, verify the result, and save it as `agreement-redline.docx`.

The intended tool sequence is:

1. `open_docx` returns a document handle, compact index, and exact input identity.
2. `inspect_docx` locates and reads only the relevant block.
3. `execute_plan` previews the explicit edit, then applies the same plan.
4. `verify_docx` checks tracked-only change, untouched content, existing revisions, and validation.
5. `save_docx` reruns the session audit, commits a new output path, and reports the audit verdict: `pass`, or `needs_review` with the finding counts.

The explicit verification step lets you inspect and remediate the evidence before delivery. Saving refuses only bytes the package gate rejects; the audit verdict is the agent's to act on: check the save receipt's `verdict.status`, and on `needs_review` inspect with `verify_docx` and fix or disclose each finding. The source is never overwritten. An existing destination is refused.

## 3. Review what was saved

A successful save returns the output byte count and SHA-256. Open the redline in Word and confirm that accepting the change produces the intended text and rejecting it restores the original text.

For exact tool arguments and receipts, see the [MCP core reference](https://stemma.sh/docs/reference/mcp.md). The optional 31-tool expert surface is documented separately in the [MCP advanced reference](https://stemma.sh/docs/reference/mcp-advanced.md).

If registration, workspace access, or saving fails, see [Troubleshooting](https://stemma.sh/docs/help/troubleshooting.md).

When one instruction must produce several mutually dependent outputs, use a declared task instead of treating each save as independent success. See [Verify a multi-document task delivery](https://stemma.sh/docs/guides/verify-task-delivery.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://stemma.sh/docs/guides/use-with-an-agent.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
