Agent Framework

MCP Server for DOCX (Word) Documents

Built-in Model Context Protocol server for DOCX. Expose 14 agent tools over JSON-RPC. Spec 2025-06-18, transport-agnostic, stdio adapter for Node.

Expose the same tool catalog over the Model Context Protocol (spec 2025-06-18). Transport-agnostic core: wire server.handle() to HTTP-SSE, WebSocket, your queue worker, or a managed stdio process. A stdio adapter is included for Node-only deployments.

Quick start

import { McpServer } from '@eigenpal/docx-editor-agents/mcp';
import { DocxReviewer, createReviewerBridge } from '@eigenpal/docx-editor-agents';
 
const reviewer = await DocxReviewer.fromBuffer(buffer, 'AI');
const bridge = createReviewerBridge(reviewer);
const server = new McpServer(bridge, { name: 'my-saas', version: '1.0.0' });
 
// Sync, transport-free, never throws.
const reply = server.handle(jsonRpcMessage);

Stdio adapter (Node only)

// docx-mcp-server.ts
import { runStdioServer } from '@eigenpal/docx-editor-agents/mcp';
import { DocxReviewer, createReviewerBridge } from '@eigenpal/docx-editor-agents';
import { readFile } from 'node:fs/promises';
 
const buffer = await readFile(process.argv[2]);
const reviewer = await DocxReviewer.fromBuffer(buffer.buffer, 'AI');
runStdioServer(createReviewerBridge(reviewer));

UTF-8-safe chunk decoding (multi-byte codepoints don't break across stdio chunks). Buffer cap to prevent memory DoS.

Wire it to Claude Desktop

Drop this into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "docx-review": {
      "command": "node",
      "args": ["/abs/path/to/docx-mcp-server.js", "/abs/path/to/contract.docx"]
    }
  }
}

Restart Claude Desktop and the fourteen tools show up under the hammer icon. Same shape works for Cursor (~/.cursor/mcp.json) and any client that spawns servers as a child process.

Spec compliance

Implements initialize, tools/list, tools/call, ping from spec 2025-06-18. Tool failures use the spec's { isError: true, content: [...] } envelope inside a successful JSON-RPC response. JSON-RPC errors are reserved for protocol-level problems.

Transport choices

  • HTTP-SSE / WebSocket: own the request lifecycle. Each inbound message goes to server.handle(); reply goes back over your transport.
  • stdio: use runStdioServer for Claude Desktop, Cursor, or anything that spawns the server as a child process.
  • Queue worker: server.handle() is sync and idempotent on a per-message basis. Suitable for SQS / Kafka / etc., one message per handle() call.

The library does not pick a transport. It's a JSON-RPC handler that wraps a bridge.

Bridges

Both bridges work with MCP:

  • Headless: createReviewerBridge(reviewer) for batch document review services.
  • Live editor: any EditorBridge instance works, but exposing a live browser editor over MCP is unusual. The typical shape is a hosted MCP service that operates on DocxReviewer instances scoped to per-user documents.

Use cases

A hosted MCP server for DOCX makes sense when you want an external agent (Claude Desktop, Cursor, an internal LLM router) to operate on documents your users have uploaded. Examples include contract review, redlining pipelines, document copilots, and compliance tooling that already speaks MCP.