DOCX MCP Server
The DOCX MCP Server is a Node.js-based Model Context Protocol (MCP) server that enables comprehensive creation, manipulation, and saving of DOCX documents using a structured JSON schema.
Core Capabilities:
Document Lifecycle: Create new DOCX documents from JSON, open existing
.docxfiles, save in-memory documents to disk, and export JSON modelsContent Management: Insert, replace, and remove content blocks by index with support for headings (6 levels), paragraphs, lists (nested ordered/unordered), tables, code blocks (180+ languages with syntax highlighting), images, page breaks, blockquotes, and text boxes
Rich Formatting: Apply comprehensive text styling including bold, italic, underline, colors, fonts, alignment, spacing, and indentation
Metadata Handling: Manage document properties like title, creator, subject, keywords, and dates
Page Layout Control: Configure page size (A4, Letter), orientation, margins, and headers/footers with dynamic elements like page numbers and dates
Image Support: Embed images from URLs, local files, or base64 data in PNG, JPEG formats
Document Registry: Maintain in-memory document management with unique IDs and querying capabilities
Schema Validation: Ensure valid document structure through JSON schema validation
Provides a Node.js-based MCP server for creating, editing, and managing DOCX documents with rich formatting, tables, images, code blocks, and headers/footers
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@DOCX MCP Server create a meeting agenda with headings and bullet points"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
docx-mcp
A Node.js MCP server that lets clients create, query, edit, and save DOCX documents using a JSON schema, powered by the docx library.
Features
Complete DOCX operations: Create, edit, and save Word documents via Model Context Protocol (MCP)
JSON Schema validation: Structured document definition with comprehensive validation
Rich content blocks:
Text & Headings: 6 heading levels with advanced formatting
Lists: Ordered/unordered lists with multiple numbering styles and nesting
Code Blocks: Syntax highlighting for 180+ languages with themes and line numbers
Tables: Full table support with styling and cell formatting
Images: URL downloads with fallback, local files, and base64 embedding
Page Control: Page breaks and section breaks
Advanced text formatting:
Basic: Bold, italic, underline, strikethrough, colors
Enhanced: Superscript, subscript, font families, highlights, small caps
Spacing: Character spacing, paragraph alignment, indentation
Document management: In-memory registry with unique IDs
Metadata support: Complete document properties and custom metadata
File operations: Open existing DOCX files and save to disk
Error handling: Graceful fallbacks and comprehensive validation
Related MCP server: Word Document MCP Server
JSON Schema
See src/schema.ts for the full schema. Key concepts:
meta: Document metadata (title, subject, creator, etc.)
pageSettings: Page size, orientation, margins, header/footer margins (NEW in v0.3.0)
headers: Page header configuration with default/first/even page support (NEW in v0.4.0)
footers: Page footer configuration with default/first/even page support (NEW in v0.4.0)
content: Array of blocks: heading, paragraph, table, image, codeBlock, list, pageBreak, horizontalRule, blockquote, infoBox, textBox
Enhanced blocks:
CodeBlock:
{ type: "codeBlock", language: "javascript", code: "...", showLineNumbers: true }List:
{ type: "list", ordered: true, items: [...] }with nesting supportTable: Enhanced with backgroundColor, borders, verticalAlign, cell margins (NEW in v0.3.0)
HorizontalRule:
{ type: "horizontalRule", style: "single", color: "#666" }(NEW in v0.3.0)Blockquote:
{ type: "blockquote", children: [...], borderColor: "#ccc" }(NEW in v0.3.0)InfoBox:
{ type: "infoBox", boxType: "info", title: "Note", children: [...] }(NEW in v0.3.0)TextBox:
{ type: "textBox", children: [...] }with border styling (NEW in v0.3.0)Enhanced TextRun: Supports fontFamily, superScript, subScript, highlight, etc.
Each paragraph/heading uses inline runs (text, hyperlink) with rich formatting options
Headers & Footers Configuration (NEW in v0.4.0)
{
"headers": {
"default": {
"alignment": "center",
"children": [
{
"type": "documentTitle",
"bold": true,
"size": 14,
"color": "#1f4788"
}
]
},
"first": {
"alignment": "right",
"children": [
{
"type": "text",
"text": "Confidential Document",
"bold": true,
"color": "#cc0000"
}
]
}
},
"footers": {
"default": {
"alignment": "center",
"children": [
{
"type": "text",
"text": "Page "
},
{
"type": "pageNumber",
"format": "decimal"
},
{
"type": "text",
"text": " of "
},
{
"type": "pageNumber",
"format": "totalPages"
}
]
}
}
}Supported header/footer elements:
text: Static text with styling options
pageNumber: Auto page numbering (decimal, upperRoman, lowerRoman, upperLetter, lowerLetter)
currentDate: Auto-updating date with custom format strings
documentTitle: References document meta.title
image: Images in headers/footers (base64, path, url)
New in v0.4.0 - Document Structure & Headers/Footers
✅ Headers & Footers System: Comprehensive page header and footer support
Default, first page, and even page headers/footers
Rich content: text, page numbers, dates, document title, images
Flexible alignment: left, center, right
Advanced styling: fonts, colors, sizes, bold/italic
✅ Dynamic Content Elements:
pageNumber: Automatic page numbering with multiple formats (decimal, roman, letters)currentDate: Auto-updating dates with custom formatsdocumentTitle: Reference document metadatatext: Static text with full styling optionsimage: Headers/footers images support
✅ Professional Layout Control:
Different headers/footers for first page vs. rest of document
Odd/even page variations for book-style layouts
Precise margin control for headers and footers
Integration with existing page settings system
New in v0.3.0 - Styles & Layout
✅ Page Settings: Page size (A4, Letter, etc.), orientation, margins control
✅ Enhanced Tables: Background colors, border styles, vertical alignment, table templates
✅ New Block Types: Horizontal rules, blockquotes, info boxes, text boxes
✅ Advanced Styling: More comprehensive table and cell formatting options
Previous Updates
v0.2.0 - Enhanced Document Operations
✅ Code Blocks: Syntax highlighting for 180+ programming languages
✅ Lists: Ordered and unordered lists with multiple styles and nesting
✅ Page Breaks: Control document pagination
✅ Enhanced Text: Superscript, subscript, font families, highlights
✅ Improved Schema: More comprehensive validation and type safety
Run locally
Install deps
npm installDev mode
npm run devBuild and start
npm run build
npm startTools
docx-getSchema { } // Get JSON schema - call this first!
docx-create { json }
docx-open { id?, path } // open .docx file from disk
docx-queryMeta { id }
docx-queryObjects { id }
docx-editMeta { id, patch }
docx-editContent { id, index, block }
docx-insertContent { id, index, block }
docx-removeContent { id, index }
docx-save { id, path }
docx-exportJson { id }
Example JSON
{
"meta": { "title": "Demo", "creator": "DOCX MCP v0.2.0" },
"content": [
{ "type": "heading", "level": 1, "children": [ { "type": "text", "text": "Title" } ] },
{ "type": "paragraph", "children": [
{ "type": "text", "text": "Hello ", "bold": true },
{ "type": "text", "text": "world", "color": "FF0000" }
]},
{
"type": "codeBlock",
"language": "javascript",
"showLineNumbers": true,
"code": "console.log('Hello, World!');"
},
{
"type": "list",
"ordered": false,
"items": [
{ "children": [{ "type": "text", "text": "First item" }] },
{ "children": [{ "type": "text", "text": "Second item" }] }
]
},
{ "type": "image", "url": "https://picsum.photos/300/200", "width": 300, "height": 200 },
{ "type": "pageBreak" },
{ "type": "table", "rows": [ { "cells": [
{ "children": [ { "type": "paragraph", "children": [ { "type": "text", "text": "A" } ] } ] },
{ "children": [ { "type": "paragraph", "children": [ { "type": "text", "text": "B" } ] } ] }
] } ] }
]
}Image Support
Images can be included in three ways:
URL:
{ "type": "image", "url": "https://example.com/image.png", "width": 300, "height": 200 }Local file path:
{ "type": "image", "path": "/path/to/image.png", "width": 300, "height": 200 }Base64 data:
{ "type": "image", "data": "base64string", "format": "png", "width": 150, "height": 100 }
URL Image Features:
Automatic download from HTTP/HTTPS URLs
Fallback to generated placeholder image if download fails
Placeholder shows original URL and dimensions
Support for common image formats (PNG, JPEG, JPG)
Note: Fontconfig warnings on Windows are harmless and can be ignored
Supported formats: PNG, JPEG, JPG
Notes
Hyperlinks are rendered visually as underlined blue text. Full hyperlink relationships can be added later.
Images support URL downloads, local file paths, and base64 data.
This server runs over stdio to be compatible with MCP hosts.
Available Tools
12 toolsdocx-createA
Create a new docx from JSON, returns an id. Use docx-getSchema first to understand the required JSON structure. Supports images via 'data' (base64), 'path' (local file), or 'url' (remote image with fallback).
Inputs: json (required).
docx-editContentB
Replace a block at index. Use docx-queryObjects first to see available blocks, and docx-getSchema to understand block structure.
Inputs: id (required), index (required), block (required).
docx-editMetaC
Patch metadata of a docx by id.
Inputs: id (required), patch (required).
docx-exportJsonC
Return the current JSON model for a given id.
Inputs: id (required).
docx-getSchemaA
Get the JSON schema for DOCX document structure. IMPORTANT: Always call this first to understand the document format before using other tools.
Inputs: no named parameters.
docx-insertContentA
Insert a block at index. Use docx-queryObjects first to see current structure, and docx-getSchema to understand block structure.
Inputs: id (required), index (required), block (required).
docx-openC
Open a .docx file from disk into memory and return id.
Inputs: path (required), id.
docx-openFileC
Open a .docx file from disk into memory and return id.
Inputs: path (required), id.
docx-queryMetaC
Get docx metadata by id.
Inputs: id (required).
docx-queryObjectsC
List top-level object info by id.
Inputs: id (required).
docx-removeContentC
Remove a block at index.
Inputs: id (required), index (required).
docx-saveC
Persist the docx to disk path by id.
Inputs: id (required), path (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Two tools (docx-open and docx-openFile) have identical descriptions, making them indistinguishable. This creates confusion for agents.
All tools follow a consistent docx-<verb><Noun> pattern with camelCase verbs. No naming convention violations.
12 tools cover the core DOCX operations reasonably well without being excessive or insufficient.
Basic CRUD is present but missing a delete/close operation for documents. Also lacks a way to create an empty document directly.
Maintenance
Related MCP Connectors
Convert, create and edit Word, PowerPoint, Excel and PDF documents from any AI agent.
Convert DOCX documents to and from PDF, TXT, HTML, ODT, JPG and RTF.
Create Word .docx files from sections or markdown, fill templates, and read text from a .docx.
Automate enterprise-grade documents from templates, merge and 100+ conversions: PDF, Office, HTML.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables comprehensive management of Microsoft Word documents with 30+ tools for reading, writing, formatting, template merging, image extraction, equation extraction, and style application.241MIT
- AlicenseBqualityDmaintenanceEnables AI assistants to create and manipulate Microsoft Word documents programmatically with support for rich text formatting, tables, lists, headings, and find-and-replace operations.1016 npmMIT
- AlicenseNot gradedqualityFmaintenanceEnables AI assistants to create, edit, and extract data from Microsoft Word documents programmatically, supporting document creation, content editing, table manipulation, parameter extraction, and template generation.1MIT
- FlicenseCqualityDmaintenanceEnables comprehensive DOCX/OOXML document manipulation via MCP, covering text, tables, images, content controls, comments, tracked changes, and metadata.34-