Word Interop MCP server

Enables automated Microsoft Word document manipulation by exposing comprehensive tools for text editing, formatting, table management, image insertion, and page setup through a Windows-specific COM Interop server.
Back to servers
Setup instructions
Provider
Mario Andreschak
Release date
Mar 27, 2025
Language
TypeScript
Stats
10 stars

This MCP Office Interop Word Server allows you to programmatically control Microsoft Word documents through the Model Context Protocol (MCP). It's a bridge between MCP clients and Word's COM automation capabilities on Windows.

Prerequisites

  • Node.js (v18 or later recommended)
  • npm
  • Microsoft Word installed on a Windows machine

Installation

  1. Clone the repository or download the source code
  2. Navigate to the project directory in your terminal
  3. Install dependencies:
npm install
  1. Build the TypeScript code:
npm run build

Running the Server

The server supports two different MCP transport methods:

Using stdio Transport (Default)

This mode is suitable for local clients communicating via standard input/output:

npm start

or

node dist/index.js

Connect your MCP client using the stdio method, pointing to the node dist/index.js command.

Using SSE Transport

This mode uses HTTP and Server-Sent Events for web-based or remote clients:

PowerShell:

$env:MCP_TRANSPORT="sse"; npm start

Bash / Cmd:

MCP_TRANSPORT=sse npm start

The server starts an HTTP server on port 3001 (or the port specified by the PORT environment variable) with:

  • SSE Endpoint: http://localhost:3001/sse
  • Message Endpoint: http://localhost:3001/messages

Available Tools

Document Operations

  • word_createDocument: Creates a new, blank Word document
  • word_openDocument: Opens an existing document
    • filePath (string): Absolute path to the document
  • word_saveActiveDocument: Saves the currently active document
  • word_saveActiveDocumentAs: Saves the active document to a new path/format
    • filePath (string): Absolute path to save to
    • fileFormat (number, optional): Numeric WdSaveFormat value (e.g., 16 for docx, 17 for pdf)
  • word_closeActiveDocument: Closes the active document
    • saveChanges (number, optional): WdSaveOptions value (0=No, -1=Yes, -2=Prompt). Default: 0

Text Manipulation

  • word_insertText: Inserts text at the selection
    • text (string): Text to insert
  • word_deleteText: Deletes text relative to the selection
    • count (number, optional): Number of units to delete (default: 1). Positive=forward, negative=backward
    • unit (number, optional): WdUnits value (1=Char, 2=Word, etc.). Default: 1
  • word_findAndReplace: Finds and replaces text
    • findText (string): Text to find
    • replaceText (string): Replacement text
    • matchCase (boolean, optional): Default: false
    • matchWholeWord (boolean, optional): Default: false
    • replaceAll (boolean, optional): Default: true
  • word_toggleBold: Toggles bold formatting for the selection
  • word_toggleItalic: Toggles italic formatting for the selection
  • word_toggleUnderline: Toggles underline formatting for the selection
    • underlineStyle (number, optional): WdUnderline value (default: 1=Single)

Paragraph Formatting

  • word_setParagraphAlignment: Sets paragraph alignment
    • alignment (number): WdParagraphAlignment value (0=Left, 1=Center, 2=Right, 3=Justify)
  • word_setParagraphLeftIndent: Sets left indent
    • indentPoints (number): Indent value in points
  • word_setParagraphRightIndent: Sets right indent
    • indentPoints (number): Indent value in points
  • word_setParagraphFirstLineIndent: Sets first line/hanging indent
    • indentPoints (number): Indent value in points (positive=indent, negative=hanging)
  • word_setParagraphSpaceBefore: Sets space before paragraphs
    • spacePoints (number): Space value in points
  • word_setParagraphSpaceAfter: Sets space after paragraphs
    • spacePoints (number): Space value in points
  • word_setParagraphLineSpacing: Sets line spacing
    • lineSpacingRule (number): WdLineSpacing value (0=Single, 1=1.5, 2=Double, 3=AtLeast, 4=Exactly, 5=Multiple)
    • lineSpacingValue (number, optional): Value needed for rules 3, 4, 5

Table Operations

  • word_addTable: Adds a table at the selection
    • numRows (number): Number of rows
    • numCols (number): Number of columns
  • word_setTableCellText: Sets text in a table cell
    • tableIndex (number): 1-based table index
    • rowIndex (number): 1-based row index
    • colIndex (number): 1-based column index
    • text (string): Text to set
  • word_insertTableRow: Inserts a row into a table
    • tableIndex (number): 1-based table index
    • beforeRowIndex (number, optional): Insert before this 1-based row index (or at end if omitted)
  • word_insertTableColumn: Inserts a column into a table
    • tableIndex (number): 1-based table index
    • beforeColIndex (number, optional): Insert before this 1-based column index (or at right end if omitted)
  • word_applyTableAutoFormat: Applies a style to a table
    • tableIndex (number): 1-based table index
    • formatName (string | number): Style name or WdTableFormat value

Image Operations

  • word_insertPicture: Inserts an inline picture
    • filePath (string): Absolute path to the image file
    • linkToFile (boolean, optional): Default: false
    • saveWithDocument (boolean, optional): Default: true
  • word_setInlinePictureSize: Resizes an inline picture
    • shapeIndex (number): 1-based index of the inline shape
    • heightPoints (number): Height in points (-1 or 0 to auto-size)
    • widthPoints (number): Width in points (-1 or 0 to auto-size)
    • lockAspectRatio (boolean, optional): Default: true

Header/Footer Operations

  • word_setHeaderFooterText: Sets text in a header or footer
    • text (string): Text content
    • isHeader (boolean): True for header, false for footer
    • sectionIndex (number, optional): 1-based section index (default: 1)
    • headerFooterType (number, optional): WdHeaderFooterIndex value (1=Primary, 2=FirstPage, 3=EvenPages). Default: 1

Page Setup Operations

  • word_setPageMargins: Sets page margins
    • topPoints (number): Top margin in points
    • bottomPoints (number): Bottom margin in points
    • leftPoints (number): Left margin in points
    • rightPoints (number): Right margin in points
  • word_setPageOrientation: Sets page orientation
    • orientation (number): WdOrientation value (0=Portrait, 1=Landscape)
  • word_setPaperSize: Sets paper size
    • paperSize (number): WdPaperSize value (e.g., 1=Letter, 8=A4)

Usage Notes

  • This server requires Microsoft Word to be installed and accessible via COM Interop on Windows
  • You may need to refer to Word VBA documentation for specific constant values used in tool arguments
  • For production use, consider implementing more robust error handling

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "msoffice-interop-word" '{"command":"node","args":["dist/index.js"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "msoffice-interop-word": {
            "command": "node",
            "args": [
                "dist/index.js"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "msoffice-interop-word": {
            "command": "node",
            "args": [
                "dist/index.js"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later