home / mcp / docx mcp server

Docx MCP Server

Provides comprehensive Word document management via MCP with 30+ tools to create, read, modify, and export .docx content

Installation
Add the following to your MCP client configuration file.

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.

How to use

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.

How to install

# 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.sh

Additional setup and runtime tips

You 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.

Configuration and runtime environment

Environment variables you can configure to control the server behavior include the project directory, maximum file size, log level, and path safety settings.

Troubleshooting

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.

Available tools

create_docx

Create a new empty document at a given filepath with optional initial metadata like title.

read_docx

Extract text content and metadata from a .docx document.

write_docx

Write or overwrite document content with provided text or structured data.

append_docx

Append content to an existing document without overwriting existing content.

list_docx

List documents present in a specified directory or catalog.

delete_docx

Securely delete a document by removing its file and references.

copy_docx

Copy a document to a new location, preserving its content and metadata.

list_merge_fields

Extract MERGEFIELD names from the document for mail-merge workflows.

fill_merge_fields

Populate merge fields with supplied data to generate personalized outputs.

list_content_controls

List all content controls embedded in the document.

get_document_properties

Read document metadata such as author, title, and keywords.

set_document_properties

Update document metadata properties.

list_styles

List available paragraph and character styles in the document.

apply_paragraph_style

Apply a named paragraph style to a target location in the document.

apply_bullet_list

Apply bullet list formatting to specified paragraphs.

apply_numbered_list

Apply numbered list formatting to specified paragraphs.

set_list_level

Control the indentation level of list items.

insert_image

Insert an image at a specified location and adjust its size.

add_image_caption

Add an automatically numbered caption to an image.

list_images

List all images contained in the document.

extract_images

Extract images from the document and output to files or base64.

list_equations

List all mathematical equations in the document and convert to LaTeX.

get_equation

Retrieve details for a specific equation by index.