En equipo Asistentes de IA (MCP)
Asistentes de IA
@rebodocs/mcp le da a un asistente las operaciones que una persona tiene en el editor, como 51 herramientas del Model Context Protocol. “Llena este contrato” o “convierte esta lista en una tabla” se hace sobre el documento real, con su composición y su formato intactos, no sobre una copia de su texto.
¿Qué camino?
Las mismas herramientas llegan a un documento de tres formas. Las dos primeras ejecutan un servidor en tu máquina; la tercera pone a Claude en tu propia aplicación.
Archivos, desde tu asistente
- Claude Desktop, Code, Cursor
- rebodocs-mcp, en tu máquina
- contract.docx
El asistente abre un .docx, lo cambia en memoria y lo guarda como DOCX, PDF o Markdown. No hace falta tener un editor abierto.
Configúralo ↓El editor que alguien tiene abierto
- Tu asistente
- rebodocs-mcp, en tu máquina
- el editor en el navegador
La persona activa “IA” en la barra de estado, y el asistente trabaja sobre lo que está mirando: cada cambio un paso para deshacer, y la vista va a él.
Configúralo ↓Claude en tu aplicación
- Un chat en tu página
- tu backend
- la API de Claude
Para todos los que usan tu aplicación, con tu clave de API. La página guarda la conversación y ejecuta las herramientas en el editor; el servidor no guarda nada.
Añádelo ↓Sé el asistente
El documento de ejemplo en el editor real, y las herramientas que llama un asistente, ejecutadas sobre él por el mismo código que ejecutan el servidor y el chat. Lo que vuelve es palabra por palabra lo que lee el asistente.
Abriendo el editor…
Los párrafos van por número, como los muestra read_document, y cada herramienta que cambia texto responde con lo que hizo: el asistente no tiene que volver a leer todo el documento tras cada paso. Un argumento erróneo vuelve como una frase simple, para que se corrija. De las 45 herramientas de un documento, 35 lo cambian y el resto leen. Las descripciones de las herramientas son lo que el servidor le dice a un asistente, en inglés.
Configúralo
Para las dos primeras formas: el servidor arranca cuando arranca tu asistente. Elige el tuyo y copia lo que necesita.
Tu asistente
Ponlo en
~/Library/Application Support/Claude/claude_desktop_config.json (en Windows, %APPDATA%\Claude\claude_desktop_config.json). Reinícialo después de cambiarlo.
{
"mcpServers": {
"rebodocs": {
"command": "npx",
"args": [
"-y",
"@rebodocs/mcp",
"--root",
"/Users/you/Documents/contracts"
]
}
}
}Viene de npm, con el motor como dependencia: no hay nada que clonar. Luego pídele al asistente: “Abre /Users/you/Documents/contracts/lease.docx y llénalo para Ana López”.
Opciones del servidor
- --root DIR
- Una carpeta de la que se pueden leer archivos y en la que se pueden escribir; se pueden dar varias. Da una: sin ella, cualquier lugar de la máquina.
- --fonts DIR
- Una carpeta donde buscar fuentes antes que en las del sistema, para componer y generar PDF.
- --port N
- Dónde se conecta el editor del navegador. 7411 por defecto, o REBODOCS_MCP_PORT.
- --no-editor
- Solo archivos: no escuchar a un editor.
- --origin URL
- Una página a la que se permite conectarse, además de localhost.
- --host ADDR
- Para escuchar a editores, y con --http a clientes, en otras máquinas. Entonces hace falta un --token de 12 caracteres o más, o REBODOCS_MCP_TOKEN.
- --http N
- Escuchar a los asistentes por HTTP en http://127.0.0.1:N/mcp (Streamable HTTP), cada uno con su propia sesión, en lugar de por la entrada y salida estándar. Con --token, un cliente lo da como “Authorization: Bearer”.
- --timeout S
- Cuántos segundos esperar a que el editor responda una herramienta: 30 por defecto.
- --editor-url URL
- La dirección de tu editor, que se le dice al asistente cuando no hay un editor conectado, para que pueda decir dónde abrirlo.
Por HTTP
Para un cliente que se conecta a un servidor en lugar de arrancarlo, o uno en otra máquina: con --http el servidor escucha en /mcp (el Streamable HTTP del protocolo), y cada cliente tiene su propia sesión, con sus propios archivos abiertos. Los editores del navegador son los mismos para todos.
# 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"El botón, en tu propio editor
El editor solo se conecta cuando la persona activa “IA”, y no lo recuerda entre recargas. Cada cosa que hace el asistente es un paso para deshacer.
// 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 } }} />Qué puede tocar un asistente
Un asistente hace lo que sus herramientas le permiten, donde el servidor se lo permite. Estos son los límites, y quién pone cada uno.
Solo las carpetas que nombras
Con --root, una ruta fuera de esas carpetas se rechaza, y se le dice al asistente por qué. Sin él, el servidor puede usar cualquier archivo que la máquina le permita.
Nada escrito hasta que guarda
Un archivo abierto se cambia en memoria. save_document lo escribe, y nunca sobre un archivo que ya existe salvo que el asistente diga overwrite; new_document no acepta una ruta que existe.
Solo esta máquina, salvo que digas
El servidor escucha en 127.0.0.1. Una página se conecta desde localhost, o desde un --origin que nombres. Para escuchar a otras máquinas (--host) no arranca sin un --token de 12 caracteres o más.
La persona lo activa
El editor solo se conecta cuando se activa “IA”, y no de nuevo tras recargar. Cada cambio es un paso para deshacer, y la vista va a él.
Sugerencias, no ediciones
Con track_changes activado, lo que cambian las herramientas queda marcado, firmado “Assistant”, para que la persona lo acepte o lo rechace.
Un camino de vuelta
En un archivo, undo vuelve atrás desde los últimos cambios, hasta 50; en el editor, cada cambio es un paso que la persona deshace. edit_document hace todas sus ediciones o ninguna.
El cliente sabe qué solo lee
Cada herramienta dice si solo lee, si hacerla de nuevo cambia más, y si puede perder trabajo: solo save_document y close_document pueden. Un cliente puede dejar correr sin preguntar las que leen.
En tu aplicación: quién, y cada cuánto
assistantRoute le pregunta a allow quién puede usarlo y le da a cada usuario perMinute pasos, distinguidos por key; la clave se queda en tu servidor, y la conversación en la página.
Todas las herramientas
Lo que el servidor le dice al asistente de cada una, leído del código de @rebodocs/mcp cuando se construyó esta página, en inglés. “Pruébalo” carga una en el editor de arriba.
Archivos
Propias del servidor: un chat en tu aplicación no tiene archivos, así que no tiene ninguna de estas.
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.
Starts an empty document, to write in and save. Gives it the path it will be saved to.
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.
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.
Forgets a file that is open, with any changes that were not saved.
Lectura
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.
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".
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.
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.
Every place a text is found, with the paragraph it is in and the words around it.
The links of the document: the text of each, where it goes and its paragraph.
The notes of the document: the id of each, who wrote it, the text it is about and what it says.
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…).
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.
Texto
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.
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.
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.
Deletes whole paragraphs, from one to another. Not for the paragraphs of a table.
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".
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.
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.
Gives paragraphs a paragraph style: a heading, a title, the normal text. get_overview lists the styles of the document.
Makes paragraphs the items of a list with bullets or with numbers, or takes them out of the list they are in.
Makes a text a link to a web page, a mail address or a telephone; or, with an empty "url", takes its link away.
Formato
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.
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.
Comentarios y control de cambios
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.
Takes a note away; the text it was about stays.
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.
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.
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.
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.
Plantillas
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.
Tablas e imágenes
Puts in a table after a paragraph, with the text of each cell. Every row must have the same number of cells.
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.
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.
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.
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.
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].
Páginas y columnas
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.
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.
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.
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.
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.
Makes the text after a paragraph start on a new page.
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.
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.
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".
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.
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.
Conservar el aspecto
Un asistente ve el texto por defecto, no cómo se ve. read_formatting se lo dice, párrafo por párrafo: estilo, alineación, sangrías, espaciado, y cada tramo con su fuente, tamaño y marcas.
Escribe un párrafo de nuevo, como en una traducción, conservando su alineación, sangrías y espaciado, y la fuente, tamaño y color que tenía la mayor parte de su texto. Dado en segmentos, las palabras que estaban en negrita o cursiva siguen así.
Con like_paragraph, los párrafos nuevos se ven como uno que ya está.
Conserva el aspecto del texto que reemplaza.
Míralo en el editor de arriba: “Cómo se ve” lee el párrafo 4, “Traduce, conservando la negrita” escribe el párrafo 10 en inglés con sus palabras en negrita y en rojo todavía así, y “Añade uno igual” pone una viñeta que coincide con las de alrededor. El chat en tu aplicación se lo dice a Claude antes de cada conversación: leer el formato antes de reescribir, y cambiar fuentes, tamaños o espaciado solo cuando se le pide.
Trabajar en un contrato
Los contratos tienen cláusulas numeradas, tablas de importes y firmas que no deben cortarse por una página. Estas herramientas son para eso, además de leer y escribir texto.
Varios cambios en una llamada, todos o ninguno: reemplazar, reescribir, insertar, borrar, estilo, formato, notas, mover una cláusula, una celda. Cada número de párrafo en ellos es el de una sola lectura, así que el asistente no vuelve a leer tras cada inserción.
Ordena los números escritos al principio de los títulos, después de poner, quitar o mover una cláusula: “Primera.”, “CLÁUSULA 3.” o “IV.”, cada uno conservado como está escrito. Lista los lugares del texto que nombran una cláusula por un número que cambió, sin cambiarlos.
Mueve un título con todo lo que tiene debajo, como arrastrarlo en el esquema: la cláusula conserva su aspecto y sus notas.
Escribe una celda por su tabla, fila y celda, vacía o no: la forma de llenar una fila recién puesta.
Cómo cae el documento en sus páginas, en palabras: un párrafo cortado por una página, un título que queda al pie de una, una última página de una línea, una tabla en dos páginas.
Con keep_together, un bloque de firmas se queda entero en una página, y pasa a la siguiente solo cuando no cabe; format_paragraphs mantiene un párrafo entero con keep_lines_together, o con el siguiente con keep_with_next.
“Varias a la vez” y “Cómo cae en páginas”, en el editor de arriba, ejecutan la primera y la última de ellas sobre el documento de ejemplo.
En tu propia aplicación
El botón “IA” llega a un servidor en la máquina de la persona. Para tener a Claude en tu aplicación, para cualquiera que la use, la página habla con tu backend, y tu backend con la API de Claude.
- 1
La persona pregunta
createAssistantChat envía la conversación hasta ahora a POST /api/assistant, en tu servidor.
- 2
Tu ruta le pregunta a Claude
assistantRoute (o assistantHandler, en Next.js) comprueba quién puede preguntar (allow) y cada cuánto (perMinute), y envía la conversación a Claude con las herramientas del documento. La respuesta vuelve a medida que Claude la escribe: una línea de JSON por cada trozo de texto y cada herramienta que pide, y la respuesta entera al final.
- 3
La página ejecuta las herramientas
Cada herramienta que pide Claude se ejecuta en el editor que la persona tiene abierto, como un paso que puede deshacer; en una sala compartida, los demás lo ven como un cambio de la propia persona.
- 4
…hasta que termina
Los resultados vuelven a Claude en el siguiente paso, hasta que no tiene nada más que hacer: 40 pasos como mucho por pregunta (maxSteps). La conversación vive en la página; el servidor no guarda nada.
En tu servidor
npm install @rebodocs/mcp, y una ruta que lleva la conversación a Claude con tu clave. Le pregunta a Claude Opus 5.5 con esfuerzo medio salvo que se dé otro model u effort, y le da a cada usuario 40 pasos por minuto (perMinute). Sin key, un usuario es la dirección de la que viene la petición, que detrás de un proxy es la misma para todos: dale el usuario de tu sesión. context le dice a Claude lo que sabe tu aplicación, después de sus instrucciones. toolSearch: true hace que Claude busque las herramientas de tablas, páginas y revisión cuando necesita una, en lugar de leerlas todas en cada paso.
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
});En la página
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 stepTu clave, tu factura. Quien ejecuta el servidor paga lo que piden las páginas abiertas. Dale a allow tu comprobación de sesión, y mantén perMinute bajo. Para verlo funcionar, npm run assistant ejecuta el demo.
Qué saber
- Los números de párrafo se mueven tras una inserción o una eliminación. edit_document hace varias ediciones con los números de una sola lectura; después de ella, o de una herramienta sola, un asistente vuelve a leer antes de usar un número viejo.
- Las longitudes en las herramientas van en centímetros y puntos, como las dice la gente; la API propia del editor va en puntos.
- Mientras se controlan los cambios, lo que cambian las herramientas también se controla, firmado “Assistant”.
- Un chat en tu aplicación no puede insertar una imagen o un membrete desde una ruta, ni comparar con un archivo: eso necesita el disco del servidor.
- read_pages dice en palabras cómo cae el texto en las páginas; no hay una imagen de una página para que un asistente la mire.
- Un cliente que cancela una llamada hace que el servidor deje de esperar al editor; un cambio que el editor ya hizo se queda, como un paso para deshacer.
- En una sala compartida, un asistente trabaja a través del editor de la persona que preguntó: los demás ven sus cambios como de esa persona, pero no la conversación.