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文件,支持完整的格式设置功能。在编辑内容时能够保留原始样式和格式,实现精确的文档操作。
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.
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.
Prerequisites: Python 3.10 or newer.
Install the required Python packages.
pip3 install python-docx mcpRun the MCP service locally to expose an endpoint for your MCP client.
python3 /path/to/MCP_dox/server.pyAdd 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.pyThe 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.
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.
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.
Create a new Word document from scratch and initialize basic structure.
Open an existing Word document for editing.
Save the current document to disk.
Save the current document under a new name.
Add a new paragraph with optional styling to the document.
Insert a heading with a specified level (1-9).
Insert a new table with a given size and populate cells.
Insert an image into the document and set its size.
Modify the content or formatting of an existing paragraph.
Remove a specified paragraph from the document.
Remove specific text within a paragraph or cell.
Add a row to an existing table.
Delete a row from an existing table.
Edit the content or formatting of a table cell.
Merge adjacent table cells.
Split a merged cell into separate cells or split a table into multiple tables.
Insert a page break at the current position.
Configure page margins for the document.
Retrieve metadata and structure information about the document.
Extract all paragraphs with optional formatting details.
Extract tables and their data from the document.
Search for text occurrences within the document.
Find specific text and replace it, with optional preview.
Search for text patterns and replace them across the document with preview support.
Replace content within a defined section while preserving formatting.
Edit a section identified by keywords and maintain styles.