MI

Microsoft Word MCP Server for DOCX Manipulation

Manipulate DOCX files with an MCP server to create, read, and edit Microsoft Word documents programmatically.

Quick Install
npx -y @GongRzhe/Office-Word-MCP-Server

Overview

The Microsoft Word MCP Server for DOCX Manipulation is a small HTTP service that exposes programmatic operations for creating, reading and editing DOCX files. It implements a Model Context Protocol (MCP) style interface so language models or other orchestrators can call document tools as discrete actions. The server is useful when you want deterministic, scriptable DOCX workflows (generate reports, extract text, perform template edits, assemble documents) without a full desktop Word installation.

The server focuses on common Word operations (create documents, insert paragraphs, add headings, images and tables, find-and-replace, merge documents, export to PDF) and provides simple REST endpoints and an MCP-compatible executor endpoint. That makes it easy to integrate with LLM chains, backend jobs, or developer scripts that need to manipulate .docx reliably.

Features

  • Create and save DOCX documents programmatically
  • Read and extract text or structured content (paragraphs, headings, tables)
  • Edit existing DOCX: replace text, insert content, append sections
  • Upload, download and list stored documents
  • Merge multiple DOCX files into a single document
  • Convert DOCX to PDF (if a converter is available)
  • MCP-compatible tool execution endpoint for LLM-driven workflows
  • Simple authentication and configuration options, Docker support

Installation / Configuration

Clone the repository and install dependencies with pip:

git clone https://github.com/GongRzhe/Office-Word-MCP-Server.git
cd Office-Word-MCP-Server
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Set environment variables (example):

export MCP_HOST=0.0.0.0
export MCP_PORT=8080
export MCP_DATA_DIR=./data        # where uploaded/docs are stored
export MCP_AUTH_TOKEN="s3cr3t"    # optional bearer token for simple auth

Run the server:

python app.py
# or if the repository provides a cli entry:
# MCP_HOST=0.0.0.0 MCP_PORT=8080 python -m mcp_server

Docker example:

docker build -t word-mcp-server .
docker run -p 8080:8080 -e MCP_AUTH_TOKEN="s3cr3t" -v $(pwd)/data:/app/data word-mcp-server

Available Tools

The server exposes a set of tools (available via a dedicated MCP endpoint that accepts a tool name plus JSON input). Typical tool names and their responsibilities:

  • create_docx — create a new DOCX with content blocks (headings, paragraphs, tables, images)
  • read_docx — extract full text or structured sections from an existing DOCX
  • edit_docx — apply edits such as find-and-replace, insert paragraph, append section
  • upload_docx — store an uploaded DOCX on the server
  • download_docx — retrieve a stored DOCX file
  • list_docs — list stored documents and metadata
  • merge_docx — combine multiple DOCX files into one
  • convert_docx — convert a DOCX to PDF (if supported by environment)

Common REST endpoints (typical layout):

EndpointMethodPurpose
/mcpPOSTExecute an MCP tool invocation (tool + input JSON)
/docs/uploadPOSTUpload a DOCX file
/docs/{id}/downloadGETDownload a DOCX by id
/docsGETList stored docs
/healthGETHealth check

Example MCP request body (JSON):

{
  "tool": "create_docx",
  "input": {
    "title": "Monthly Report",
    "content": [
      {"type": "heading", "level": 1, "text": "Summary"},
      {"type": "paragraph", "text": "This report contains ..."}
    ]
  }
}

Use Cases

  • Automated report generation:
    • A scheduled job uses create_docx to generate weekly reports from analytics data; download_docx returns the final file which is emailed or archived.
  • LLM-driven document editing:
    • An LLM analyzes a contract and calls edit_docx via the MCP endpoint to apply requested changes (replace clause text, insert signature block).
  • Template population:
    • upload_docx stores a DOCX template; create_docx or edit_docx fills placeholders with form data to produce personalized letters.
  • Document assembly:
    • merge_docx combines multiple chapter DOCX files produced by different services into a single deliverable.
  • Data extraction and indexing:
    • read_docx extracts headings, paragraphs and tables for indexing into a search engine or knowledge base.

Quick examples

Create a DOCX via curl (MCP execution):

curl -X POST "http://localhost:8080/mcp" \
  -H "Authorization: Bearer s3cr3t" \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "create_docx",
    "input": {
      "title": "Notes",
      "content": [{"type":"paragraph","text":"Hello from MCP server"}]
    }
  }'

Python example (requests):

import requests, json

url = "http://localhost:8080/mcp"
payload = {
    "tool": "read_docx",
    "input": {"doc_id": "report-2026-04-01.docx"}
}
headers = {"Authorization": "Bearer s3cr3t", "Content-Type": "application/json"}
resp = requests.post(url, headers=headers, json=payload)
print(resp.json())  # structured text / extracted data

Resources

  • Repository: https://github.com/GongRzhe/Office-Word-MCP-Server
  • Look for README, examples and any provided API docs in the repo for concrete request/response schemas and authentication details.

This server is intended to be a straightforward programmatic bridge for DOCX workflows and to serve as a toolset easily callable from automation scripts or LLM toolchains.