Skip to content
Back to search

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.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/gongrzhe--office-word-mcp-server/badge.svg)](/listings/gongrzhe--office-word-mcp-server)

HTML

<a href="/listings/gongrzhe--office-word-mcp-server"><img src="/api/listings/gongrzhe--office-word-mcp-server/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Installing via Smithery

To install Office Word Document Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@GongRzhe/Office-Word-MCP-Server):

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

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

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 394 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # Office-Word-MCP-Server
  2. [![smithery badge](https://smithery.ai/badge/@GongRzhe/Office-Word-MCP-Server)](https://smithery.ai/server/@GongRzhe/Office-Word-MCP-Server)
  3. 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.
  4. <a href="https://glama.ai/mcp/servers/@GongRzhe/Office-Word-MCP-Server">
  5. <img width="380" height="200" src="https://glama.ai/mcp/servers/@GongRzhe/Office-Word-MCP-Server/badge" alt="Office Word Server MCP server" />
  6. </a>
  7. ![](https://badge.mcpx.dev?type=server "MCP Server")
  8. ## Overview
  9. Office-Word-MCP-Server implements the [Model Context Protocol](https://modelcontextprotocol.io/) 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.
  10. The server features a modular architecture that separates concerns into core functionality, tools, and utilities, making it highly maintainable and extensible for future enhancements.
  11. ### Example
  12. #### Pormpt
  13. ![image](https://github.com/user-attachments/assets/f49b0bcc-88b2-4509-bf50-995b9a40038c)
  14. #### Output
  15. ![image](https://github.com/user-attachments/assets/ff64385d-3822-4160-8cdf-f8a484ccc01a)
  16. ## Features
  17. ### Document Management
  18. - Create new Word documents with metadata
  19. - Extract text and analyze document structure
  20. - View document properties and statistics
  21. - List available documents in a directory
  22. - Create copies of existing documents
  23. - Merge multiple documents into a single document
  24. - Convert Word documents to PDF format
  25. ### Content Creation
  26. - Add headings with different levels and direct formatting (font, size, bold, italic, borders)
  27. - Insert paragraphs with optional styling and direct formatting (font, size, bold, italic, color)
  28. - Create tables with custom data
  29. - Add images with proportional scaling
  30. - Insert page breaks
  31. - Insert bulleted and numbered lists with proper XML formatting
  32. - Add footnotes and endnotes to documents
  33. - Convert footnotes to endnotes
  34. - Customize footnote and endnote styling
  35. - Create professional table layouts for technical documentation
  36. - Design callout boxes and formatted content for instructional materials
  37. - Build structured data tables for business reports with consistent styling
  38. - Insert content relative to existing text or paragraph indices
  39. ### Rich Text Formatting
  40. - Format specific text sections (bold, italic, underline)
  41. - Change text color and font properties
  42. - Apply custom styles to text elements
  43. - Search and replace text throughout documents
  44. - Individual cell text formatting within tables
  45. - Multiple formatting combinations for enhanced visual appeal
  46. - Font customization with family and size control
  47. - Direct formatting during content creation (paragraphs and headings)
  48. - Reduce function calls by combining content creation with formatting
  49. - Add section header borders for visual separation
  50. ### Table Formatting
  51. - Format tables with borders and styles
  52. - Create header rows with distinct formatting
  53. - Apply cell shading and custom borders
  54. - Structure tables for better readability
  55. - Individual cell background shading with color support
  56. - Alternating row colors for improved readability
  57. - Enhanced header row highlighting with custom colors
  58. - Cell text formatting with bold, italic, underline, color, font size, and font family
  59. - Comprehensive color support with named colors and hex color codes
  60. - Cell padding management with independent control of all sides
  61. - Cell alignment (horizontal and vertical positioning)
  62. - Cell merging (horizontal, vertical, and rectangular areas)
  63. - Column width management with multiple units (points, percentage, auto-fit)
  64. - Auto-fit capabilities for dynamic column sizing
  65. - Professional callout table support with icon cells and styled content
  66. ### Advanced Document Manipulation
  67. - Delete paragraphs
  68. - Insert content relative to specific text or paragraph indices
  69. - Insert bulleted and numbered lists with proper XML numbering structure
  70. - Insert headers and paragraphs before or after target locations
  71. - Create custom document styles
  72. - Apply consistent formatting throughout documents
  73. - Format specific ranges of text with detailed control
  74. - Flexible padding units with support for points and percentage-based measurements
  75. - Clear, readable table presentation with proper alignment and spacing
  76. ### Document Protection
  77. - Add password protection to documents
  78. - Implement restricted editing with editable sections
  79. - Add digital signatures to documents
  80. - Verify document authenticity and integrity
  81. ### Comment Extraction
  82. - Extract all comments from a document
  83. - Filter comments by author
  84. - Get comments for specific paragraphs
  85. - Access comment metadata (author, date, text)
  86. ## Installation
  87. ### Installing via Smithery
  88. To install Office Word Document Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@GongRzhe/Office-Word-MCP-Server):
  89. ```bash
  90. npx -y @smithery/cli install @GongRzhe/Office-Word-MCP-Server --client claude
  91. ```
  92. ### Prerequisites
  93. - Python 3.8 or higher
  94. - pip package manager
  95. ### Basic Installation
  96. ```bash
  97. # Clone the repository
  98. git clone https://github.com/GongRzhe/Office-Word-MCP-Server.git
  99. cd Office-Word-MCP-Server
  100. # Install dependencies
  101. pip install -r requirements.txt
  102. ```
  103. ### Using the Setup Script
  104. Alternatively, you can use the provided setup script which handles:
  105. - Checking prerequisites
  106. - Setting up a virtual environment
  107. - Installing dependencies
  108. - Generating MCP configuration
  109. ```bash
  110. python setup_mcp.py
  111. ```
  112. ## Usage with Claude for Desktop
  113. ### Configuration
  114. #### Method 1: After Local Installation
  115. 1. After installation, add the server to your Claude for Desktop configuration file:
  116. ```json
  117. {
  118. "mcpServers": {
  119. "word-document-server": {
  120. "command": "python",
  121. "args": ["/path/to/word_mcp_server.py"]
  122. }
  123. }
  124. }
  125. ```
  126. #### Method 2: Without Installation (Using uvx)
  127. 1. You can also configure Claude for Desktop to use the server without local installation by using the uvx package manager:
  128. ```json
  129. {
  130. "mcpServers": {
  131. "word-document-server": {
  132. "command": "uvx",
  133. "args": ["--from", "office-word-mcp-server", "word_mcp_server"]
  134. }
  135. }
  136. }
  137. ```
  138. 2. Configuration file locations:
  139. - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
  140. - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
  141. 3. Restart Claude for Desktop to load the configuration.
  142. ### Example Operations
  143. Once configured, you can ask Claude to perform operations like:
  144. - "Create a new document called 'report.docx' with a title page"
  145. - "Add a heading and three paragraphs to my document"
  146. - "Add my name in Helvetica 36pt bold at the top of the document"
  147. - "Add a section heading 'Summary' in Helvetica 14pt bold with a bottom border"
  148. - "Add a paragraph in Times New Roman 14pt with italic blue text"
  149. - "Insert a bulleted list after the paragraph containing 'Introduction'"
  150. - "Insert a numbered list with items: 'First step', 'Second step', 'Third step'"
  151. - "Add bullet points after the 'Summary' heading"
  152. - "Insert a 4x4 table with sales data"
  153. - "Format the word 'important' in paragraph 2 to be bold and red"
  154. - "Search and replace all instances of 'old term' with 'new term'"
  155. - "Create a custom style for section headings"
  156. - "Apply formatting to the table in my document"
  157. - "Extract all comments from my document"
  158. - "Show me all comments by John Doe"
  159. - "Get comments for paragraph 3"
  160. - "Make the text in table cell (1,2) bold and blue with 14pt font"
  161. - "Add 10 points of padding to all sides of the header cells"
  162. - "Create a callout table with a blue checkmark icon and white text"
  163. - "Set the first column width to 50 points and auto-fit the remaining columns"
  164. - "Apply alternating row colors to make the table more readable"
  165. ## API Reference
  166. ### Document Creation and Properties
  167. ```python
  168. create_document(filename, title=None, author=None)
  169. get_document_info(filename)
  170. get_document_text(filename)
  171. get_document_outline(filename)
  172. list_available_documents(directory=".")
  173. copy_document(source_filename, destination_filename=None)
  174. convert_to_pdf(filename, output_filename=None)
  175. ```
  176. ### Content Addition
  177. ```python
  178. add_heading(filename, text, level=1, font_name=None, font_size=None,
  179. bold=None, italic=None, border_bottom=False)
  180. add_paragraph(filename, text, style=None, font_name=None, font_size=None,
  181. bold=None, italic=None, color=None)
  182. add_table(filename, rows, cols, data=None)
  183. add_picture(filename, image_path, width=None)
  184. add_page_break(filename)
  185. ```
  186. ### Advanced Content Manipulation
  187. ```python
  188. # Insert content relative to existing text or paragraph index
  189. insert_header_near_text(filename, target_text=None, header_title=None,
  190. position='after', header_style='Heading 1',
  191. target_paragraph_index=None)
  192. insert_line_or_paragraph_near_text(filename, target_text=None, line_text=None,
  193. position='after', line_style=None,
  194. target_paragraph_index=None)
  195. # Insert bulleted or numbered lists with proper XML formatting
  196. insert_numbered_list_near_text(filename, target_text=None, list_items=None,
  197. position='after', target_paragraph_index=None,
  198. bullet_type='bullet')
  199. # bullet_type options:
  200. # 'bullet' - Creates bulleted list with bullets (•)
  201. # 'number' - Creates numbered list (1, 2, 3, ...)
  202. ```
  203. ### Content Extraction
  204. ```python
  205. get_document_text(filename)
  206. get_paragraph_text_from_document(filename, paragraph_index)
  207. find_text_in_document(filename, text_to_find, match_case=True, whole_word=False)
  208. ```
  209. ### Text Formatting
  210. ```python
  211. format_text(filename, paragraph_index, start_pos, end_pos, bold=None,
  212. italic=None, underline=None, color=None, font_size=None, font_name=None)
  213. search_and_replace(filename, find_text, replace_text)
  214. delete_paragraph(filename, paragraph_index)
  215. create_custom_style(filename, style_name, bold=None, italic=None,
  216. font_size=None, font_name=None, color=None, base_style=None)
  217. ```
  218. ### Table Formatting
  219. ```python
  220. format_table(filename, table_index, has_header_row=None,
  221. border_style=None, shading=None)
  222. set_table_cell_shading(filename, table_index, row_index, col_index,
  223. fill_color, pattern="clear")
  224. apply_table_alternating_rows(filename, table_index,
  225. color1="FFFFFF", color2="F2F2F2")
  226. highlight_table_header(filename, table_index,
  227. header_color="4472C4", text_color="FFFFFF")
  228. # Cell merging tools
  229. merge_table_cells(filename, table_index, start_row, start_col, end_row, end_col)
  230. merge_table_cells_horizontal(filename, table_index, row_index, start_col, end_col)
  231. merge_table_cells_vertical(filename, table_index, col_index, start_row, end_row)
  232. # Cell alignment tools
  233. set_table_cell_alignment(filename, table_index, row_index, col_index,
  234. horizontal="left", vertical="top")
  235. set_table_alignment_all(filename, table_index,
  236. horizontal="left", vertical="top")
  237. # Cell text formatting tools
  238. format_table_cell_text(filename, table_index, row_index, col_index,
  239. text_content=None, bold=None, italic=None, underline=None,
  240. color=None, font_size=None, font_name=None)
  241. # Cell padding tools
  242. set_table_cell_padding(filename, table_index, row_index, col_index,
  243. top=None, bottom=None, left=None, right=None, unit="points")
  244. # Column width management
  245. set_table_column_width(filename, table_index, col_index, width, width_type="points")
  246. set_table_column_widths(filename, table_index, widths, width_type="points")
  247. set_table_width(filename, table_index, width, width_type="points")
  248. auto_fit_table_columns(filename, table_index)
  249. ```
  250. ### Comment Extraction
  251. ```python
  252. get_all_comments(filename)
  253. get_comments_by_author(filename, author)
  254. get_comments_for_paragraph(filename, paragraph_index)
  255. ```
  256. ## Troubleshooting
  257. ### Common Issues
  258. 1. **Missing Styles**
  259. - Some documents may lack required styles for heading and table operations
  260. - The server will attempt to create missing styles or use direct formatting
  261. - For best results, use templates with standard Word styles
  262. 2. **Permission Issues**
  263. - Ensure the server has permission to read/write to the document paths
  264. - Use the `copy_document` function to create editable copies of locked documents
  265. - Check file ownership and permissions if operations fail
  266. 3. **Image Insertion Problems**
  267. - Use absolute paths for image files
  268. - Verify image format compatibility (JPEG, PNG recommended)
  269. - Check image file size and permissions
  270. 4. **Table Formatting Issues**
  271. - **Cell index errors**: Ensure row and column indices are within table bounds (0-based indexing)
  272. - **Color format problems**: Use hex colors without '#' prefix (e.g., "FF0000" for red) or standard color names
  273. - **Padding unit confusion**: Specify "points" or "percent" explicitly when setting cell padding
  274. - **Column width conflicts**: Auto-fit may override manual column width settings
  275. - **Text formatting persistence**: Apply cell text formatting after setting cell content for best results
  276. ### Debugging
  277. Enable detailed logging by setting the environment variable:
  278. ```bash
  279. export MCP_DEBUG=1 # Linux/macOS
  280. set MCP_DEBUG=1 # Windows
  281. ```
  282. ## Contributing
  283. Contributions are welcome! Please feel free to submit a Pull Request.
  284. 1. Fork the repository
  285. 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
  286. 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
  287. 4. Push to the branch (`git push origin feature/amazing-feature`)
  288. 5. Open a Pull Request
  289. ## License
  290. This project is licensed under the MIT License - see the LICENSE file for details.
  291. ## Acknowledgments
  292. - [Model Context Protocol](https://modelcontextprotocol.io/) for the protocol specification
  293. - [python-docx](https://python-docx.readthedocs.io/) for Word document manipulation
  294. - [FastMCP](https://github.com/modelcontextprotocol/python-sdk) for the Python MCP implementation
  295. ---
  296. _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._

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.