Office-Word-MCP-Server

Office-Word-MCP-Server

A Model Context Protocol server that enables AI assistants to create, read, edit, and format Microsoft Word documents through standardized tools and resources.

GongRzhe

Developer Tools
Visit Server

Tools

create_document

Create a new Word document with optional metadata. Args: filename: Name of the document to create (with or without .docx extension) title: Optional title for the document metadata author: Optional author for the document metadata

add_heading

Add a heading to a Word document. Args: filename: Path to the Word document text: Heading text level: Heading level (1-9, where 1 is the highest level)

add_paragraph

Add a paragraph to a Word document. Args: filename: Path to the Word document text: Paragraph text style: Optional paragraph style name

add_table

Add a table to a Word document. Args: filename: Path to the Word document rows: Number of rows in the table cols: Number of columns in the table data: Optional 2D array of data to fill the table

add_picture

Add an image to a Word document. Args: filename: Path to the Word document image_path: Path to the image file width: Optional width in inches (proportional scaling)

get_document_info

Get information about a Word document. Args: filename: Path to the Word document

get_document_text

Extract all text from a Word document. Args: filename: Path to the Word document

get_document_outline

Get the structure of a Word document. Args: filename: Path to the Word document

list_available_documents

List all .docx files in the specified directory. Args: directory: Directory to search for Word documents

copy_document

Create a copy of a Word document. Args: source_filename: Path to the source document destination_filename: Optional path for the copy. If not provided, a default name will be generated.

format_text

Format a specific range of text within a paragraph. Args: filename: Path to the Word document paragraph_index: Index of the paragraph (0-based) start_pos: Start position within the paragraph text end_pos: End position within the paragraph text bold: Set text bold (True/False) italic: Set text italic (True/False) underline: Set text underlined (True/False) color: Text color (e.g., 'red', 'blue', etc.) font_size: Font size in points font_name: Font name/family

search_and_replace

Search for text and replace all occurrences. Args: filename: Path to the Word document find_text: Text to search for replace_text: Text to replace with

delete_paragraph

Delete a paragraph from a document. Args: filename: Path to the Word document paragraph_index: Index of the paragraph to delete (0-based)

create_custom_style

Create a custom style in the document. Args: filename: Path to the Word document style_name: Name for the new style bold: Set text bold (True/False) italic: Set text italic (True/False) font_size: Font size in points font_name: Font name/family color: Text color (e.g., 'red', 'blue') base_style: Optional existing style to base this on

format_table

Format a table with borders, shading, and structure. Args: filename: Path to the Word document table_index: Index of the table (0-based) has_header_row: If True, formats the first row as a header border_style: Style for borders ('none', 'single', 'double', 'thick') shading: 2D list of cell background colors (by row and column)

add_page_break

Add a page break to the document. Args: filename: Path to the Word document

README

Office-Word-MCP-Server

A Model Context Protocol (MCP) server for creating, reading, and manipulating Microsoft Word documents. This server enables AI assistants to work with Word documents through a standardized interface, providing rich document editing capabilities.

<a href="https://glama.ai/mcp/servers/@GongRzhe/Office-Word-MCP-Server"> <img width="380" height="200" src="https://glama.ai/mcp/servers/@GongRzhe/Office-Word-MCP-Server/badge" alt="Office Word Server MCP server" /> </a>

Overview

Office-Word-MCP-Server implements the Model Context Protocol to expose Word document operations as tools and resources. It serves as a bridge between AI assistants and Microsoft Word documents, allowing for document creation, content addition, formatting, and analysis.

Example

Pormpt

image

Output

image

Features

Document Management

  • Create new Word documents with metadata
  • Extract text and analyze document structure
  • View document properties and statistics
  • List available documents in a directory
  • Create copies of existing documents

Content Creation

  • Add headings with different levels
  • Insert paragraphs with optional styling
  • Create tables with custom data
  • Add images with proportional scaling
  • Insert page breaks

Rich Text Formatting

  • Format specific text sections (bold, italic, underline)
  • Change text color and font properties
  • Apply custom styles to text elements
  • Search and replace text throughout documents

Table Formatting

  • Format tables with borders and styles
  • Create header rows with distinct formatting
  • Apply cell shading and custom borders
  • Structure tables for better readability

Advanced Document Manipulation

  • Delete paragraphs
  • Create custom document styles
  • Apply consistent formatting throughout documents
  • Format specific ranges of text with detailed control

Installation

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Basic Installation

# Clone the repository
git clone https://github.com/GongRzhe/Office-Word-MCP-Server.git
cd Office-Word-MCP-Server

# Install dependencies
pip install -r requirements.txt

Using the Setup Script

Alternatively, you can use the provided setup script which handles:

  • Checking prerequisites
  • Setting up a virtual environment
  • Installing dependencies
  • Generating MCP configuration
python setup_mcp.py

Usage with Claude for Desktop

Configuration

Method 1: After Local Installation

  1. After installation, add the server to your Claude for Desktop configuration file:
{
  "mcpServers": {
    "word-document-server": {
      "command": "python",
      "args": [
        "/path/to/word_server.py"
      ]
    }
  }
}

Method 2: Without Installation (Using uvx)

  1. You can also configure Claude for Desktop to use the server without local installation by using the uvx package manager:
{
  "mcpServers": {
    "word-document-server": {
      "command": "uvx",
      "args": [
        "--from", "office-word-mcp-server", "word_mcp_server"
      ]
    }
  }
}
  1. Configuration file locations:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. Restart Claude for Desktop to load the configuration.

Example Operations

Once configured, you can ask Claude to perform operations like:

  • "Create a new document called 'report.docx' with a title page"
  • "Add a heading and three paragraphs to my document"
  • "Insert a 4x4 table with sales data"
  • "Format the word 'important' in paragraph 2 to be bold and red"
  • "Search and replace all instances of 'old term' with 'new term'"
  • "Create a custom style for section headings"
  • "Apply formatting to the table in my document"

API Reference

Document Creation and Properties

create_document(filename, title=None, author=None)
get_document_info(filename)
get_document_text(filename)
get_document_outline(filename)
list_available_documents(directory=".")
copy_document(source_filename, destination_filename=None)

Content Addition

add_heading(filename, text, level=1)
add_paragraph(filename, text, style=None)
add_table(filename, rows, cols, data=None)
add_picture(filename, image_path, width=None)
add_page_break(filename)

Text Formatting

format_text(filename, paragraph_index, start_pos, end_pos, bold=None, 
            italic=None, underline=None, color=None, font_size=None, font_name=None)
search_and_replace(filename, find_text, replace_text)
delete_paragraph(filename, paragraph_index)
create_custom_style(filename, style_name, bold=None, italic=None, 
                    font_size=None, font_name=None, color=None, base_style=None)

Table Formatting

format_table(filename, table_index, has_header_row=None, 
             border_style=None, shading=None)

Troubleshooting

Common Issues

  1. Missing Styles

    • Some documents may lack required styles for heading and table operations
    • The server will attempt to create missing styles or use direct formatting
    • For best results, use templates with standard Word styles
  2. Permission Issues

    • Ensure the server has permission to read/write to the document paths
    • Use the copy_document function to create editable copies of locked documents
    • Check file ownership and permissions if operations fail
  3. Image Insertion Problems

    • Use absolute paths for image files
    • Verify image format compatibility (JPEG, PNG recommended)
    • Check image file size and permissions

Debugging

Enable detailed logging by setting the environment variable:

export MCP_DEBUG=1  # Linux/macOS
set MCP_DEBUG=1     # Windows

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments


Note: This server interacts with document files on your system. Always verify that requested operations are appropriate before confirming them in Claude for Desktop or other MCP clients.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
MCP Package Docs Server

MCP Package Docs Server

Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.

Featured
Local
TypeScript
Claude Code MCP

Claude Code MCP

An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.

Featured
Local
JavaScript
@kazuph/mcp-taskmanager

@kazuph/mcp-taskmanager

Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.

Featured
Local
JavaScript
Linear MCP Server

Linear MCP Server

Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.

Featured
JavaScript
mermaid-mcp-server

mermaid-mcp-server

A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.

Featured
JavaScript
Jira-Context-MCP

Jira-Context-MCP

MCP server to provide Jira Tickets information to AI coding agents like Cursor

Featured
TypeScript
Linear MCP Server

Linear MCP Server

A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Featured
JavaScript
Sequential Thinking MCP Server

Sequential Thinking MCP Server

This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.

Featured
Python