RebodocsDocs
Start3
What is Rebodocs
Getting started
Demos to run
Put it in your app8
React component
Headless: your own UI
A complete interface
Without a framework
Only to read: the viewer
Styling and Tailwind
Phones and touch
Accessibility
Documents8
Templates and variables
On a server: DOCX and PDF
Documents in an S3 bucket
Letterheads
Versions
Tracked changes
Fonts
Languages
Together2
Real-time collaboration
AI assistants (MCP)
Reference5
Packages
Components and hooks
Editor API
How it works
Status and roadmap
↑↓ to move↵ to openEsc to close26 pages

Together AI assistants (MCP)

AI assistants

@rebodocs/mcp gives an assistant the operations a person has in the editor, as 51 tools of the Model Context Protocol. “Fill this contract” or “turn this list into a table” is done on the real document, its layout and formatting intact, not on a copy of its text.

tip: be the assistant below, no API key needed
Start here

Which way?

The same tools reach a document three ways. The first two run a server on your machine; the third puts Claude in your own application.

Files, from your assistant

  1. Claude Desktop, Code, Cursor
  2. rebodocs-mcp, on your machine
  3. contract.docx

The assistant opens a .docx, changes it in memory and saves it as DOCX, PDF or Markdown. No editor needs to be open.

Set it up ↓

The editor someone has open

  1. Your assistant
  2. rebodocs-mcp, on your machine
  3. the editor in the browser

The person switches on “AI” in the status bar, and the assistant works on what they are looking at: each change a step to undo, the view going to it.

Set it up ↓

Claude in your application

  1. A chat in your page
  2. your backend
  3. the Claude API

For everyone who uses your application, with your API key. The page holds the conversation and runs the tools on the editor; the server keeps nothing.

Add it ↓
Live

Be the assistant

The sample document in the real editor, and the tools an assistant calls, run on it by the same code the server and the chat run. What comes back is word for word what the assistant reads.

Opening the editor…

Paragraphs go by number, as read_document shows them, and every tool that changes text answers with what it did: the assistant does not have to read the whole document again after each step. A wrong argument comes back as a plain sentence, for it to correct itself. Of the 45 tools of a document, 35 change it and the rest read. The descriptions of the tools are what the server tells an assistant, in English.

Your machine

Set it up

For the first two ways: the server starts when your assistant does. Choose yours, and copy what it needs.

Your assistant

Put it in

~/Library/Application Support/Claude/claude_desktop_config.json (on Windows, %APPDATA%\Claude\claude_desktop_config.json). Restart it after changing it.

{
  "mcpServers": {
    "rebodocs": {
      "command": "npx",
      "args": [
        "-y",
        "@rebodocs/mcp",
        "--root",
        "/Users/you/Documents/contracts"
      ]
    }
  }
}

It comes from npm, with the engine as its dependency: there is nothing to clone. Then ask the assistant: “Open /Users/you/Documents/contracts/lease.docx and fill it for Ana López”.

Options of the server

--root DIR
A folder files may be read from and written to; several can be given. Give one: without, anywhere on the machine.
--fonts DIR
A folder to look for fonts in before the system’s, to lay out and make PDFs.
--port N
Where the editor in the browser connects. 7411 by default, or REBODOCS_MCP_PORT.
--no-editor
Files only: do not listen for an editor.
--origin URL
A page allowed to connect, besides localhost.
--host ADDR
To listen for editors, and with --http for clients, on other machines. A --token of 12 characters or more is then required, or REBODOCS_MCP_TOKEN.
--http N
Listen for assistants over HTTP at http://127.0.0.1:N/mcp (Streamable HTTP), each with a session of its own, instead of over standard input and output. With --token, a client gives it as “Authorization: Bearer”.
--timeout S
How many seconds to wait for the editor to answer a tool: 30 by default.
--editor-url URL
The address of your editor, told to the assistant when no editor is connected, so it can say where to open it.

Over HTTP

For a client that connects to a server instead of starting one, or one on another machine: with --http the server listens at /mcp (the protocol’s Streamable HTTP), and each client has a session of its own, with its own open files. The editors in the browser are the same for all of them.

# The server, listening for assistants at http://127.0.0.1:7412/mcp
npx -y @rebodocs/mcp --root /path/to/documents --http 7412

# Claude Code, pointed at it
claude mcp add --transport http rebodocs http://127.0.0.1:7412/mcp

# From another machine: --host and a --token of 12 characters or more,
# which the client gives as "Authorization: Bearer <token>"
npx -y @rebodocs/mcp --root /srv/documents --http 7412 --host 0.0.0.0 --token "$REBODOCS_MCP_TOKEN"

The button, in your own editor

The editor connects only when the person switches “AI” on, and does not remember it between reloads. Each thing the assistant does is one step to undo.

// The “AI” button, for a server on the person's machine
<DocsEditor features={{ assistant: true }} />

// …or one on another machine, started with --host and --token
<DocsEditor features={{ assistant: { url: 'http://10.0.0.5:7411', token } }} />
Safety

What an assistant may touch

An assistant does what its tools let it, where the server lets it. These are the limits, and who sets each.

Only the folders you name

With --root, a path outside those folders is refused, and the assistant is told why. Without it, the server may use any file the machine lets it.

Nothing written until it saves

An opened file is changed in memory. save_document writes it, and never over a file that is there unless the assistant says overwrite; new_document will not take a path that exists.

Only this machine, unless you say

The server listens on 127.0.0.1. A page connects from localhost, or from an --origin you name. To listen for other machines (--host) it will not start without a --token of 12 characters or more.

The person switches it on

The editor connects only when “AI” is switched on, and not again after a reload. Each change is a step to undo, and the view goes to it.

Suggestions, not edits

With track_changes on, what the tools change stays marked, signed “Assistant”, for the person to accept or reject.

A way back

On a file, undo goes back from the last changes, up to 50; in the editor, each change is a step the person undoes. edit_document makes all its edits or none.

The client knows what only reads

Each tool says whether it only reads, whether doing it again changes more, and whether it can lose work: only save_document and close_document can. A client can let the reading ones run without asking.

In your application: who, and how often

assistantRoute asks allow who may use it and gives each user perMinute steps, told apart by key; the key stays on your server, and the conversation in the page.

Reference

Every tool

What the server tells the assistant about each, read from the source of @rebodocs/mcp when this page was built. “Try it” loads one in the editor above.

Files

The server’s own: a chat in your application has no files, so it has none of these.

open_document

Opens a Word file (.docx) to read it and change it. It is kept in memory: nothing is written until save_document. Gives its overview.

new_document

Starts an empty document, to write in and save. Gives it the path it will be saved to.

save_document

Writes a document to a file: Word (.docx), PDF (.pdf) or Markdown (.md), by the ending of the path. A DOCX that was opened keeps everything that was not changed exactly as it was. It does not write over a file that is there unless "overwrite" is true.

undo

Undoes the last changes the tools made to a file that is open, one at a time or several: the way back from a mistake without opening the file again and losing the rest. Up to 50 changes. In the editor in the browser, each change is a step the person undoes there.

The documents that can be worked on now: the files that are open, with whether each has changes not saved, and whether an editor is connected.

close_document

Forgets a file that is open, with any changes that were not saved.

Reading

get_overviewreads

A summary of the document: how long it is, its headings with the paragraph each is at, its template variables, its notes and its paragraph styles. Start here.

read_documentreadsheader, footer, notes too

The text of the document, one paragraph a line, each with its number in brackets and, in parentheses, its style and its table cell when it has them. A long document comes in parts: ask for the next with "from".

read_formattingreadsheader, footer, notes too

How paragraphs look: for each, its style, alignment, indents, the room before and after it and its line spacing; then each stretch of its text that looks different, with its font, its size and whether it is bold, italic, underlined or coloured. Read it before rewriting or adding text that has to look like what is there.

read_pagesreads

How the document falls on its pages, as it prints: for each page, the paragraphs on it, how it starts and ends and how much room is left at its foot; and what may want mending: a paragraph cut by the end of a page, a heading left at the foot of one with its text on the next, a page with only a line or two, a table that runs over pages, a page with nothing on it. Read it after changes that move text, before a document goes out.

find_textreadsheader, footer, notes too

Every place a text is found, with the paragraph it is in and the words around it.

list_notesreads

The notes of the document: the id of each, who wrote it, the text it is about and what it says.

list_variablesreads

The template variables of the document, written between double braces: the name of each, how many times it is used and the formats it is given (capitals, a date, money…).

compare_documentsreadsserver only: reads a file

What changed between this document and another version of it in a .docx file ("path"): the paragraphs put in, taken out and changed, of the text and of its headers, footers, notes at the foot of the page and text boxes, and the notes on the text (as add_note makes), with what was taken out as [-…-] and what was put in as {+…+}. Tracked changes are compared as if accepted, as Word does. By default the file is the earlier version; with "file_is" "later", it is the later one.

Text

replace_textchangesheader, footer, notes too

Puts a text in place of another, in the formatting of what was there: its font, its size and its marks. The text to find has to be inside one paragraph. An empty "replace" deletes it. To write a whole paragraph anew, as in a translation, rewrite_paragraph keeps more of its look.

rewrite_paragraphchangesheader, footer, notes too

Writes the whole text of a paragraph anew, as to translate it or say it otherwise, and keeps how it looks: its style, alignment, indents and spacing, and the font, size and colour most of its text has. Words that were set apart (bold, italic…) are kept so by giving the text in "segments". A paragraph with a picture is changed with replace_text instead.

insert_paragraphschangesheader, footer, notes too

Writes new paragraphs after a paragraph. Each has its text and, when wanted, a style (a heading, for one) or a list. With "like_paragraph" a new one looks like a paragraph that is there: its alignment, indents, spacing, list, and the font, size and colour of most of its text. Text between double braces, like {{cliente}}, is a template variable.

delete_paragraphschangesheader, footer, notes too

Deletes whole paragraphs, from one to another. Not for the paragraphs of a table.

edit_documentchanges

Makes several changes in one go, each as the tool it names would make it, and all of them or none. Every paragraph number in them is the one read_document showed before the first edit: the numbers do not move as the edits before insert or delete paragraphs, so there is no need to read again between them. A text to find is looked for as the document is when its edit comes. Each edit is an object with "tool" (replace_text, rewrite_paragraph, insert_paragraphs, delete_paragraphs, set_style, set_list, format_text, format_paragraphs, set_link, add_note, insert_page_break, move_section, set_cell_text, renumber_clauses) and the arguments of that tool beside it. The text of the document only: for a header or a footer, use each tool alone with "area".

move_sectionchanges

Moves a heading and everything under it, down to the next heading of its level or above (a clause with its text, a chapter with its clauses), to another place, as dragging it in the outline of the editor does. The paragraphs keep their look, their notes and their pictures. After it, renumber_clauses puts the numbers of the headings in order.

renumber_clauseschanges

Puts in order the numbers written at the start of the headings of clauses, after one was put in, taken out or moved: "Primera.", "Segunda."… in words, "CLÁUSULA 3.", or "IV.", each kept as it is written (its capitals, "Primera" or "Primero", "Décima Primera" or "Undécima"). The headings of one series are those that begin the same way and have the same style; the longest is renumbered, or the one of "paragraph". It says the places of the text that name a clause by its number ("según la cláusula Tercera"), for you to check: it does not change them.

set_stylechangesheader, footer, notes too

Gives paragraphs a paragraph style: a heading, a title, the normal text. get_overview lists the styles of the document.

set_listchangesheader, footer, notes too

Makes paragraphs the items of a list with bullets or with numbers, or takes them out of the list they are in.

Formatting

format_textchangesheader, footer, notes too

Changes how a text looks: its font, its size, bold, italic, underlined, struck through, its colour or the highlight behind it. The text is one found by "find", or whole paragraphs, from "from" to "to". Give only what is to change.

format_paragraphschangesheader, footer, notes too

Changes how paragraphs sit on the page: their alignment, indents, the room before and after them, their line spacing, their tab stops, and whether they keep with the next one. Give only what is to change.

Comments and tracked changes

add_notechanges

Puts a note on a text: a comment in the margin, as in Word, that does not change the document. The way to review a document, or to ask about something in it.

remove_notechanges

Takes a note away; the text it was about stays.

track_changeschanges

Switches tracked changes on or off, as Word's "Track changes". While on, every change made to the text, by any tool, stays marked for a person to accept or reject: what was put in as {+…+} and what was taken out as [-…-] in read_document.

list_changesreads

The tracked changes of the document, numbered: who made each, whether it put text in, took it out, moved it or changed its formatting, the text, and the paragraph it is in. Text one person put in and another took out is two changes. accept_changes and reject_changes take these numbers.

accept_changeschanges

Accepts tracked changes: what was put in stays, unmarked, and what was taken out goes. With "changes", the ones of those numbers in list_changes; with "author", all of that person's; without either, all of them. A move is accepted whole.

reject_changeschanges

Rejects tracked changes: what was put in goes, and what was taken out comes back. With "changes", the ones of those numbers in list_changes; with "author", all of that person's; without either, all of them. A move is rejected whole.

Templates

fill_variableschanges

Puts a value in place of each template variable that is given one, everywhere in the document (its headers, footers, notes and text boxes too), in the format the variable asks for, and writes out each block given one: {{#name}} … {{/name}} is repeated for each item of a list (a row of a table, paragraphs, or text), kept for true and taken out for false; {{^name}} … {{/name}} the other way round. Dates go as YYYY-MM-DD and numbers plain (1234.5): the format writes them out. Variables and blocks with no value stay as they are.

Tables and pictures

insert_tablechangesheader, footer, notes too

Puts in a table after a paragraph, with the text of each cell. Every row must have the same number of cells.

edit_tablechangesheader, footer, notes too

Changes the shape or the look of a table that is there. "paragraph" is any paragraph of the cell to act on (read_document says which cell each is in). Actions: insert_row_above, insert_row_below, insert_column_left, insert_column_right, delete_row, delete_column, merge_cells (from "paragraph" to "to_paragraph"), split_cell (undoes a merge), set_column_widths (with "widths_cm", one for each column), set_row_height (with "height_cm", 0 for as tall as it holds, and "exact"), header_row_on and header_row_off (the rows down to this one repeat at the top of each page), align_cells_top, align_cells_center, align_cells_bottom, text_level, text_up and text_down (the text of the cells set level, or vertically to read from the bottom up or from the top down; its lines are as long as the row is tall), shade_cells (with "shade"), cell_lines (with "line_style", "line_width_pt" and "line_color"; "line_style" none takes them away), show_borders, hide_borders (the whole table), keep_together (the whole table on one page, as a block of signatures should be: no row is cut, and each row stays with the next), allow_split (undoes it) and delete_table. The actions on cells take "to_paragraph" for several. The text of a cell is changed with replace_text and insert_paragraphs.

set_cell_textchangesheader, footer, notes too

Writes the text of a cell of a table, by its table, row and cell, as read_document shows them ("table 1, row 2, cell 3"): what the cell had goes, empty or not, and the text takes the look most of it had. A new line in "text" starts another paragraph in the cell. The way to fill the cells of a row just put in.

insert_signatureschanges

Puts in a block of signatures after a paragraph: side by side, each with its title (such as ASESOR and CLIENTE), a line to sign on and the name under it.

insert_imagechangesheader, footer, notes tooserver only: reads a file

Puts a picture from a file (PNG, JPEG or GIF) in a paragraph of its own after a paragraph. It goes at its own size, or as wide as the text when it is wider, unless "width_cm" says otherwise.

edit_imagechangesheader, footer, notes too

Changes a picture that is in the document: "resize" it (with "width_cm"; its height follows), "move" it to a paragraph of its own after another (with "after_paragraph"), "align" the paragraph it is in (with "align"), "describe" it for whoever cannot see it (with "description", what a screen reader says; empty takes it away), or "delete" it. read_document shows a picture as [image], or [image: its description].

Pages and columns

set_page_setupchanges

Changes the size of the paper, its orientation, or its margins; and, for one section of a document of several, whether it has a header and footer of its own and whether its first page has its own. Give only what is to change. Without "section", the page of every section changes.

set_letterheadchangesserver only: reads a file

Gives the document a letterhead: a picture from a file (PNG, JPEG or GIF), stretched over the whole page behind the text of every page, in place of the one it had. For a PNG, the top and bottom margins grow to clear what it prints there. With "remove", takes it away; the rest of the header stays. get_overview says whether the document has one.

set_columnschanges

Sets text in columns, as a newsletter: one column, two, three, with a line between them or not. With "from" and "to" only those paragraphs go in columns, in a section of their own on the same page; with "paragraph" alone, the whole section that paragraph is in.

insert_column_breakchanges

Makes the text from a place start at the top of the next column, in a section set in columns: before a text found with "find", or at the start of a paragraph.

set_page_numberchanges

Puts the number of the page in the header or the footer of every page, moves it, changes how it reads, or takes it away.

insert_page_breakchanges

Makes the text after a paragraph start on a new page.

insert_footnotechanges

Puts a note at the foot of the page: its number goes in the text right after a text found with "find" (or at the end of paragraph "at_paragraph"), and the note says "text". Notes are numbered by where they are in the text.

insert_endnotechanges

Puts a note at the end of the document, after its text (or at the end of its section, when the document puts them there): its number (i, ii, iii) goes in the text right after a text found with "find" (or at the end of paragraph "at_paragraph"), and the note says "text". Notes at the end are numbered by where they are in the text, apart from those at the foot of the page.

insert_text_boxchanges

Puts a text box in: a box with a thin black line, anchored to a paragraph (at the end of "after_paragraph"; 1 when left out), at the left of the column, with the text of that paragraph going round it. It is as tall as its text. Its text is "text"; each line of it a paragraph. Change it later with area "textbox".

insert_table_of_contentschanges

Puts in a table of contents after a paragraph: the headings of the document, each with its page and a link to it. A document has one.

update_table_of_contentschanges

Writes the table of contents again from the headings and the pages the document has now. Do it after changing headings, or text that moves them to other pages.

Good to know

Keeping the look

An assistant sees the text by default, not how it looks. read_formatting tells it, paragraph by paragraph: style, alignment, indents, spacing, and each stretch with its font, size and marks.

rewrite_paragraph

Writes a paragraph anew, as in a translation, keeping its alignment, indents and spacing, and the font, size and colour most of its text had. Given in segments, the words that were bold or italic stay so.

insert_paragraphs

With like_paragraph, new paragraphs look like one that is there.

replace_text

Keeps the look of the text it replaces.

See it in the editor above: “How it looks” reads paragraph 4, “Translate, keeping the bold” writes paragraph 10 in Spanish with its bold and red words still so, and “Add one like it” puts in a bullet that matches the ones around it. The chat in your application tells Claude so before every conversation: read the formatting before rewriting, and change fonts, sizes or spacing only when asked.

Good to know

Working on a contract

Contracts have numbered clauses, tables of amounts and signatures that must not be cut by a page. These tools are for that, besides reading and writing text.

edit_document

Several changes in one call, all or none: replace, rewrite, insert, delete, style, format, notes, moving a clause, a cell. Every paragraph number in them is the one of a single reading, so the assistant does not read again after each insertion.

renumber_clauses

Puts in order the numbers written at the start of the headings, after a clause was put in, taken out or moved: “Primera.”, “CLÁUSULA 3.” or “IV.”, each kept as written. It lists the places of the text that name a clause by a number that changed, without changing them.

move_section

Moves a heading with everything under it, as dragging it in the outline does: the clause keeps its look and its notes.

set_cell_text

Writes a cell by its table, row and cell, empty or not: the way to fill a row just put in.

read_pages

How the document falls on its pages, in words: a paragraph cut by a page, a heading left at the foot of one, a last page of a line, a table over two pages.

edit_table

With keep_together, a block of signatures stays whole on one page, and goes to the next only when it does not fit; format_paragraphs keeps a paragraph whole with keep_lines_together, or with the next with keep_with_next.

“Several at once” and “How it falls on pages”, in the editor above, run the first and the last of them on the sample document.

Your application

In your own application

The “AI” button reaches a server on the person’s machine. To have Claude in your application, for anyone who uses it, the page talks to your backend, and your backend to the Claude API.

  1. 1

    The person asks

    createAssistantChat sends the conversation so far to POST /api/assistant, on your server.

  2. 2

    Your route asks Claude

    assistantRoute (or assistantHandler, in Next.js) checks who may ask (allow) and how often (perMinute), and sends the conversation to Claude with the tools of the document. The answer comes back as Claude writes it: a line of JSON for each piece of text and each tool it asks for, and the whole answer at the end.

  3. 3

    The page runs the tools

    Each tool Claude asks for is run on the editor the person has open, as a step they can undo; in a shared room, the others see it as the person’s own change.

  4. 4

    …until it is done

    The results go back to Claude in the next step, until it has nothing more to do: 40 steps at most for one question (maxSteps). The conversation lives in the page; the server keeps nothing.

On your server

npm install @rebodocs/mcp, and a route that takes the conversation to Claude with your key. It asks Claude Opus 5.5 at medium effort unless given another model or effort, and gives each user 40 steps a minute (perMinute). Without key, a user is the address the request comes from, which behind a proxy is the same for everyone: give it the user of your session. context tells Claude what your application knows, after its instructions. toolSearch: true has Claude search for the tools of tables, pages and reviewing when it needs one, instead of reading all of them on every step.

import { assistantHandler, assistantRoute } from '@rebodocs/mcp/claude';

// ANTHROPIC_API_KEY in the environment.
// Next.js: app/api/assistant/route.ts
export const POST = assistantHandler({
  allow: async (request) => !!(await sessionOf(request)),
  key: async (request) => (await sessionOf(request))!.userId,  // perMinute counts per user
  context: async (request) => `The adviser is ${(await sessionOf(request))!.name}.`,
});

// A server of Node's own: answers POST /api/assistant.
const assistant = assistantRoute({ allow: (request) => isSignedIn(request) });
http.createServer(async (request, response) => {
  if (await assistant(request, response)) return;
  // …the rest of your server
});

In the page

import { createAssistantChat } from '@rebodocs/react';

const chat = createAssistantChat(handle.editor, { onChange: redraw });
await chat.send('Translate the document into English, keeping its format.');

chat.entries;   // what to show: the person, Claude, each tool it used
chat.busy;      // true while it works; chat.stop() ends it after this step

Your key, your bill. Whoever runs the server pays for what open pages ask. Give allow your session check, and keep perMinute low. To see it working, npm run assistant runs the demo.

Limits

What to know

  • Paragraph numbers move after an insertion or a deletion. edit_document makes several edits in the numbers of one reading; after it, or after one tool alone, an assistant reads again before using an old number.
  • Lengths in the tools are in centimetres and points, as people say them; the editor’s own API is in points.
  • While changes are tracked, what the tools change is tracked too, signed “Assistant”.
  • A chat in your application cannot insert a picture or a letterhead from a path, or compare with a file: those need the server’s disk.
  • read_pages says how the text falls on the pages in words; there is no picture of a page for an assistant to look at.
  • A client that cancels a call stops the server waiting for the editor; a change the editor already made stays, as a step to undo.
  • In a shared room, an assistant works through the editor of the person who asked: the others see its changes as that person’s, but not the conversation.