Skip to main content
Glama

MCP DOCX Template Server

A portable MCP server that clones a styled Microsoft Word template and fills it with content from another document, preserving images, layout, fonts, colors, and paragraph styles.

Tools

The server exposes three tools:

  • analyze_template — Inspect a .docx template and return its paragraph structure, images, styles, and a content schema. Also writes a <template>.docx.md descriptor next to the template so repeat lookups (e.g. by the map_content_to_template prompt) don't need to re-analyze it.

  • extract_content — Extract editable text blocks from a content .docx.

  • fill_template — Clone the template and replace its editable text using a label-to-text mapping. Optionally converts the result to PDF.

Related MCP server: Word MCP Server

Prompts

  • map_content_to_template — Given a template_path and content_path, reads the template's .docx.md descriptor (analyzing and writing it first if it doesn't exist yet) plus the extracted content, and returns an instruction message for building a content_mapping. The assistant is told to ask the user directly when a mapping is ambiguous, then call fill_template.

Installation

pip install .

Or, for development with tests:

pip install -e ".[dev]"

Usage with Claude Desktop

Add the server to your Claude Desktop configuration (claude_desktop_config.json):

{
  "mcpServers": {
    "docx-template": {
      "command": "mcp-docx-template-server"
    }
  }
}

The server uses stdio transport. Once configured, Claude can call analyze_template, extract_content, and fill_template.

Example flow

  1. Analyze the template:

{
  "template_path": "/path/to/SSIT_Template.docx"
}
  1. Extract content from the source document:

{
  "content_path": "/path/to/NetApp_Content.docx"
}
  1. Fill the template:

{
  "template_path": "/path/to/SSIT_Template.docx",
  "content_mapping": {
    "overview": "NetApp Cutover Dependency Mapper",
    "business_challenge": "Business Challenge",
    "body_1": "Long body paragraph...",
    "solution_item_1": "Title\nBody text..."
  },
  "output_path": "/path/to/output.docx",
  "convert_to_pdf": true
}

Development

Run tests:

pytest

License

MIT

Related MCP Connectors

Related MCP Servers