Overview

Let a model read and edit DOCX: comments, tracked changes, redlining. Run against a live editor, headless in Node, or over MCP.

@eigenpal/docx-editor-agents lets a language model read and edit a Word document: pull out paragraphs, leave comments, suggest tracked changes, apply formatting. The same tools run in three places: a live editor in the browser, a headless reviewer on the server, or an MCP server. You point them at whatever model you already run; the tool definitions are plain JSON Schema, with adapters for the Vercel AI SDK, OpenAI-style function calling, React, and Vue.

npm install @eigenpal/docx-editor-agents

Integration shapes

1. Live editor panel. Tool calls execute against a <DocxEditor> running in the user's browser. Comments and tracked changes appear in the open document. In this setup your API route sees chat messages, tool names, arguments, and tool results; the DOCX file stays client-side.

const { tools, executeToolCall, getContext } = useDocxAgentTools({
  editorRef,
  author: 'Assistant',
});

Full walkthrough: AI editing with the Vercel AI SDK.

2. Headless DocxReviewer on the server. Parse a buffer, run a review, serialize the modified DOCX back. No DOM, no editor instance. Fits a queue worker, Lambda, or CI bot.

import { DocxReviewer } from '@eigenpal/docx-editor-agents';

const reviewer = await DocxReviewer.fromBuffer(buffer, 'Reviewer');
reviewer.addComment({ paragraphIndex: 5, text: 'This cap seems too low.' });
reviewer.replace({ paragraphIndex: 5, search: '$50k', replaceWith: '$500k' });
const out = await reviewer.toBuffer();

Reference: DocxReviewer.

3. MCP server. Expose the tool catalog over JSON-RPC for any MCP-compatible client. Transport-agnostic core; you own auth, storage, and the transport.

import { McpServer } from '@eigenpal/docx-editor-agents/mcp';
import { createReviewerBridge } from '@eigenpal/docx-editor-agents';

const server = new McpServer(createReviewerBridge(reviewer), {
  name: 'acme-review',
  version: '1.0.0',
});

Reference: MCP server.

Which shape to pick

Live editorHeadless DocxReviewerMCP server
Where the agent runsYour API route; tools execute in the browserYour server processWherever the MCP client points
Where the document livesThe user's browser, in the open editorA buffer you load and saveA buffer your host loads per request
User watches it happenYes, liveNo, batchNo
Pages (read_page / read_pages)YesNo (no layout, zero pages)No (reviewer-backed)
Typical useAI writing assistant, in-editor reviewContract review API, CI bot, bulk redliningExisting MCP-speaking agent or platform

If you are building a product UI, start with the live editor. If you have documents and no UI, start with DocxReviewer. Pick MCP only when the client already supports MCP.

The tools

  • Locate: read_document, read_selection, read_page, read_pages, find_text, read_comments, read_changes
  • Mutate: add_comment, reply_comment, resolve_comment, suggest_change, apply_formatting, set_paragraph_style
  • Navigate: scroll

The pattern is locate-then-mutate, mirroring Word's JS API: locate tools return paragraphs tagged with a stable paraId, and mutate tools address by it (how paraId anchoring works). Full parameter and return shapes: tools reference.

Subpaths

SubpathUse when
@eigenpal/docx-editor-agentsDocxReviewer, agentTools, getToolSchemas, executeToolCall, createReviewerBridge
/reactuseDocxAgentTools, useAgentChat, chat UI components
/vueuseAgentBridge, Vue chat UI components
/serverBackend routes that need tool schemas without MCP
/bridgecreateEditorBridge for non-React/Vue hosts
/mcpMcpServer, runStdioServer
/ai-sdk/servergetAiSdkTools() for Vercel AI SDK streamText
/ai-sdk/react, /ai-sdk/vuetoAgentMessages() to feed useChat output into <AgentChatLog>

Each subpath tree-shakes independently. The /ai-sdk/* entries import ai, which is an optional peer dependency; skip them if you are not on the AI SDK.

Next steps

On this page