Word Document Formatter MCP server

Enables Microsoft Word document manipulation with text formatting and color control capabilities through python-docx and langchain-mcp-adapters.
Back to servers
Provider
Cuong Pham
Release date
Apr 16, 2025
Language
Python
Stats
1 star

Word MCP Server is a Python application that enables creation and editing of Microsoft Word (.docx) documents through an API. It uses FastMCP to build tools for interacting with Word documents, allowing you to programmatically manipulate document content.

Installation

Requirements

  • Python 3.12+
  • Dependencies:
    • python-docx
    • opencv-python (cv2)
    • numpy
    • FastMCP

Installing Libraries

uv venv
source venv/bin/activate
uv pip install .

Running the Server

Configuration and Setup with LLM

To use Word MCP Server with Large Language Models (LLMs), you need to configure it through a JSON file:

{
  "mcpServers": {
    "word-mcp-server": {
      "command": "/path/to/word-mcp-server/.venv/bin/python3",
      "args": ["/path/to/word-mcp-server/server.py"]
    }
  }
}

Configuration Explanation

  • mcpServers: Object containing configuration for MCP servers
  • word-mcp-server: Identifier name for the server
  • command: Path to Python interpreter (usually within virtual environment)
  • args: Command line parameters, where the first parameter is the path to server.py

Once configured, the server will start and be ready to receive commands from the LLM.

Usage Guide

Creating a New Document

create_new_document()

Opening an Existing Document

open_document("path/to/document.docx")

Adding Headings and Paragraphs

# Adding headings
add_heading("Document Title", level=0)
add_heading("Chapter 1", level=1)

# Adding plain paragraphs
add_paragraph("This is a paragraph content.")

# Adding formatted paragraphs
add_paragraph(
    "This is a formatted paragraph.",
    style="Normal",
    font_size=14,
    bold=True,
    italic=False,
    alignment=WD_PARAGRAPH_ALIGNMENT.CENTER
)

Formatting Text

# Create a paragraph
p = add_paragraph("This is a basic paragraph. ")

# Add formatted text
add_run_to_paragraph(
    p,
    "This part is bold and red.",
    bold=True,
    color="red"
)

# Add highlighted text
add_run_to_paragraph(
    p,
    " This part is highlighted in yellow.",
    highlight="yellow"
)

Adding Images

# Add image from file path
add_picture("path/to/image.jpg", width=4.0)

# Or add image from numpy array
import numpy as np
import cv2

img = cv2.imread("path/to/image.jpg")
add_picture(img, width=3.5)

Creating Tables

# Create a table with 3 rows and 4 columns
table = add_table(rows=3, cols=4, style="Table Grid")

# Fill data into the table
table.cell(0, 0).text = "Row 1, Column 1"
table.cell(0, 1).text = "Row 1, Column 2"
# ...

Supported Colors

When using color and highlight parameters, you can use the following values:

  • black
  • blue
  • green
  • dark blue
  • dark red
  • dark yellow
  • dark green
  • pink
  • red
  • white
  • teal
  • yellow
  • violet
  • gray25
  • gray50

Complete Example

# Create a new document
create_new_document()

# Add title
add_heading("Project Report", level=0)

# Add creator information
p = add_paragraph("Created by: ")
add_run_to_paragraph(p, "John Doe", bold=True)

# Add table of contents
add_heading("Table of Contents", level=1)
add_paragraph("1. Introduction")
add_paragraph("2. Content")
add_paragraph("3. Conclusion")

# Add content
add_heading("1. Introduction", level=1)
add_paragraph("This is the introduction section of the project...")

# Add image
add_paragraph("Illustrative image:")
add_picture("project_diagram.jpg", width=5.0)

# Add data table
add_heading("Data Table", level=2)
table = add_table(rows=3, cols=3)
table.cell(0, 0).text = "Data 1"
table.cell(0, 1).text = "Data 2"
table.cell(0, 2).text = "Data 3"
# Fill other data...

# Save document
save_document("project_report.docx")

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later