home / mcp / docx mcp server

Docx MCP Server

A powerful Word document processing service based on FastMCP, enabling AI assistants to create, edit, and manage docx files with full formatting support. Preserves original styles when editing content. 基于FastMCP的强大Word文档处理服务,使AI助手能够创建、编辑和管理docx文件,支持完整的格式设置功能。在编辑内容时能够保留原始样式和格式,实现精确的文档操作。

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "meterlong-mcp-doc": {
      "command": "python3",
      "args": [
        "/path/to/MCP_dox/server.py"
      ]
    }
  }
}

Docx MCP Server enables AI-assisted creation, editing, and management of Word documents through MCP clients. Built on the FastMCP framework and Python-docx, it exposes a rich set of document operations that you can drive from natural language, making common Word tasks fast and repeatable.

How to use

You interact with the Docx MCP Server through an MCP client or integration in your editor. After you connect the server, you can issue natural language requests to perform document tasks such as creating a new document, adding headings and paragraphs, inserting tables or images, adjusting formatting, and querying document content. You can replace content in specific sections while preserving existing styles, search for text with preview results, and apply find-and-replace operations.

How to install

Prerequisites: Python 3.10 or newer.

Install the required Python packages.

pip3 install python-docx mcp

Run the MCP service locally to expose an endpoint for your MCP client.

python3 /path/to/MCP_dox/server.py

Add the service to your MCP-enabled editor or Cursor by configuring a new MCP server with these values.

Name: MCP_DOCX
Type: Command
Command: python3 /path/to/MCP_dox/server.py

Additional notes

The server supports a wide range of operations, including creating and opening documents, saving, adding and editing content, table operations, image insertion, layout control, and text queries. Use the editor’s MCP client to invoke these actions with natural language.

Troubleshooting

If you encounter issues, verify Python 3.10+ is installed and that the required packages are present. Ensure the server path in your configuration is correct and restart the editor or Cursor after making changes.

Notes

The service relies on the Python-docx library for Word document manipulation and on FastMCP for MCP protocol communication. Ensure your environment supports Chinese characters in paths if you work with multilingual documents.

Available tools

create_document

Create a new Word document from scratch and initialize basic structure.

open_document

Open an existing Word document for editing.

save_document

Save the current document to disk.

save_as_document

Save the current document under a new name.

add_paragraph

Add a new paragraph with optional styling to the document.

add_heading

Insert a heading with a specified level (1-9).

add_table

Insert a new table with a given size and populate cells.

add_picture

Insert an image into the document and set its size.

edit_paragraph

Modify the content or formatting of an existing paragraph.

delete_paragraph

Remove a specified paragraph from the document.

delete_text

Remove specific text within a paragraph or cell.

add_table_row

Add a row to an existing table.

delete_table_row

Delete a row from an existing table.

edit_table_cell

Edit the content or formatting of a table cell.

merge_table_cells

Merge adjacent table cells.

split_table

Split a merged cell into separate cells or split a table into multiple tables.

add_page_break

Insert a page break at the current position.

set_page_margins

Configure page margins for the document.

get_document_info

Retrieve metadata and structure information about the document.

get_paragraphs

Extract all paragraphs with optional formatting details.

get_tables

Extract tables and their data from the document.

search_text

Search for text occurrences within the document.

find_and_replace

Find specific text and replace it, with optional preview.

search_and_replace

Search for text patterns and replace them across the document with preview support.

replace_section

Replace content within a defined section while preserving formatting.

edit_section_by_keyword

Edit a section identified by keywords and maintain styles.