Content
# MCP Server for Microsoft Word (docx)
**MCP Word Server** is a simple CLI server built on Node.js that implements the Model Context Protocol (MCP) for creating and managing Microsoft Word documents (format `.docx`). Using JSON commands sent through standard input/output, you can:
- Create and save documents.
- Add and format text (paragraphs, headings, lists).
- Work with tables (creation, rows, styles, merging cells).
- Insert images and captions.
- Manage headers and page numbering.
- Configure layout (margins, orientation, breaks).
- Set document metadata (title, author, subject).
## 📦 Installation
1. Clone the repository:
```bash
git clone https://github.com/<your-account>/mcp-word-server.git
cd mcp-word-server
```
2. Install dependencies:
```bash
npm install
```
## 🚀 Running
```bash
node server.js
```
When started, the server is ready to accept JSON commands via `stdin` and will respond with a JSON object in `stdout`.
## 🔧 MCP Client Configuration
Add to your `cline_mcp_settings.json` file:
```json
{
"mcpServers": {
"word-server": {
"command": "node",
"args": ["server.js"],
"env": {},
"disabled": false,
"autoApprove": [
"create_document",
"add_paragraph",
"add_heading",
"add_bullet_list",
"add_numbered_list",
"set_alignment",
"set_font_size",
"set_font_family",
"set_spacing",
"add_table",
"add_table_row",
"set_table_style",
"merge_cells",
"insert_image",
"insert_image_with_caption",
"add_header",
"add_footer",
"add_page_numbering",
"add_page_break",
"set_margins",
"set_orientation",
"set_title",
"set_author",
"set_subject",
"save_document"
]
}
}
}
```
## 📝 Command List
All commands accept an object `{ command: string, params?: any }` and return `{ command, status, result? | error? }`.
### 1. Creation and Saving
- **create_document** — creates a new document. Optionally, you can pass `{ title, author, subject }`.
- **save_document** — saves the document to a file. Parameter `{ path: string }`.
### 2. Working with Text
- **add_paragraph** `{ text: string }`
- **add_heading** `{ text: string, level?: number }`
- **add_bullet_list** `{ items: string[] }`
- **add_numbered_list** `{ items: string[] }`
- **set_alignment** `{ alignment: "left"|"center"|"right"|"justify" }`
- **set_font_size** `{ size: number }` (in points)
- **set_font_family** `{ name: string }`
- **set_spacing** `{ before?: number, after?: number, line?: number }` or `number` (line spacing)
### 3. Tables
- **add_table** `{ data?: string[][] }`
- **add_table_row** `{ cells: string[] }`
- **set_table_style** `{ style: string }`
- **merge_cells** `{ startRow, startCol, endRow, endCol }`
### 4. Images
- **insert_image** `{ path: string, width?: number, height?: number }`
- **insert_image_with_caption** `{ path: string, caption: string, width?: number, height?: number }`
### 5. Headers and Numbering
- **add_header** `{ text: string }`
- **add_footer** `{ text: string }`
- **add_page_numbering** `{} // adds "Page X of Y" in footer`
### 6. Layout
- **add_page_break** `{}`
- **set_margins** `{ top:number, bottom:number, left:number, right:number }` (cm or inches)
- **set_orientation** `{ orientation: "portrait"|"landscape" }`
### 7. Metadata
- **set_title** `{ title: string }`
- **set_author** `{ author: string }`
- **set_subject** `{ subject: string }`
## 📋 Usage Examples
Example interaction via `stdin`:
```json
{ "command": "create_document", "params": { "title": "Report" } }
{ "command": "add_heading", "params": { "text": "Report Title", "level": 1 } }
{ "command": "add_paragraph", "params": { "text": "Main text of the paragraph." } }
{ "command": "add_table", "params": { "data": [["Parameter","Value"],["Temperature","25°C"]] } }
{ "command": "insert_image_with_caption", "params": { "path": "diagram.jpg", "caption": "Figure 1. Diagram." } }
{ "command": "add_page_numbering" }
{ "command": "save_document", "params": { "path": "report.docx" } }
```
## 🛠️ Development and Contribution
- **Node.js** v14+ and **npm**
- Main dependency: [docx](https://www.npmjs.com/package/docx)
Please create issues and pull requests for improvements and fixes.
## 📄 License
MIT © 2025
You Might Also Like
UI-TARS-desktop
UI-TARS-desktop is part of the TARS Multimodal AI Agent stack.
inbox-zero
Inbox Zero is an open source AI email assistant to help you manage emails...
DesktopCommanderMCP
Desktop Commander MCP allows AI-driven file management and terminal command...
experiments-with-mcp
A collection of practical experiments with MCP using various libraries.
guidance-for-deploying-model-context-protocol-servers-on-aws
Guidance for deploying Model Context Protocol servers on AWS with secure...
mcp-hubspot
MCP server for AI assistants to access HubSpot CRM data efficiently.