Docx MCP Server
# Docx MCP Server
A Model Context Protocol (MCP) server for reading and editing Microsoft Word (`.docx`) documents.
## Features
- **`read_docx`**: Extracts all paragraph text and tables from a `.docx` file.
- **`create_or_append_docx`**: Creates a new `.docx` file or appends headings and paragraphs to an existing file.
- **`replace_text_in_docx`**: Finds and replaces specific text across paragraphs and tables.
- **`create_table_docx`**: Creates a new table from 2D data rows with an optional heading.
- **`edit_table_docx`**: Edits specific cell content by table index, row, and column.
- **`delete_table_docx`**: Deletes a table by its table index.
- **`clear_docx`**: Clears all content (paragraphs and tables) from a document.
- **`add_column_docx`**: Appends or inserts a new column to a table with optional cell values, width, and position (`insert_index`).
- **`resize_table_docx`**: Resizes column widths (in inches) across all columns or for a single column.
- **`set_table_visibility_docx`**: Toggles table border visibility (visible grid or transparent/borderless).
- **`delete_column_docx`**: Deletes a specific column from a table by column index.
- **`add_row_docx`**: Appends or inserts a new row to a table with optional cell values, height, and position (`insert_index`).
- **`delete_row_docx`**: Deletes a specific row from a table by row index.
- **`merge_cells_docx`**: Merges a rectangular range of cells within a table.
- **`set_cell_shading_docx`**: Applies background color (HEX) to a cell, row, column, or entire table.
- **`set_table_style_docx`**: Sets the Word table template style (e.g. Table Grid, Light Shading).
- **`set_table_alignment_docx`**: Sets table alignment on the document page (left, center, right).
- **`set_cell_alignment_docx`**: Sets cell text alignment horizontally and/or vertically.
- **`set_table_pagination_docx`**: Configures repeat header rows (`tblHeader`) and prevents row split (`cantSplit`).
- **`set_cell_margins_docx`**: Sets cell padding/margins (in pt) on a specific cell or the entire table.
- **`set_table_borders_docx`**: Configures custom borders per side (top, bottom, left, right, inside) with custom color and size.
- **`set_cell_text_direction_docx`**: Rotates cell text direction (horizontal, 90° up, 270° down).
- **`split_table_docx`**: Splits a table into two separate tables at a specified row index.
- **`format_text_docx`**: Formats font name, size (Pt), color (RGB/HEX), bold, italic, underline, underline style (double, dotted, dashed, wave, etc.), strikethrough, subscript, superscript, small caps, all caps, and highlight on paragraphs, table cells, or targeted phrases.
- **`format_paragraph_docx`**: Formats paragraph layout on document body or inside table cells: line spacing (multiple or exact pt), space before/after (pt), indents (first line, left, right, hanging in inches), alignment, list styles, and page flow controls (`keep_with_next`, `page_break_before`, `widow_control`).
- **`add_styled_paragraph_docx`**: Appends a new paragraph or heading with comprehensive font, typography (subscript/superscript/caps), paragraph spacing, exact/multiple line spacing, indents, hanging indent, page flow controls, list style, and alignment options.
- **`add_picture_docx`**: Inserts an image (`.png`, `.jpg`, `.jpeg`, `.gif`, `.bmp`, `.tiff`) via file path or direct base64 string into a document, specific paragraph, or table cell with width/height in Inches or Cm, alignment, italic caption, alt text, and title.
- **`get_images_info_docx`**: Inspects and lists all images in the document with their dimensions in both Inches and Centimeters.
- **`resize_picture_docx`**: Resizes an existing image in the document by its picture index using Inches or Cm.
- **`delete_picture_docx`**: Deletes an image from the document by its picture index.
- **`extract_images_docx`**: Extracts all embedded image files from the document and saves them to an output directory.
- **`set_page_setup_docx`**: Configures paper size (`A4`, `Letter`, `Legal`, `Folio`/`F4`, `A3`, `A5`, `Executive` or custom cm/inches), orientation (`Portrait`/`Landscape`), margins (preset: `normal`, `narrow`, `skripsi` 4-4-3-3, or custom cm/inches), gutter, header/footer distance, mirror margins (`mirror_margins` for facing pages/booklets), multi-column layout (`columns_count`, `column_spacing_cm`/`inches`), and page numbering format/restart (`page_number_start`, `page_number_format`).
- **`get_page_setup_docx`**: Inspects page dimensions, orientation, margins, gutter, mirror margins status, multi-column setup, and page numbering settings for all sections in the document.
- **`add_section_docx`**: Appends a new section (e.g. for switching to landscape, multi-column, or different paper size / margins) with section start types (`new_page`, `continuous`, etc.), column count/spacing, and page numbering restart.
- **`add_page_break_docx`**: Inserts a hard page break, column break, or line break at document end, before a specific paragraph, or inside a table cell.
- **`add_horizontal_rule_docx`**: Inserts a standalone horizontal divider rule or applies a bottom/top/box border directly to an existing paragraph (ideal for Kop Surat letterhead dividers) with customizable style (`single`, `double`, `triple`, `thick`, `thick_thin`, `thin_thick`, `wave`, etc.), thickness in Pt, left/right indentation, alignment, color, and spacing.
- **`add_equation_docx`**: Inserts native editable Word mathematical equations (OMML) converted from LaTeX or MathML with block/inline display modes, academic right-aligned equation numbering (`equation_number`), placeholder replacement (`placeholder`), font size scaling (`font_size_pt`), paragraph alignment, and table cell support.
- **`set_header_footer_docx`**: Sets Header and Footer text and physical page number fields (`PAGE` / `NUMPAGES`) with alignment, fonts, colors, section unlinking (`is_linked_to_previous`), different first page, and academic presets (`skripsi_chapter` for bottom-center on first page and top-right on subsequent pages, `skripsi_preliminary` for centered roman numbers).
- **`get_header_footer_docx`**: Inspects Header and Footer text, field codes (`PAGE`/`NUMPAGES`), alignment, and linkage status across all sections in the document.
- **`add_table_of_contents_docx`**: Inserts a Table of Contents (Daftar Isi, Daftar Tabel, Daftar Gambar) supporting native Word dynamic fields (`TOC \o "1-3" \h \z \u` with F9 / automatic refresh via `update_fields_on_open`), manual or pre-computed entries with dot leaders (`. . . . . 15`), auto-detection of existing document headings, hierarchical indentation per level (`level_indent_cm`), bold level 1 styling, arbitrary insertion index, and page break integration.
## Requirements
- Python >= 3.12
- [uv](https://docs.astral.sh/uv/) (recommended)
## Installation
Clone the repository and install dependencies:
```bash
cd docx-mcp
uv sync
```
## Running the Server
Run directly with `uv`:
```bash
uv run docx-mcp
```
## MCP Client Configuration
Add this server to your MCP client configuration (e.g. `mcp_config.json`):
```json
{
"mcpServers": {
"docx-editor": {
"command": "uv",
"args": [
"--directory",
"/path/to/docx-mcp",
"run",
"docx-mcp"
]
}
}
}
```
TDQS
Scored across 40 tools
Most tools target clearly distinct resource+action pairs (e.g., add_row vs add_column vs merge_cells). A few boundaries are softer—add_styled_paragraph overlaps with format_text and format_paragraph, and set_table_alignment could be confused with set_cell_alignment—but descriptions make the distinctions reasonably clear.
All tools use snake_case with a consistent action-object suffix (_docx), e.g., resize_table_docx, set_cell_shading_docx, get_page_setup_docx. Minor compound names like create_or_append_docx still follow the same predictable pattern.
40 tools is heavy for a single server, with nearly half dedicated to granular table operations (borders, shading, margins, pagination, visibility, etc.). The domain is broad enough to justify many tools, but several table controls could be consolidated without losing capability.
The surface covers core docx workflows: create/read/clear, text and paragraph formatting, table CRUD and styling, images, headers/footers, page setup, sections, equations, and TOC. Notable gaps remain for hyperlinks, footnotes/endnotes, comments, document properties, and inserting paragraphs at specific positions.