Office Word MCP Server
The Office Word Model Context Protocol (MCP) Server is a Python library designed to enable AI assistants to create, read, and manipulate Microsoft Word documents through a standardized interface. It exposes a rich set of document operations as tools and resources, facilitating seamless integration of Word document manipulation into AI-powered workflows. The current version is 1.1.11, requiring Python 3.11 or newer, and appears to be actively maintained with recent updates.
Common errors
-
Failed to connect to MCP server: Connection timed out
cause The client (AI agent/IDE) could not establish a connection with the MCP server within the allowed time. This can be due to the server not running, network issues, or server overload.fixEnsure the `office-word-mcp-server` process is running correctly. Check for firewall blocks, verify network connectivity, and ensure the server isn't overloaded. If running locally, confirm no other process is blocking the port. -
401 Unauthorized: Invalid API key
cause The client attempted to connect to the MCP server without proper authentication credentials, or with an incorrect/expired API key.fixVerify that your AI client or IDE is configured with the correct API key. Ensure the API key is not expired and is provided with the correct prefix (e.g., 'Bearer ' or 'Key ') and no leading/trailing whitespace. -
Error: Document lacks required styles for heading operations.
cause The target Word document does not contain the expected styles for operations like adding headings, forcing the server to use direct formatting as a fallback.fixModify the Word document to include standard heading styles (e.g., 'Heading 1', 'Heading 2'). For new documents, start with a template that defines these styles.
Warnings
- gotcha The `office-word-mcp-server` operates as a standalone service designed for AI agent integration, not as a library for direct Python function calls within a script. Your AI client or IDE must be configured to connect to the running MCP server.
- gotcha Documents lacking standard Word styles may lead to the server applying direct formatting instead of style-based formatting, which can result in inconsistent document appearance or difficulty in future edits.
- gotcha File system permission issues can prevent the server from reading or writing Word documents to specified paths, leading to errors or failed operations.
Install
-
pip install office-word-mcp-server
Quickstart
# 1. Install the server (if not already installed)
# pip install office-word-mcp-server
# 2. Run the MCP server. This makes its capabilities available via a local API.
# The `uvx` command is often used for running CLI entry points from installed packages.
# Ensure `uv` is installed (pip install uv) if `uvx` is not available.
import subprocess
import os
# This command typically runs in a separate terminal or as a background service.
# For a quick demo, we can run it via subprocess (though not ideal for production).
# In a real scenario, you'd configure your AI agent/IDE to start and connect to it.
print("Starting Office Word MCP Server...")
# Use a placeholder for a real AI agent configuration or an actual API call
# The server logs its activity, and AI agents communicate via its exposed API.
# Example command from GitHub README [2]
# For demonstration, we'll just print the command. Actual execution would block or run in background.
server_command = "uvx --from office-word-mcp-server word_mcp_server"
print(f"Execute this in your terminal: {server_command}")
# To simulate interaction, an AI agent would make API calls like:
# create_document(filename="report.docx", title="Quarterly Report")
# add_heading(filename="report.docx", text="Introduction", level=1)
# add_paragraph(filename="report.docx", text="This is the first paragraph of the report.")
print("\nServer started. An AI agent can now interact with it, e.g., to create or edit Word documents.")
print("Refer to your AI agent's documentation for connecting to a local MCP server.")