# Agents and MCP

Agents prepare, edit and send documents through task-sized tools; people sign, and decide in a window in the chat.


## Connect {#connect}

**The quickest way is Eggent.** [Start Eggent with Monoclan](https://cloud.eggent.ai/?lang=ru&role=monoclan&utm_source=monoclan&utm_medium=docs): Eggent makes a workspace and connects this server itself; you only sign in to Monoclan when it asks.

The MCP server is at `https://api.monoclan.ru/mcp` (Streamable HTTP). Authenticate with an API key as a Bearer token; through MCP a key always acts as an **agent**: it can do everything except sign or see signing links.

```json
{ "mcpServers": { "monoclan": { "url": "https://api.monoclan.ru/mcp", "headers": { "Authorization": "Bearer sk_live_…" } } } }
```

Or connect the agent by signing in: give the address with no key and the client opens Monoclan's sign-in (a password or the company's SSO) — the agent then acts as that member, with their roles. See [Workspace and people](@team#agents).

A person in several workspaces connects their agent once: it creates new documents in the workspace chosen at sign-in, and works on a document waiting for them in any of their workspaces with the roles they have there. A workspace they are not in stays closed to it.

## Tools {#tools}

| Tool | Does |
| --- | --- |
| `create_document` | from Markdown, a file or a template, with parties and data |
| `create_documents` | up to 50 documents in one call (a batch from one template, each with its own data and parties); answers one line per document, so a whole batch fits the agent's context |
| `get_document` | shows the person the document's card: status, parties, fields, and for a draft what still stands between it and sending |
| `read_document` | the same for the agent alone, with the text as blocks with their ids; a long document comes in pages of about 20,000 characters (`from` = the next block, or `blocks` = the ids wanted), each block whole; a table comes by rows, each cell with its own block id |
| `edit_document` | precise edits by block id (`replace_text`, `replace`, `insert_after`, `delete`); one table cell changes by its own id (`replace_text` or `replace`), and Word's table formatting stays; a paragraph replaced by one paragraph keeps its id, so later operations in the same edit still find it; `replace_text` finds text as `read_document` shows it: a field as `{{key}}`, and any spaces in `find` match a tab or line break |
| `download_document` | the file for your person: PDF, or Word as it will be signed (conditions applied, values in the text); `editable: true` gives a draft's Word file with every variant and the fields as content controls, to edit and bring back with `upload_version` |
| `fill_fields` | set field values |
| `set_parties` | add a signer or a copy recipient |
| `send_document`, `remind_signers`, `unsend_document`, `void_document`, `copy_document` | the document's life |
| `delete_document`, `archive_documents` | move documents to the [archive](@documents#archive) (and back); an agent never deletes for good — a person does |
| `get_template`, `show_template`, `edit_template`, `publish_template_version`, `duplicate_template`, `delete_template` | read a template with its versions; show it to your person as a card, changing nothing in it; edit it through its working draft; publish the next version when your person says so; copy it; archive it |
| `search` | [search](@documents#search) documents and templates: names, text, field values, counterparty, recipients; one line per hit with the words in context |
| `list_documents`, `document_groups`, `list_templates` | the [list](@documents#list) with filters (stage, template, counterparty, words, field values, archive), sorting and columns; counts by counterparty, template or field; templates |
| `rename`, `set_counterparty` | a new name for a document or template; a document's counterparty |
| `get_guide` | how to do a job by Monoclan's rules: one Word file to a template, several to one, fields, conditions |
| `get_upload_link`, `upload_file`, `create_template`, `define_field` | a user's Word file or photos in (by curl to one-time links when the agent has a terminal, several files with one command); a reusable template out; a decision field (placed later by a marker, by key or label, it keeps its type and options) |
| `list_versions`, `compare_versions`, `restore_version` | every edit is a version: who, what, why; a comparison shows the changed words with a few around them and comes in pages (`skip`) |
| `paragraph_history`, `changes_since` | one clause through the versions; what approvers changed since it went out to them |
| `find_people`, `set_workflow`, `my_tasks` | colleagues from the directory, a workflow of steps of approvers and signers, what waits for your person |
| `get_review`, `add_comment`, `suggest_edit`, `decide_suggestion`, `resolve_comment` | discussion: comments and suggested edits |
| `start_negotiation`, `get_negotiation`, `propose_edit`, `decide_proposal`, `pass_turn`, `agree_negotiation`, `stop_negotiation` | [negotiation](@collaboration#negotiation) with the other side in turns: points to accept, reject or counter, your own changes, passing the turn, agreeing; given a negotiation link (`…/n/ng_…`) as `link`, the agent acts for the other side |
| `return_with_edits` | the approver's side: a document waiting for your person's approval goes back to its author as a draft, with exact edits as suggestions and the reason |
| `api_request` | anything else in the API, except browser routes |

## The document window {#window}

In hosts that draw MCP Apps (Claude, ChatGPT, Eggent), document tools show a window under the call: a draft as an approval card the person can send from or review in full, a sent document as its live status. A template's working draft is never sent: its card has no Send, and opened, its bar publishes the template's next version. The window gets a short-lived session in the tool result's `_meta`, which the model does not see; it is never a signing session.

The window tells the model what the person sees (`ui/update-model-context`), so "add Ivan as a second signer" acts on the document on screen, and says what the person did (`ui/message`).


**Who "you" are.** The agent always knows whose behalf it acts on: the server tells it at connection (the member, their name and email), and in every tool answer the party who is that person (the same member, or the same email) carries `your_person: true`, with a line naming them. So the agent says "you approve", "then you sign", and never routes a step to its own person as to a colleague. The window and the app do the same for the person looking: their party is marked `you` in the session view and shown as «Name (you)» in the route, the status and the signing links.
## Telling your agent {#inbox}

Each member can have their own agent told when a document waits for them to approve or sign, and what happens to the documents they sent: approved, returned with edits, signed, declined, completed, and when the other side of a negotiation answered or both sides agreed. Set it in Settings → Tell my agent, or with `PUT /v2/me/agent-inbox`. Nobody is told about what they did themselves.

**Eggent.** Give the workspace address (`https://name.cloud.eggent.ai`), its API token (Eggent: Settings → API) and, if you like, a project by name or id. Each document gets one chat in that project (`monoclan:<document id>`): the agent is asked, in your language, to read the document, say what it is about and what deserves attention, and to send it back with exact edits if asked. It never approves or signs: only the person does. The token is stored sealed.

**Any other agent.** A webhook gets a signed JSON, verified like ordinary [webhooks](@webhooks#signatures):

```json
{
  "object": "agent_notification",
  "id": "evt_…",
  "type": "party.notified",
  "text": "A document is waiting for your approval…",
  "document": { "id": "doc_…", "name": "Service agreement", "status": "open", "url": "https://…" },
  "member": "mem_…",
  "created": 1790000000
}
```

`text` is written for a model; pass it to your agent as the next message. Deliveries are retried for about an hour (20 s, 1 min, 5 min, 15 min, 1 h). `POST /v2/me/agent-inbox/test` sends a check now and says whether it got through.

## Agent keys {#keys}

Mark a key as an agent key when you create it (`agent: true`), or let MCP do it. Agent keys can only create agent keys, cannot create signing sessions, and appear in the history as "the agent on behalf of your account". Restrict them further with `permissions` and `allowed_recipient_domains`.
