Office Word logo

Office Word

CommunityPopular
gongrzhe

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.

Publishergongrzhe
Repositoryoffice-word-mcp-server
LanguagePython
Forks
254
Stars
2K
Available tools
54
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    Office Word exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 54 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    2K stars and 254 forks from the linked repository.

Office-Word-MCP-Server

smithery badge

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.

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.

The server features a modular architecture that separates concerns into core functionality, tools, and utilities, making it highly maintainable and extensible for future enhancements.

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
  • Merge multiple documents into a single document
  • Convert Word documents to PDF format

Content Creation

  • Add headings with different levels and direct formatting (font, size, bold, italic, borders)
  • Insert paragraphs with optional styling and direct formatting (font, size, bold, italic, color)
  • Create tables with custom data
  • Add images with proportional scaling
  • Insert page breaks
  • Insert bulleted and numbered lists with proper XML formatting
  • Add footnotes and endnotes to documents
  • Convert footnotes to endnotes
  • Customize footnote and endnote styling
  • Create professional table layouts for technical documentation
  • Design callout boxes and formatted content for instructional materials
  • Build structured data tables for business reports with consistent styling
  • Insert content relative to existing text or paragraph indices

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
  • Individual cell text formatting within tables
  • Multiple formatting combinations for enhanced visual appeal
  • Font customization with family and size control
  • Direct formatting during content creation (paragraphs and headings)
  • Reduce function calls by combining content creation with formatting
  • Add section header borders for visual separation

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
  • Individual cell background shading with color support
  • Alternating row colors for improved readability
  • Enhanced header row highlighting with custom colors
  • Cell text formatting with bold, italic, underline, color, font size, and font family
  • Comprehensive color support with named colors and hex color codes
  • Cell padding management with independent control of all sides
  • Cell alignment (horizontal and vertical positioning)
  • Cell merging (horizontal, vertical, and rectangular areas)
  • Column width management with multiple units (points, percentage, auto-fit)
  • Auto-fit capabilities for dynamic column sizing
  • Professional callout table support with icon cells and styled content

Advanced Document Manipulation

  • Delete paragraphs
  • Insert content relative to specific text or paragraph indices
  • Insert bulleted and numbered lists with proper XML numbering structure
  • Insert headers and paragraphs before or after target locations
  • Create custom document styles
  • Apply consistent formatting throughout documents
  • Format specific ranges of text with detailed control
  • Flexible padding units with support for points and percentage-based measurements
  • Clear, readable table presentation with proper alignment and spacing

Document Protection

  • Add password protection to documents
  • Implement restricted editing with editable sections
  • Add digital signatures to documents
  • Verify document authenticity and integrity

Comment Extraction

  • Extract all comments from a document
  • Filter comments by author
  • Get comments for specific paragraphs
  • Access comment metadata (author, date, text)

Installation

Installing via Smithery

To install Office Word Document Server for Claude Desktop automatically via Smithery:

bash
npx -y @smithery/cli install @GongRzhe/Office-Word-MCP-Server --client claude

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Basic Installation

bash
# 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
bash
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:
json
{
  "mcpServers": {
    "word-document-server": {
      "command": "python",
      "args": ["/path/to/word_mcp_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:
json
{
  "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"
  • "Add my name in Helvetica 36pt bold at the top of the document"
  • "Add a section heading 'Summary' in Helvetica 14pt bold with a bottom border"
  • "Add a paragraph in Times New Roman 14pt with italic blue text"
  • "Insert a bulleted list after the paragraph containing 'Introduction'"
  • "Insert a numbered list with items: 'First step', 'Second step', 'Third step'"
  • "Add bullet points after the 'Summary' heading"
  • "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"
  • "Extract all comments from my document"
  • "Show me all comments by John Doe"
  • "Get comments for paragraph 3"
  • "Make the text in table cell (1,2) bold and blue with 14pt font"
  • "Add 10 points of padding to all sides of the header cells"
  • "Create a callout table with a blue checkmark icon and white text"
  • "Set the first column width to 50 points and auto-fit the remaining columns"
  • "Apply alternating row colors to make the table more readable"

API Reference

Document Creation and Properties

python
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)
convert_to_pdf(filename, output_filename=None)

Content Addition

python
add_heading(filename, text, level=1, font_name=None, font_size=None,
            bold=None, italic=None, border_bottom=False)
add_paragraph(filename, text, style=None, font_name=None, font_size=None,
              bold=None, italic=None, color=None)
add_table(filename, rows, cols, data=None)
add_picture(filename, image_path, width=None)
add_page_break(filename)

Advanced Content Manipulation

python
# Insert content relative to existing text or paragraph index
insert_header_near_text(filename, target_text=None, header_title=None,
                       position='after', header_style='Heading 1',
                       target_paragraph_index=None)

insert_line_or_paragraph_near_text(filename, target_text=None, line_text=None,
                                   position='after', line_style=None,
                                   target_paragraph_index=None)

# Insert bulleted or numbered lists with proper XML formatting
insert_numbered_list_near_text(filename, target_text=None, list_items=None,
                              position='after', target_paragraph_index=None,
                              bullet_type='bullet')
# bullet_type options:
#   'bullet' - Creates bulleted list with bullets (•)
#   'number' - Creates numbered list (1, 2, 3, ...)

Content Extraction

python
get_document_text(filename)
get_paragraph_text_from_document(filename, paragraph_index)
find_text_in_document(filename, text_to_find, match_case=True, whole_word=False)

Text Formatting

python
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

python
format_table(filename, table_index, has_header_row=None,
             border_style=None, shading=None)
set_table_cell_shading(filename, table_index, row_index, col_index, 
                      fill_color, pattern="clear")
apply_table_alternating_rows(filename, table_index, 
                            color1="FFFFFF", color2="F2F2F2")
highlight_table_header(filename, table_index, 
                      header_color="4472C4", text_color="FFFFFF")

# Cell merging tools
merge_table_cells(filename, table_index, start_row, start_col, end_row, end_col)
merge_table_cells_horizontal(filename, table_index, row_index, start_col, end_col)
merge_table_cells_vertical(filename, table_index, col_index, start_row, end_row)

# Cell alignment tools
set_table_cell_alignment(filename, table_index, row_index, col_index,
                        horizontal="left", vertical="top")
set_table_alignment_all(filename, table_index, 
                       horizontal="left", vertical="top")

# Cell text formatting tools
format_table_cell_text(filename, table_index, row_index, col_index,
                      text_content=None, bold=None, italic=None, underline=None,
                      color=None, font_size=None, font_name=None)

# Cell padding tools
set_table_cell_padding(filename, table_index, row_index, col_index,
                      top=None, bottom=None, left=None, right=None, unit="points")

# Column width management
set_table_column_width(filename, table_index, col_index, width, width_type="points")
set_table_column_widths(filename, table_index, widths, width_type="points")
set_table_width(filename, table_index, width, width_type="points")
auto_fit_table_columns(filename, table_index)

Comment Extraction

python
get_all_comments(filename)
get_comments_by_author(filename, author)
get_comments_for_paragraph(filename, paragraph_index)

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
  4. Table Formatting Issues

    • Cell index errors: Ensure row and column indices are within table bounds (0-based indexing)
    • Color format problems: Use hex colors without '#' prefix (e.g., "FF0000" for red) or standard color names
    • Padding unit confusion: Specify "points" or "percent" explicitly when setting cell padding
    • Column width conflicts: Auto-fit may override manual column width settings
    • Text formatting persistence: Apply cell text formatting after setting cell content for best results

Debugging

Enable detailed logging by setting the environment variable:

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

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "word-document-server": {
      "command": "uvx",
      "args": [
        "--from",
        "office-word-mcp-server",
        "word_mcp_server"
      ]
    }
  }
}

Available Tools

  • create_document

    Create a new Word document with optional metadata.

  • copy_document

    Create a copy of a Word document.

  • get_document_info

    Get information about a Word document.

  • get_document_text

    Extract all text from a Word document.

  • get_document_outline

    Get the structure of a Word document.

  • list_available_documents

    List all .docx files in the specified directory.

  • get_document_xml

    Get the raw XML structure of a Word document.

  • insert_header_near_text

    Insert a header (with specified style) before or after the target paragraph. Specify by text or paragraph index. Args: filename (str), target_text (str, optional), header_title (str), position ('before' or 'after'), header_style (str, default 'Heading 1'), target_paragraph_index (int, optional).

  • insert_line_or_paragraph_near_text

    Insert a new line or paragraph (with specified or matched style) before or after the target paragraph. Specify by text or paragraph index. Args: filename (str), target_text (str, optional), line_text (str), position ('before' or 'after'), line_style (str, optional), target_paragraph_index (int, optional).

  • insert_numbered_list_near_text

    Insert a numbered list before or after the target paragraph. Specify by text or paragraph index. Args: filename (str), target_text (str, optional), list_items (list of str), position ('before' or 'after'), target_paragraph_index (int, optional).

  • add_paragraph

    Add a paragraph to a Word document.

  • add_heading

    Add a heading to a Word document.

  • add_picture

    Add an image to a Word document.

  • add_table

    Add a table to a Word document.

  • add_page_break

    Add a page break to the document.

  • delete_paragraph

    Delete a paragraph from a document.

  • search_and_replace

    Search for text and replace all occurrences.

  • create_custom_style

    Create a custom style in the document.

  • format_text

    Format a specific range of text within a paragraph.

  • format_table

    Format a table with borders, shading, and structure.

  • set_table_cell_shading

    Apply shading/filling to a specific table cell.

  • apply_table_alternating_rows

    Apply alternating row colors to a table for better readability.

  • highlight_table_header

    Apply special highlighting to table header row.

  • merge_table_cells

    Merge cells in a rectangular area of a table.

  • merge_table_cells_horizontal

    Merge cells horizontally in a single row.

  • merge_table_cells_vertical

    Merge cells vertically in a single column.

  • set_table_cell_alignment

    Set text alignment for a specific table cell.

  • set_table_alignment_all

    Set text alignment for all cells in a table.

  • protect_document

    Add password protection to a Word document.

  • unprotect_document

    Remove password protection from a Word document.

  • add_footnote_to_document

    Add a footnote to a specific paragraph in a Word document.

  • add_footnote_after_text

    Add a footnote after specific text with proper superscript formatting. This enhanced function ensures footnotes display correctly as superscript.

  • add_footnote_before_text

    Add a footnote before specific text with proper superscript formatting. This enhanced function ensures footnotes display correctly as superscript.

  • add_footnote_enhanced

    Enhanced footnote addition with guaranteed superscript formatting. Adds footnote at the end of a specific paragraph with proper style handling.

  • add_endnote_to_document

    Add an endnote to a specific paragraph in a Word document.

  • customize_footnote_style

    Customize footnote numbering and formatting in a Word document.

  • delete_footnote_from_document

    Delete a footnote from a Word document. Identify the footnote either by ID (1, 2, 3, etc.) or by searching for text near it.

  • add_footnote_robust

    Add footnote with robust validation and Word compliance. This is the production-ready version with comprehensive error handling.

  • validate_document_footnotes

    Validate all footnotes in document for coherence and compliance. Returns detailed report on ID conflicts, orphaned content, missing styles, etc.

  • delete_footnote_robust

    Delete footnote with comprehensive cleanup and orphan removal. Ensures complete removal from document.xml, footnotes.xml, and relationships.

  • get_paragraph_text_from_document

    Get text from a specific paragraph in a Word document.

  • find_text_in_document

    Find occurrences of specific text in a Word document.

  • convert_to_pdf

    Convert a Word document to PDF format.

  • replace_paragraph_block_below_header

    Reemplaza el bloque de párrafos debajo de un encabezado, evitando modificar TOC.

  • replace_block_between_manual_anchors

    Replace all content between start_anchor_text and end_anchor_text (or next logical header if not provided).

  • get_all_comments

    Extract all comments from a Word document.

  • get_comments_by_author

    Extract comments from a specific author in a Word document.

  • get_comments_for_paragraph

    Extract comments for a specific paragraph in a Word document.

  • set_table_column_width

    Set the width of a specific table column.

  • set_table_column_widths

    Set the widths of multiple table columns.

  • set_table_width

    Set the overall width of a table.

  • auto_fit_table_columns

    Set table columns to auto-fit based on content.

  • format_table_cell_text

    Format text within a specific table cell.

  • set_table_cell_padding

    Set padding/margins for a specific table cell.

Use Office Word MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Office Word is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Office Word as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Office Word MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "office-word": {
      "command": "npx",
      "args": [
        "-y",
        "office-word-mcp-server"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Office Word MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Office Word MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Office Word to help me with this task?
Office Word
Sure. I read it.
Here is what I found using Office Word.

Frequently asked questions

What is the Office Word MCP server used for?

Office Word is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Office Word MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Office Word with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Office Word MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Office Word connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Office Word MCP to TypingMind?

Office Word runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Office Word MCP provide in TypingMind?

Office Word exposes 54 MCP tools that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Office Word MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Office Word requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇