Office Word MCP Server

repository·main·Indexed 24 days ago

https://github.com/gongrzhe/office-word-mcp-server

A Model Context Protocol (MCP) server version 1.1.11 that enables AI assistants to create, read, and manipulate Microsoft Word documents. It provides a standardized interface for document management, content creation (headings, paragraphs, tables, images), rich text formatting, table manipulation, and comment extraction. Supports multiple transport types including stdio, SSE, and streamable-http, with specific deployment guides for Claude Desktop and Render.

Tokens
5K
Snippets
13
Records
27
Agent score
83%

What's inside office-word-mcp-server

  1. Overview of Office-Word-MCP-Server capabilities

    main

    The Office-Word-MCP-Server is a Model Context Protocol (MCP) server that allows AI assistants to interact with Microsoft Word documents. It exposes document operations as tools and resources, enabling tasks such as:

    • Document Management: Creating, reading, merging, and converting documents (e.g., to PDF).
    • Content Creation: Adding headings, paragraphs, tables, images, lists, and footnotes with rich formatting.
    • Rich Text & Table Formatting: Controlling fonts, colors, cell shading, borders, alignment, and cell merging.
    • Advanced Manipulation: Deleting paragraphs, inserting content at specific indices, and applying custom styles.
    • Document Protection: Adding password protection, restricted editing, and digital signatures.
    • Comment Extraction: Retrieving comments and their metadata (author, date, text).
  2. Configure environment variables for Render deployment

    main

    To deploy the Office Word MCP Server on Render, you must configure specific environment variables to ensure the server uses Server-Sent Events (SSE) instead of the default STDIO transport.

    Required Variables:

    • MCP_TRANSPORT: Must be set to sse.

    Optional Variables:

    • MCP_HOST: Set to 0.0.0.0 to bind to all network interfaces (defaults to 0.0.0.0).
    • FASTMCP_LOG_LEVEL: Sets the logging level (defaults to INFO).
  3. Deploy the Office Word MCP Server on Render

    main

    Follow these steps to deploy on Render:

    1. Log in to the Render dashboard.
    2. Select your Office-Word-MCP-Server service.
    3. Navigate to the Environment section in the sidebar.
    4. Add the environment variable MCP_TRANSPORT with the value sse.
    5. Save changes. Render will automatically redeploy the service.

    Once deployed, the server will be accessible via SSE at your service URL followed by /sse (e.g., https://office-word-mcp-server-bzlp.onrender.com/sse).

  4. Install Office-Word-MCP-Server via Smithery

    main

    To automatically install the Office Word Document Server for Claude Desktop, use the Smithery CLI. This is the recommended method for quick setup with Claude.

    npx -y @smithery/cli install @GongRzhe/Office-Word-MCP-Server --client claude
  5. Basic Installation via pip

    main

    If you prefer a manual installation, ensure you have Python 3.8+ and pip installed. Clone the repository and install the required dependencies from requirements.txt.

    # 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
  6. Configure Office-Word-MCP-Server for Claude Desktop (using uvx)

    main

    You can run the server without a local installation by using the uvx package manager. This is useful for a lightweight, managed execution environment.

    {
      "mcpServers": {
        "word-document-server": {
          "command": "uvx",
          "args": ["--from", "office-word-mcp-server", "word_mcp_server"]
        }
      }
    }
  7. Configure Office-Word-MCP-Server for Claude Desktop (Local Install)

    main

    After installing the server locally, add it to your Claude Desktop configuration file. You must provide the absolute path to the word_mcp_server.py file.

    {
      "mcpServers": {
        "word-document-server": {
          "command": "python",
          "args": ["/path/to/word_mcp_server.py"]
        }
      }
    }
  8. Troubleshoot Table Formatting Issues

    main

    Common pitfalls when working with tables:

    • 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_table_columns may override manual column width settings.
    • Text formatting persistence: Apply format_table_cell_text after setting cell content for best results.
  9. Troubleshoot Render deployment issues

    main

    If you encounter issues with your Render deployment, check the following common causes:

    IssueCauseFix
    Server exits with status 1Server is running in STDIO mode instead of SSEEnsure MCP_TRANSPORT=sse is set in environment variables
    Port binding errorsServer not using Render's PORT environment variableEnsure you are using the latest version of main.py
    Cannot connect to serverHealth checks are failingEnsure SSE transport is enabled and server is listening on 0.0.0.0
  10. Extract Comments

    main

    Retrieve comments from a document, either all comments, comments by a specific author, or comments associated with a specific paragraph index.

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