Skip to main content
Glama

apply_changes

Idempotent

Apply tracked changes to .docx files and produce a Word-compatible redlined document with insertions, deletions, and comments.

Instructions

Apply tracked changes to a .docx file and save a new redlined document.

Produces Word-compatible tracked changes (``w:ins`` / ``w:del``) with comments.
Always call ``extract_fragments`` first to get fragment IDs.

Paragraph changes (use ``fragment_id``):
  - ``modify``: Word-level diff. ``new_text`` required.
  - ``delete``: Marks paragraph deleted. Omit ``new_text``.
  - ``append_after``: Insert after target. ``new_text`` required.

Table changes (use ``cell_id`` like ``"2.1.3"``):
  - ``modify_cell``: Replace cell text. ``new_text`` required. Use ``

for multi-paragraph cells. -clear_cell: Delete cell content. Omit new_text``.

Rules:
  - ``delete_next_blanks`` only with ``delete``.
  - ``blank_lines_before`` / ``blank_lines_after`` only with ``append_after``.
  - Header/footer changes work but comments are silently dropped.
  - Documents with pre-existing tracked changes are hard-rejected.

``new_text`` uses pseudo-Markdown: ``**bold**``, ``_italic_``, ``__underline__``.

Example::

    changes = [
        {
            "fragment_id": 1,
            "change_type": "modify",
            "new_text": "**Updated title**",
            "justification": "Fixed typo"
        },
        {
            "cell_id": "2.1.1",
            "change_type": "modify_cell",
            "new_text": "New header",
            "justification": "Clarified"
        }
    ]

Args:
    document_path: Absolute path to the input .docx file.
    changes: List of change objects (paragraph or table cell changes).
    output_path: Where to save the redlined document. Defaults to
        ``<stem>_redlined.docx`` beside the input file.
    author: Author name for tracked changes and comments. Defaults to
        "AI Review".

Returns:
    Summary string with change counts, output path, and validation result.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
authorNoAI Review
changesYes
output_pathNo
document_pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description goes far beyond the annotations by disclosing specific behaviors: it produces w:ins/w:del tagged changes, hard-rejects documents with pre-existing tracked changes, silently drops comments in headers/footers, and explains pseudo-Markdown formatting. These are non-obvious traits not captured by readOnlyHint, idempotentHint, or destructiveHint, adding significant value.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long but well-organized with sections, examples, and a clear progression from summary to details. It is appropriately sized for the tool's complexity, though it includes some repetition of information already present in the schema (e.g., pseudo-Markdown rules). The front-loaded summary sentence ensures immediate clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers prerequisites, change types, parameter constraints, edge cases (headers/footers, pre-existing changes), output behavior, and provides multiple examples. It even explains the return value. Despite the tool's complexity and nested schema, the description is sufficiently complete for an agent to select and invoke it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% for top-level parameters, so the description must compensate—and it does thoroughly. It defines document_path as an absolute path, output_path's default behavior, author's default, and the structure of changes list. It also explains nested change types, required fields, and validation rules, effectively documenting all parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'Apply tracked changes to a .docx file and save a new redlined document.' It clearly distinguishes the tool from siblings like apply_changes_from_file by focusing on in-memory change objects and mentioning the redlining output. The scope is unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly instructs 'Always call extract_fragments first to get fragment IDs,' which is a clear prerequisite and differentiates this tool from alternatives. It also provides detailed rules for when to use each change_type and parameter. However, it does not explicitly contrast with apply_changes_from_file, so the exclusion is implied rather than stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sontanon/docx-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server