/che-word-mcp:che-word-mcpfrom che-word-mcp
Use when working with Microsoft Word (.docx) documents — reading content, creating new documents, modifying text/formatting/structure, working with tables/images/comments/track-changes/SDT/sections/styles/headers/hyperlinks. Swift-native OOXML server, 242 tools, no Word install required.
Ships in che-word-mcp. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A Swift-native MCP server for Microsoft Word (.docx) document manipulation. 242 tools for reading, writing, and modifying Word documents without requiring Microsoft Word installation. Built on ooxml-swift v0.24.0.
Office.js OOXML Roadmap P0 = 100% complete (PsychQuant/che-word-mcp#43). Binary v3.20.0(242 tools);programmatic Track Changes 自 v3.12.0 起提供。
| Mode | Parameter | Use when | Tool count |
|---|---|---|---|
| Direct Mode | source_path | Quick read-only access, no state needed | 18 tools |
| Session Mode | doc_id | Full read/write with open→edit→save lifecycle | All 242 tools |
source_path)Pass source_path with the .docx path. No open_document needed. Best for quick inspection.
list_images: { "source_path": "/path/to/file.docx" }
search_text: { "source_path": "/path/to/file.docx", "query": "keyword" }
doc_id)Call open_document first, then pass doc_id. Required for any edit.
open_document: { "path": "/path/to/file.docx", "doc_id": "mydoc" }
insert_paragraph: { "doc_id": "mydoc", "text": "Hello" }
save_document: { "doc_id": "mydoc", "path": "/path/to/output.docx" }
close_document: { "doc_id": "mydoc" }
1. open_document(path: "...") → returns doc_id
2. get_document_text(doc_id: "...") → plain text
OR get_paragraphs(doc_id: "...") → with formatting + indices
3. close_document(doc_id: "...")
1. create_document(doc_id: "report")
2. insert_paragraph(doc_id, text: "Title", style: "Heading1")
insert_table(doc_id, rows: 3, cols: 4, data: [...])
insert_image(doc_id, path: "/image.png")
3. save_document(doc_id, path: "/out.docx")
1. open_document(path: "...")
2. update_paragraph(doc_id, paragraph_index: 0, text: "...")
format_text(doc_id, paragraph_index: 0, bold: true)
replace_text(doc_id, find: "...", replace: "...")
3. save_document(doc_id, path: "...")
Two paths: accept/reject existing revisions OR generate new revisions programmatically.
# Accept/reject existing revisions
1. open_document(path: "...")
2. get_revisions(doc_id) → list with revision ids
3. accept_revision(doc_id, revision_id) / reject_revision(...)
accept_all_revisions(doc_id) / reject_all_revisions(doc_id)
# Generate new revisions (NEW in v3.12.0)
1. enable_track_changes(doc_id, author: "Reviewer A")
2. insert_text_as_revision(doc_id, paragraph_index, position, text)
delete_text_as_revision(doc_id, paragraph_index, start, end)
move_text_as_revision(doc_id, source/dest)
format_text(doc_id, paragraph_index, bold: true, as_revision: true)
set_paragraph_format(doc_id, paragraph_index, alignment: "center", as_revision: true)
3. save_document(...)
Author resolution chain: explicit author arg → revisions.settings.author (set at enable_track_changes) → "Unknown".
Side-effect contract (important): as_revision: true requires track changes to be enabled. If disabled, the call throws track_changes_not_enabled instead of silently auto-enabling. Call enable_track_changes first.
insert_content_control(doc_id, paragraph_index, control_type: "richText"|"plainText"|"checkBox"|"dropDownList"|"comboBox"|"date"|"picture")
insert_repeating_section(doc_id, ...)
list_content_controls(doc_id)
get_content_control(doc_id, sdt_id)
update_content_control_text(doc_id, sdt_id, text)
replace_content_control_content(doc_id, sdt_id, content)
delete_content_control(doc_id, sdt_id)
SDT ids are auto-allocated via max+1 pattern (scans body + headers + footers + footnotes + endnotes).
export_text(doc_id) → plain text
export_markdown(doc_id) → Markdown
export_revision_summary_markdown(doc_id) → revision summary
export_comment_threads_markdown(doc_id) → comment threads
export_all_images(doc_id, output_dir)
create_document, open_document, save_document, close_document, list_open_documents, get_document_info, get_document_session_state, finalize_document, recover_from_autosave, revert_to_disk, reload_from_disk, check_disk_drift, checkpoint
get_document_properties, set_document_properties, get_theme, set_theme, update_theme_color, update_theme_fonts, get_web_settings, update_web_settings, set_language
get_text, get_document_text, get_paragraphs, get_paragraph_runs, get_text_with_formatting, insert_paragraph, update_paragraph, delete_paragraph, replace_text, replace_text_batch, search_text, search_text_batch, search_text_with_formatting, search_by_formatting, list_all_formatted_text
format_text (with as_revision flag, v3.12.0+), set_paragraph_format (with as_revision flag), set_character_spacing, set_text_effect, set_text_direction, set_paragraph_border, set_paragraph_shading
list_styles, apply_style, create_style, update_style, delete_style
insert_bullet_list, insert_numbered_list, set_list_level, set_outline_level
get_section_properties, insert_section_break, insert_continuous_section_break, insert_column_break, insert_page_break, set_columns, set_page_size, set_page_margins, set_page_orientation, set_page_borders, set_page_break_before, set_keep_lines, set_keep_with_next, set_widow_orphan, set_line_numbers, get_word_count_by_section
insert_table, get_tables, update_cell, get_cell_paragraphs, update_cell_paragraph, add_row_to_table, delete_row_from_table, add_column_to_table, delete_column_from_table, merge_cells, set_cell_width, set_cell_vertical_alignment, set_row_height, set_header_row, set_table_alignment, set_table_style, delete_table
多段落儲存格(4.2.0+):update_cell 會把整格 N 段塌成一段;官方表單的 checkbox 欄(□(1)/□(2)…)改用 get_cell_paragraphs 列出 [k] 文字,再以 update_cell_paragraph(table_index/row/col/paragraph_index,皆從 0 起算)只改那一段。同格其他段落、已建模的段落格式與其他列的同字串都不動;座標越界時失敗,文件不變。replace_text 是全域取代,定位字串不唯一時不要用它填表。
insert_hyperlink, update_hyperlink, delete_hyperlink, list_hyperlinks, insert_internal_link, insert_cross_reference
add_header, update_header, get_header, delete_header, list_headers, add_footer, update_footer, get_footer, delete_footer, list_footers, insert_page_number
insert_comment, update_comment, delete_comment, list_comments, list_comment_threads, get_comment_thread, reply_to_comment, resolve_comment, sync_extended_comments, add_person, update_person, delete_person, list_people
enable_track_changes, disable_track_changes, get_revisions, accept_revision, reject_revision, accept_all_revisions, reject_all_revisions, insert_text_as_revision, delete_text_as_revision, move_text_as_revision, export_revision_summary_markdown
insert_content_control, list_content_controls, get_content_control, update_content_control_text, replace_content_control_content, delete_content_control, insert_repeating_section, update_repeating_section_item, list_repeating_section_items, insert_checkbox, insert_dropdown, insert_text_field, list_custom_xml_parts
insert_image, insert_image_from_path, insert_floating_image, update_image, delete_image, list_images, set_image_style, export_image, export_all_images, insert_drop_cap
insert_footnote, update_footnote, delete_footnote, get_footnote, list_footnotes, insert_endnote, update_endnote, delete_endnote, get_endnote, list_endnotes, insert_equation, update_equation, delete_equation, get_equation, list_equations, insert_caption, update_caption, delete_caption, get_caption, list_captions
insert_bookmark, delete_bookmark, list_bookmarks, insert_index, insert_index_entry, insert_toc, insert_table_of_figures, get_watermark, list_watermarks
Watermark write tools (insert_watermark, insert_image_watermark, remove_watermark) are listed by the server but not implemented: each call returns isError. Do not use them to add or remove a watermark (PsychQuant/che-word-mcp#208).
insert_date_field, insert_page_field, insert_sequence_field, insert_calculation_field, insert_if_field, insert_merge_field, update_all_fields
insert_horizontal_line, insert_symbol, insert_tab_stop, clear_tab_stops
Not implemented. protect_document, unprotect_document, set_document_password, remove_document_password and restrict_editing_region are listed by the server, but each call returns isError (PsychQuant/che-word-mcp#172). Tell the user protection has to be set in Word.
compare_documents, compare_documents_markdown, export_text, export_markdown
export_script, get_script_coverage, execute_script
把 docx 變成 .mdocx.swift 重建腳本、再放回 docx。三個工具都是 macdoc CLI 同一條 transcoder 的薄包裝,兩邊呼叫同一個實作。
| Tool | 參數 | 回傳 |
|---|---|---|
export_script | source_path, output_path, 選填 slots: [{name, para_id}]、paragraphs_only(預設 false,4.3.0+) | JSON:dsl_parts / form_gaps_empty / slot_count / output_path;paragraphs_only: true 時改回 paragraphs_only / byte_equal: false / omitted_body_blocks / slot_count / output_path |
get_script_coverage | source_path | JSON:每個 part 的 channel(dsl/raw)、bytes、dsl_ratio,加 aggregate_ratio;raw part 另帶 raw_reason(4.3.0+,原樣透傳,DSL part 不帶) |
execute_script | script_path, output_path, 選填 verify_byte_equal_against、overwrite | 成功時 JSON:written;只有傳了參考檔才有 verified / broken_parts。驗證失敗不是回應,是 tool error |
CLI 對應:export_script ↔ macdoc word reverse,execute_script ↔ macdoc word render。同一個操作在兩個面的名字不同——MCP 這邊的名字是已發布 tool schema 的一部分,CLI 那邊的名字由 mdocx-grammar spec 固定。
verified 缺席 ≠ 通過:沒傳 verify_byte_equal_against 時回應不會有 verified 與 broken_parts 欄位。只檢查 broken_parts 是否為空的 client 會把「沒驗」讀成「驗過且乾淨」——要判斷驗證結果,先確認 verified 這個欄位存在。
驗證失敗是 tool error,不是回應欄位:verified: false 不會出現在成功回應裡。不符時整個 tool call 失敗,錯誤文字列出每一個不符的 part。這是刻意的——舊行為把失敗的 verdict 放進一個成功回應,只判斷「呼叫有沒有成功」的 client 會把驗證失敗讀成通過。代價是不符的 part 清單降級成字串而非結構化陣列(追蹤中)。
失敗不寫出任何東西:驗證失敗時 output_path 保持原狀——原本有檔就原封不動,原本沒檔就不會憑空出現。重建結果先寫到輸出檔同目錄的暫存路徑,驗過才搬進位。
overwrite 預設拒絕:output_path 已存在時,沒帶 overwrite: true 就直接失敗並具名該路徑,檔案不動。這是行為變更——舊版無條件覆寫。把同一路徑同時當 output_path 與 verify_byte_equal_against(問「這份腳本能不能逐位元組重建這份文件?」)必須帶 overwrite: true,因為那必然指向既有檔案。
written 只在真的 publish 了才出現;沒 publish 就整個欄位缺席,不會給你一個 null。
slots 是 strict mode:指定失敗(paraId 不存在、名稱不合法、重複)直接報錯且不寫檔,不會靜默降級。
腳本有兩條 channel:typed DSL(可讀)與 raw(整個 XML part 逐字塞進一行)。DSL 升級是 per-part 全有全無——canonical minimal table 可用 typed appendTable 升級;只要 part 內任何一處(含不支援的 rich/foreign-form 表格、或缺 w14:paraId 的段落)無法以 typed 形式試重建 byte-equal,整個 part 才會落到 raw。判準細節與各原因的對應策略見 macdoc plugin 的 swiftify skill,不在此重複。
實測真實官方表單(REC-O-01):0.0% DSL (0 / 190479 XML bytes across 16 parts),產出 24 行 / 212 KB,其中 document.xml 那行約 118 KB。**可完美重播,但不可讀、不可手改、無法有意義 diff。**這是這一份文件的量測結果,不是「含表格就必然 0% DSL」的通則——swiftify skill 有 canonical table 成功升級的對照案例。
所以先跑 get_script_coverage 再決定期待值。4.3.0 起每個 raw part 都帶 raw_reason,說明它為什麼沒能升級(值原樣透傳,例如 sibling-part、table、paragraph-no-paraId、byte-mismatch,不是封閉列舉)。word/document.xml 的 raw_reason 是 paragraph-no-paraId 時,可以改走 export_script 帶 paragraphs_only: true,等同 CLI 的 macdoc word reverse --paragraphs-only,兩邊寫出的腳本逐位元組相同。代價要先講清楚:只匯出段落文字與 styleId,省略表格等非段落內容、不保證 byte-equal,所以對含省略內容的來源,execute_script 的 verify_byte_equal_against 會回報不符;來源旁有 oplog sidecar 時 MCP 會直接拒絕(CLI 會改匯出 sidecar);export_script 會覆寫既有的 output_path(CLI 預設拒絕)。其他根因沒有這條備援路徑。完整工作流見 macdoc plugin 的 swiftify skill。
create_document and open_document auto-enable track changes via enforceTrackChangesIfNeeded. Pass track_changes: false to open_document if you need to bypass enforcement (e.g., authoring tooling that controls revisions itself).save_document.finalize_document to save+close in one step when done.apply_style over manual formatting.get_document_info / get_paragraphs before editing.export_markdown for easier text analysis.source_path, skip the open/close lifecycle."row_index": "3" or "bold": "true" is now rejected with Invalid parameter '<name>'; before 4.4.0 such values were silently treated as absent and the default was applied. A parameter is validated whenever it is present, even when another argument means it would not be used. Whole-valued decimals (3.0) are accepted; null still means "not provided". String parameters are not yet checked this way: a wrongly typed or unknown enum value (e.g. wrap_type: "bogus") still falls back to the default (PsychQuant/che-word-mcp#240).rows × cols ≤ 65,536) and similar values are checked against Word's limits. Before 4.4.0 an extreme value could terminate the server process and lose every open document's unsaved changes. insert_floating_image takes an integer EMU offset in horizontal_position/vertical_position and an alignment keyword in horizontal_align/vertical_align.1. open_document("/contracts/draft.docx")
2. enable_track_changes(doc_id, author: "Reviewer A")
3. insert_text_as_revision(doc_id, paragraph_index: 5, position: 32,
text: " (subject to escalation)")
4. delete_text_as_revision(doc_id, paragraph_index: 7, start: 23, end: 31)
5. format_text(doc_id, paragraph_index: 9, bold: true, as_revision: true)
6. save_document(doc_id, path: "/contracts/draft-redlined.docx")
→ Word opens the file with proper <w:ins>/<w:del>/<w:rPrChange> markup,
attributed to "Reviewer A", reviewable in the Review pane.
1. enable_track_changes(doc_id, author: "Author A")
2. insert_text_as_revision(...) # → "Author A"
3. disable_track_changes(doc_id)
4. enable_track_changes(doc_id, author: "Author B")
5. insert_text_as_revision(..., author: "Author C") # explicit override
6. insert_text_as_revision(...) # falls back to "Author B"
1. create_document(doc_id: "form")
2. insert_paragraph(doc_id, text: "Application Form", style: "Heading1")
3. insert_paragraph(doc_id, text: "Name: ")
4. insert_content_control(doc_id, paragraph_index: 1, control_type: "plainText",
tag: "applicant_name", placeholder: "Enter name...")
5. insert_paragraph(doc_id, text: "Date: ")
6. insert_content_control(doc_id, paragraph_index: 2, control_type: "date",
tag: "submission_date")
7. save_document(doc_id, path: "/forms/application.docx")
1. open_document("/document.docx")
2. get_paragraphs(doc_id) + list_comments(doc_id) + get_revisions(doc_id)
3. export_markdown(doc_id) → analyze
4. close_document(doc_id)
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub psychquant/macdoc --plugin che-word-mcp