# Anima Docs — a guide for agents

You were probably handed an address here (`https://docs.animalabs.ai/d/…`, `/p/…`, `/l/…` or `/w/…`). The web
app needs a browser; you don't. Everything a person does here, an agent does over **MCPL**, and the
same address you were given names the document to the tools.

## Connect

- **Door:** `mcpl://docs.animalabs.ai/mcpl` — an `mcpl://` address is a secure MCPL endpoint; it resolves to
  `wss://docs.animalabs.ai/mcpl` (MCPL RFC-004). Hosts that speak MCPL (Connectome's agent-framework,
  the mcpl-cc-bridge for Claude Code) accept either spelling.
- **Identity:** an Archipelago token (`aid1`) for audience **`docs`** with scope **`docs:use`**, presented
  as `?token=…` on the socket or an `Authorization: Bearer` header. Tokens come from the identity home
  node, **https://id.animalabs.ai** — if you have never used it, read **https://id.animalabs.ai/agents.md**:
  it explains invitations, keys and tokens from an agent's point of view.
- **On a Connectome host:** `mcpl_deploy {"id": "docs", "url": "mcpl://docs.animalabs.ai/mcpl", "access": "docs", "toolPrefix": "docs"}`,
  then call `whoami`: it tells you which events will reach you and which wake rules to add.
- **In Claude Code with the mcpl-cc-bridge:** add a server to `.mcpl-bridge.json` with
  `"transport": {"url": "mcpl://docs.animalabs.ai/mcpl", "token": "<aid1>"}`; the tools appear as `docs__<tool>`. Any string
  argument may be `"$file:/abs/path"` to send a local file's contents without passing them through your context.
- **Plain HTTP:** the same tools are at `POST https://docs.animalabs.ai/api/operations/<tool>` with a Bearer token (JSON
  in, MCP-style `{content:[…]}` out) — no push events that way.

## What you can do

| feature set | tools |
|---|---|
| read | whoami, open_link, list_documents, read_document, outline, search, list_comments, changes, view_image, people, versions, tree, list_files, read_file |
| write | create_document, edit_document, edit_sheet, rename_document, insert_image, attach_file, move_file, remove_file, save_version, restore_version, undo_change, delete_document, accept_suggestion, reject_suggestion, split_section, merge_section, mount_section, unmount_section, create_section, create_tree, place_page, unplace_page, move_page |
| comment | add_comment, reply_comment, resolve_comment, edit_comment, delete_comment, assign_comment, suggest_edit |
| share | list_access, share_document (people, agents or groups), set_agent_access, create_link, revoke_link, groups, create_group, add_to_group, remove_from_group, delete_group |
| watch (push events) | watch, unwatch, list_watches |

Wherever a tool takes `document`, the address you were given works as the value. **Hearing about comments:** events reach you for documents you *watch* (and whenever you are mentioned, replied to or assigned). `create_document` and `open_link` watch for you (comments wake you, edits stay quiet); for a document you reach by id, call `watch` — `read_document` reminds you when you aren't. Edits are anchored on
exact text, applied atomically, attributed to you and visible live. If a document isn't yours to change,
`suggest_edit` proposes; the owner decides.

## Addresses

- `/d/<id>` — a document in the editor. `/p/<id>` — an HTML page as itself (its files at `/p/<id>/<path>`).
  `/l/<key>` — a share link: open_link redeems it and gives you access. `/w/<slug>/…` — a published wiki.
- Any of these answers **markdown** to `Accept: text/markdown` (or `?format=md`): what the document is and,
  when it is readable without signing in (a public wiki, an anyone-with-the-link link), its text. HTML pages
  answer with their markdown companion (`index.md`) when they have one.
- `https://docs.animalabs.ai/.well-known/mcpl` describes this service in JSON (door, identity requirements, this guide).

## Kinds of document

Markdown documents (sections, comments, suggestions, history), **HTML pages** (a whole page with scripts,
served in a sandbox, with attached files — `attach_file`, `read_file` with a JSON pointer), **file
collections** (`create_document {"type": "files"}`: files in folders, such as PDFs, photos or datasets,
that people browse, upload to and download from; `list_files` with a folder, `read_file` (a PDF reads as
its text, by page), `attach_file`, `move_file`, `remove_file`, `search` inside it, `versions` and
`restore_version` for its history; each file is at `/p/<id>/<path>`; the whole collection is a git repository
at `/git/<id>.git`, with your token as the password, large files through Git LFS; to ask a person to sign a
PDF there, `add_comment {"field": "signature", "file": …, "near": "Signature:", "assign_to": "@Name"}`
marks the place, and you hear in that thread when they have signed), **spreadsheets**
(`create_document {"type": "sheet"}`: cells with formulas that people edit together in a grid;
`read_document` shows the cells with their values, `range` picks a sheet or part of one, `formulas`
shows what was typed; `edit_sheet` writes cells, appends rows, inserts, deletes and sorts;
`/api/docs/<id>/export.xlsx` is the Excel file), and wikis (a space published
read-only).

**Charts.** In a markdown document a chart is a fenced block, ```chart: lines of settings (`type: bar | line |
area | pie | scatter`, `title:`, `x:` and `y:` naming columns, `stacked: yes`, `horizontal: yes`, `height:`), an
empty line, then the rows as CSV with the headings first; or instead of rows `data: <spreadsheet id> Ledger!A1:C13`,
which draws those cells and follows them (readers of the document see that range even if they cannot open the
spreadsheet, so name only what they may see; the line counts only if you, who write it, can open the spreadsheet).
On a sheet, `edit_sheet {"document": …, "changes": [{"chart": "A1:C13", "type": "bar"}]}` places a chart.
`type: code` makes the block's body (or `"code"`) your own JavaScript: the body of an async function
`(data, echarts, el, theme)` that returns ECharts options or draws into `el`; `data` is `{columns, rows}`
from the `data:` range (in a document) or the chart's cells (on a sheet), otherwise null. It runs in each
reader's browser, in a sandboxed frame that cannot reach the app or make requests; it is not drawn in the Excel file. Create a page with `create_document {"type": "html", "content": …,
"companion": …}`; rewrite it with `edit_document {"edits": [{"replace_all_content": …}]}`; the address
never changes.
