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.
A Model Context Protocol server that enables AI assistants to create, read, edit, and format Microsoft Word documents through standardized tools and resources.
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.
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.
# 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
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
{
"mcpServers": {
"word-document-server": {
"command": "python",
"args": [
"/path/to/word_server.py"
]
}
}
}
{
"mcpServers": {
"word-document-server": {
"command": "uvx",
"args": [
"--from", "office-word-mcp-server", "word_mcp_server"
]
}
}
}
~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%Claudeclaude_desktop_config.json
Restart Claude for Desktop to load the configuration.
Once configured, you can ask Claude to perform operations like:
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)
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)
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)
format_table(filename, table_index, has_header_row=None,
border_style=None, shading=None)
For best results, use templates with standard Word styles
Permission Issues
copy_document
function to create editable copies of locked documentsCheck file ownership and permissions if operations fail
Image Insertion Problems
Enable detailed logging by setting the environment variable:
export MCP_DEBUG=1 # Linux/macOS
set MCP_DEBUG=1 # Windows
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.
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.
[
{
"description": "Create a new Word document with optional metadata.n n Args:n filename: Name of the document to create (with or without .docx extension)n title: Optional title for the document metadatan author: Optional author for the document metadatan ",
"inputSchema": {
"properties": {
"author": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Author"
},
"filename": {
"title": "Filename",
"type": "string"
},
"title": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Title"
}
},
"required": [
"filename"
],
"title": "create_documentArguments",
"type": "object"
},
"name": "create_document"
},
{
"description": "Add a heading to a Word document.n n Args:n filename: Path to the Word documentn text: Heading textn level: Heading level (1-9, where 1 is the highest level)n ",
"inputSchema": {
"properties": {
"filename": {
"title": "Filename",
"type": "string"
},
"level": {
"default": 1,
"title": "Level",
"type": "integer"
},
"text": {
"title": "Text",
"type": "string"
}
},
"required": [
"filename",
"text"
],
"title": "add_headingArguments",
"type": "object"
},
"name": "add_heading"
},
{
"description": "Add a paragraph to a Word document.n n Args:n filename: Path to the Word documentn text: Paragraph textn style: Optional paragraph style namen ",
"inputSchema": {
"properties": {
"filename": {
"title": "Filename",
"type": "string"
},
"style": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Style"
},
"text": {
"title": "Text",
"type": "string"
}
},
"required": [
"filename",
"text"
],
"title": "add_paragraphArguments",
"type": "object"
},
"name": "add_paragraph"
},
{
"description": "Add a table to a Word document.n n Args:n filename: Path to the Word documentn rows: Number of rows in the tablen cols: Number of columns in the tablen data: Optional 2D array of data to fill the tablen ",
"inputSchema": {
"properties": {
"cols": {
"title": "Cols",
"type": "integer"
},
"data": {
"anyOf": [
{
"items": {
"items": {
"type": "string"
},
"type": "array"
},
"type": "array"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Data"
},
"filename": {
"title": "Filename",
"type": "string"
},
"rows": {
"title": "Rows",
"type": "integer"
}
},
"required": [
"filename",
"rows",
"cols"
],
"title": "add_tableArguments",
"type": "object"
},
"name": "add_table"
},
{
"description": "Add an image to a Word document.n n Args:n filename: Path to the Word documentn image_path: Path to the image filen width: Optional width in inches (proportional scaling)n ",
"inputSchema": {
"properties": {
"filename": {
"title": "Filename",
"type": "string"
},
"image_path": {
"title": "Image Path",
"type": "string"
},
"width": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Width"
}
},
"required": [
"filename",
"image_path"
],
"title": "add_pictureArguments",
"type": "object"
},
"name": "add_picture"
},
{
"description": "Get information about a Word document.n n Args:n filename: Path to the Word documentn ",
"inputSchema": {
"properties": {
"filename": {
"title": "Filename",
"type": "string"
}
},
"required": [
"filename"
],
"title": "get_document_infoArguments",
"type": "object"
},
"name": "get_document_info"
},
{
"description": "Extract all text from a Word document.n n Args:n filename: Path to the Word documentn ",
"inputSchema": {
"properties": {
"filename": {
"title": "Filename",
"type": "string"
}
},
"required": [
"filename"
],
"title": "get_document_textArguments",
"type": "object"
},
"name": "get_document_text"
},
{
"description": "Get the structure of a Word document.n n Args:n filename: Path to the Word documentn ",
"inputSchema": {
"properties": {
"filename": {
"title": "Filename",
"type": "string"
}
},
"required": [
"filename"
],
"title": "get_document_outlineArguments",
"type": "object"
},
"name": "get_document_outline"
},
{
"description": "List all .docx files in the specified directory.n n Args:n directory: Directory to search for Word documentsn ",
"inputSchema": {
"properties": {
"directory": {
"default": ".",
"title": "Directory",
"type": "string"
}
},
"title": "list_available_documentsArguments",
"type": "object"
},
"name": "list_available_documents"
},
{
"description": "Create a copy of a Word document.n n Args:n source_filename: Path to the source documentn destination_filename: Optional path for the copy. If not provided, a default name will be generated.n ",
"inputSchema": {
"properties": {
"destination_filename": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Destination Filename"
},
"source_filename": {
"title": "Source Filename",
"type": "string"
}
},
"required": [
"source_filename"
],
"title": "copy_documentArguments",
"type": "object"
},
"name": "copy_document"
},
{
"description": "Format a specific range of text within a paragraph.n n Args:n filename: Path to the Word documentn paragraph_index: Index of the paragraph (0-based)n start_pos: Start position within the paragraph textn end_pos: End position within the paragraph textn bold: Set text bold (True/False)n italic: Set text italic (True/False)n underline: Set text underlined (True/False)n color: Text color (e.g., 'red', 'blue', etc.)n font_size: Font size in pointsn font_name: Font name/familyn ",
"inputSchema": {
"properties": {
"bold": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Bold"
},
"color": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Color"
},
"end_pos": {
"title": "End Pos",
"type": "integer"
},
"filename": {
"title": "Filename",
"type": "string"
},
"font_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Font Name"
},
"font_size": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Font Size"
},
"italic": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Italic"
},
"paragraph_index": {
"title": "Paragraph Index",
"type": "integer"
},
"start_pos": {
"title": "Start Pos",
"type": "integer"
},
"underline": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Underline"
}
},
"required": [
"filename",
"paragraph_index",
"start_pos",
"end_pos"
],
"title": "format_textArguments",
"type": "object"
},
"name": "format_text"
},
{
"description": "Search for text and replace all occurrences.n n Args:n filename: Path to the Word documentn find_text: Text to search forn replace_text: Text to replace withn ",
"inputSchema": {
"properties": {
"filename": {
"title": "Filename",
"type": "string"
},
"find_text": {
"title": "Find Text",
"type": "string"
},
"replace_text": {
"title": "Replace Text",
"type": "string"
}
},
"required": [
"filename",
"find_text",
"replace_text"
],
"title": "search_and_replaceArguments",
"type": "object"
},
"name": "search_and_replace"
},
{
"description": "Delete a paragraph from a document.n n Args:n filename: Path to the Word documentn paragraph_index: Index of the paragraph to delete (0-based)n ",
"inputSchema": {
"properties": {
"filename": {
"title": "Filename",
"type": "string"
},
"paragraph_index": {
"title": "Paragraph Index",
"type": "integer"
}
},
"required": [
"filename",
"paragraph_index"
],
"title": "delete_paragraphArguments",
"type": "object"
},
"name": "delete_paragraph"
},
{
"description": "Create a custom style in the document.n n Args:n filename: Path to the Word documentn style_name: Name for the new stylen bold: Set text bold (True/False)n italic: Set text italic (True/False)n font_size: Font size in pointsn font_name: Font name/familyn color: Text color (e.g., 'red', 'blue')n base_style: Optional existing style to base this onn ",
"inputSchema": {
"properties": {
"base_style": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Base Style"
},
"bold": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Bold"
},
"color": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Color"
},
"filename": {
"title": "Filename",
"type": "string"
},
"font_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Font Name"
},
"font_size": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Font Size"
},
"italic": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Italic"
},
"style_name": {
"title": "Style Name",
"type": "string"
}
},
"required": [
"filename",
"style_name"
],
"title": "create_custom_styleArguments",
"type": "object"
},
"name": "create_custom_style"
},
{
"description": "Format a table with borders, shading, and structure.n n Args:n filename: Path to the Word documentn table_index: Index of the table (0-based)n has_header_row: If True, formats the first row as a headern border_style: Style for borders ('none', 'single', 'double', 'thick')n shading: 2D list of cell background colors (by row and column)n ",
"inputSchema": {
"properties": {
"border_style": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Border Style"
},
"filename": {
"title": "Filename",
"type": "string"
},
"has_header_row": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Has Header Row"
},
"shading": {
"anyOf": [
{
"items": {
"items": {
"type": "string"
},
"type": "array"
},
"type": "array"
},
{
"type": "null"
}
],
"default": {
"path": "word_server.py",
"type": "blob"
},
"title": "Shading"
},
"table_index": {
"title": "Table Index",
"type": "integer"
}
},
"required": [
"filename",
"table_index"
],
"title": "format_tableArguments",
"type": "object"
},
"name": "format_table"
},
{
"description": "Add a page break to the document.n n Args:n filename: Path to the Word documentn ",
"inputSchema": {
"properties": {
"filename": {
"title": "Filename",
"type": "string"
}
},
"required": [
"filename"
],
"title": "add_page_breakArguments",
"type": "object"
},
"name": "add_page_break"
}
]