validate_document_tool
Validate .docx files for structural issues to ensure they open correctly in Word and have properly formed tracked changes and comments. Use after applying changes or when debugging document corruption.
Instructions
Check a .docx file for structural issues.
Runs validation checks on the document's OOXML structure to ensure it will open correctly in Microsoft Word and that all tracked changes and comments are properly formed.
Use this tool:
After calling
apply_changesto verify the redlined document is valid (automatically enabled by default viavalidate=Trueparameter)When debugging a document that won't open correctly in Word
When verifying that an existing redlined document has proper structure
Validation Checks
Annotation ID isolation: Tracked-change and comment IDs must not collide across groups. Each
<w:ins>,<w:del>, and<w:comment>needs a globally unique ID within the document.Comment integrity: Every
<w:comment>in comments.xml must have matching<w:commentRangeStart>/<w:commentRangeEnd>markers in the document body, and vice versa.Tracked-change attributes: Every
<w:ins>and<w:del>must have required attributes:w:id(unique ID),w:author(author name), andw:date(timestamp).Package consistency: Content-type and relationship entries must be present in the .docx ZIP structure when comments.xml exists.
Example Output
Success case::
"Validation: passed (0 errors, 0 warnings)."Failure case::
"Validation: FAILED (2 error(s), 1 warning(s)).
Error 1: Annotation ID collision: ID 5 used by both tracked change and comment
Error 2: Orphaned comment range: commentRangeStart with id=3 has no matching end
Warning 1: Comment with id=7 is not referenced by any comment range"Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| document_path | Yes | Absolute path to the .docx file to validate. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |