Agent Framework

Agent Tool Catalog for DOCX Editing

Fourteen tools for AI agents to read, comment, and edit DOCX documents. Locate, mutate, navigate. OpenAI function-calling format, Anthropic-compatible.

Fourteen tools work against either bridge. Schemas are OpenAI function-calling format. Anthropic, Vercel AI SDK, and anything else that takes that shape accepts them as-is.

Locate, then mutate

Locate tools return paragraphs tagged with a stable paraId. Mutate tools accept that paraId. paraIds survive concurrent edits and tool-loop iterations; ordinal paragraph indices do not.

This mirrors the addressing model Office.js uses for Range, made JSON-serializable so it survives tool calls and MCP transports. See Word JS API parity for the full mapping.

Catalog

GroupToolPurpose
Locateread_documentReturn paragraphs with their paraIds.
Locateread_selectionRead the user's current cursor / selection.
Locateread_pageReturn paragraphs on a single page.
Locateread_pagesReturn paragraphs across a page range.
Locatefind_textLocate text. Returns one handle per matching paragraph.
Locateread_commentsList existing comments and replies.
Locateread_changesList existing tracked changes.
Mutateadd_commentAdd a comment, anchored to a paragraph.
Mutatesuggest_changeOne tool, three modes via empty-string semantics. Replacement: both non-empty. Deletion: replaceWith="". Insertion: search="" appends to the paragraph.
Mutateapply_formattingApply character formatting (bold, italic, color, font) to a range.
Mutateset_paragraph_styleSet a paragraph style (Heading 1, Quote, etc.).
Mutatereply_commentReply to an existing comment thread.
Mutateresolve_commentMark a comment thread as done.
NavigatescrollScroll the editor to a paragraph. Headless bridge: no-op.

Loading the schemas

import { getToolSchemas } from '@eigenpal/docx-editor-agents';
 
const schemas = getToolSchemas(); // OpenAI function-calling format

For Vercel AI SDK callers, use the wrapper that returns the AI SDK shape directly:

import { getAiSdkTools } from '@eigenpal/docx-editor-agents/ai-sdk/server';
 
const tools = getAiSdkTools(); // { [name]: Tool } shape, ready for streamText({ tools }).

The React hook returns the same schemas plus an executor:

import { useDocxAgentTools } from '@eigenpal/docx-editor-agents/react';
 
const { tools, executeToolCall } = useDocxAgentTools({ editorRef });

Restricting the surface

useDocxAgentTools accepts include and exclude allow/block lists. A read-only review agent is one line:

useDocxAgentTools({
  editorRef,
  include: ['read_document', 'find_text', 'read_comments'],
});

Comment-only (no edits or formatting):

useDocxAgentTools({
  editorRef,
  exclude: ['suggest_change', 'apply_formatting', 'set_paragraph_style'],
});

Adding custom tools

Custom tools merge with the built-ins. Same-name tools replace the built-in.

useDocxAgentTools({
  editorRef,
  tools: {
    fetch_clause: {
      name: 'fetch_clause',
      description: 'Fetch a clause template by name from your library.',
      inputSchema: {
        type: 'object',
        properties: { name: { type: 'string' } },
        required: ['name'],
      },
      handler: async (input) => ({
        success: true,
        data: await fetchTemplate(input.name as string),
      }),
    },
  },
});