Provides comprehensive Word document management via MCP with 30+ tools to create, read, modify, and export .docx content
Configuration
View docs{
"mcpServers": {
"andrew82106-llm_docx_agent_mcp": {
"command": "uv",
"args": [
"--directory",
"/你的/docx-mcp/路径",
"run",
"python",
"-m",
"docx_mcp.server"
],
"env": {
"DOCX_MCP_LOG_LEVEL": "INFO",
"DOCX_MCP_PROJECT_DIR": "\\/path\\/to\\/documents",
"DOCX_MCP_MAX_FILE_SIZE": "52428800",
"DOCX_MCP_ALLOW_UNSAFE_PATHS": "true"
}
}
}
}You can manage Microsoft Word documents programmatically with a full-feature MCP server designed to read, write, and manipulate .docx files. It covers the document lifecycle from creation and formatting to templates, content controls, images, equations, and structured logging, all with safety checks and path validation.
You run the MCP server locally and connect with an MCP client to perform a wide range of tasks on Word documents. You can create new documents, read text and metadata, write or append content, apply styles and lists, insert images with captions, extract images, list and manage merge fields and content controls, and even handle equations by converting them to LaTeX. All operations are accessible through the MCP endpoints exposed by the server, and you can configure access, logging, and security options as needed.
# 1. Prerequisites
# - Python 3.10 or newer
# - uvx (or equivalent) for running MCP endpoints
# 2. Clone and enter project directory
# (assumes you have a local copy available at docx-mcp or equivalent)
# cd docx-mcp
# 3. Install and prepare the environment
./setup.sh
# 4. Activate virtual environment
source venv/bin/activate
# 5. Run the MCP server
./run.shYou can customize run configurations through the provided MCP endpoints and environment variables. The server supports structured JSON logs, robust error handling, and path validations to prevent common security issues such as directory traversal. Review the environment variables section to tailor project directory, file size limits, log level, and path safety rules to your environment.
Environment variables you can configure to control the server behavior include the project directory, maximum file size, log level, and path safety settings.
If the server cannot start, verify you are using Python 3.10 or newer and check the log files for details. Common issues include an incorrect Python version, missing dependencies, or misconfigured environment variables.
Create a new empty document at a given filepath with optional initial metadata like title.
Extract text content and metadata from a .docx document.
Write or overwrite document content with provided text or structured data.
Append content to an existing document without overwriting existing content.
List documents present in a specified directory or catalog.
Securely delete a document by removing its file and references.
Copy a document to a new location, preserving its content and metadata.
Extract MERGEFIELD names from the document for mail-merge workflows.
Populate merge fields with supplied data to generate personalized outputs.
List all content controls embedded in the document.
Read document metadata such as author, title, and keywords.
Update document metadata properties.
List available paragraph and character styles in the document.
Apply a named paragraph style to a target location in the document.
Apply bullet list formatting to specified paragraphs.
Apply numbered list formatting to specified paragraphs.
Control the indentation level of list items.
Insert an image at a specified location and adjust its size.
Add an automatically numbered caption to an image.
List all images contained in the document.
Extract images from the document and output to files or base64.
List all mathematical equations in the document and convert to LaTeX.
Retrieve details for a specific equation by index.