Skip to main content
Glama

docx-comparison-mcp

A3 Landscape Old/New Comparison Table / A4 Portrait Specification Word Document Generation MCP Server

A local MCP server that can be called from any AI framework such as Dify, LangFlow, LangChain, or Claude Desktop.


Design Philosophy: GET schema → POST generate

It adopts the same "get schema first, then generate" pattern as excel-mcp.

However, there is a fundamental difference from excel-mcp:

excel-mcp

docx-mcp

Schema Origin

Reads Excel file header row at runtime (dynamic)

Fixed output format at compile time (static)

"Write Destination"

Fixed Excel file (always the same path)

New generation every time (new document per PDF upload)

Append Concept

Yes (appends to existing rows)

No (1 PDF = 1 new docx)

Positioning in Dify workflows:

[HTTP ノード] GET /schema/comparison
     ↓ prompt_context(列定義の代わりに出力フォーマット定義)
[LLM ノード] アップロードされた PDF を Gemini が読む + schema context を注入
     ↓ { doc_title, sections: [...] } の JSON
[HTTP ノード] POST /generate  { spec: { ... } }
     ↓ download_url
[End]

The prompt_context field is formatted to be pasted directly into the system prompt of a Dify LLM node.


Features

  • A3 landscape, Old/New/Remarks 3-column format (Old/New Comparison Table)

  • A4 portrait, Cover page/Revision history table/Body (Specification)

  • Red text (changes/additions)

  • Blue underlined Word comment anchors

  • Multi-section support (cover page, revision history, individual clauses)

  • stdio mode (for Claude Desktop / Claude Code)

  • HTTP mode (for Dify / LangFlow)


Setup

# 1. 依存パッケージのインストール
npm install

# 2. テスト実行
npm test
# → test-output.docx が生成されます

# 3a. MCP (stdio) モード起動 — Claude Desktop / Claude Code 向け
npm start

# 3b. HTTP モード起動 — Dify / LangFlow / REST 向け
npm run start:http
# → http://localhost:3456 で起動

Registration to Claude Desktop

Add to ~/.claude/claude_desktop_config.json:

{
  "mcpServers": {
    "docx-comparison": {
      "command": "node",
      "args": ["/absolute/path/to/docx-mcp/src/index.js"],
      "env": {
        "OUTPUT_DIR": "/Users/yourname/Desktop/docx-output"
      }
    }
  }
}

List of Endpoints

Method

Path

Description

GET

/health

Server health check

GET

/schema

API documentation (static)

GET

/schema/comparison

Schema for LLM injection for Old/New Comparison Table

GET

/schema/manual

Schema for LLM injection for Specification

POST

/generate

Generate Old/New Comparison Table (local save)

POST

/generate/download

Generate Old/New Comparison Table (direct file stream)

POST

/generate/manual

Generate Specification (local save)

POST

/generate/manual/download

Generate Specification (direct file stream)


GET /schema/comparison — Old/New Comparison Table Schema

Returns the format definition to be injected into the LLM. Please paste the prompt_context field into the system prompt of the Dify LLM node.

Response Overview:

{
  "doc_type": "comparison",
  "description": "新旧比較表(A3横、旧/新/備考 3カラム)Word文書の生成スキーマ",
  "prompt_context": "## 新旧比較表 生成形式\n\nPOST /generate に渡す spec を...",
  "required_fields": ["doc_title", "sections"],
  "sections_schema": { ... },
  "paragraph_schema": { ... },
  "example": { ... }
}

GET /schema/manual — Specification Schema

{
  "doc_type": "manual",
  "description": "仕様書(A4縦、表紙・経歴表・本文)Word文書の生成スキーマ",
  "prompt_context": "## 仕様書 生成形式\n\nPOST /generate/manual に渡す spec を...",
  "required_fields": ["doc_title", "sections"],
  "sections_schema": { ... },
  "history_schema": { ... },
  "example": { ... }
}

Dify Workflow Integration Pattern

Old/New Comparison Table (PDF Comparison)

[ファイルアップロード] ユーザーが PDF をアップロード
     ↓
[HTTP ノード] GET /schema/comparison
     ↓ body.prompt_context を変数に格納
[LLM ノード]
  システムプロンプト: {{schema_prompt_context}}
  ユーザーメッセージ: {{uploaded_pdf_content}}
     ↓ spec JSON(新旧比較表形式)
[HTTP ノード] POST /generate  { "spec": {{llm_output}} }
     ↓ { "download_url": "http://...", "filename": "...", "sections": N }
[End]

Gemini reads the uploaded PDF multimodally. PDF parsing on the server side is not required.

Specification Generation

[HTTP ノード] GET /schema/manual
     ↓ prompt_context
[LLM ノード] 仕様書内容の構造化
[HTTP ノード] POST /generate/manual  { "spec": {...} }

JSON Specification (Old/New Comparison Table)

Paragraph Specs (elements of old_paragraphs / new_paragraphs)

{
  "text": "テキスト(シンプルな場合)",
  "segments": [
    { "text": "通常テキスト" },
    { "text": "赤い変更箇所", "color": "red", "underline": true },
    { "text": "続き" }
  ],
  "bold": false,
  "color": "black",
  "underline": false,
  "align": "justify",
  "indent": 0,
  "sz": 19
}

Use either text or segments. segments is used when multiple formats are mixed within a single paragraph.

Comment Anchors

{
  "anchor": "作業手順確認書類",
  "text": "名称変更:作業手順確認書類→作業安全確認表",
  "column": "old"
}
  • anchor: Text to attach the comment to (exact match)

  • text: Content displayed in the Word comment balloon

  • column: "old" | "new" | "both"


Usage Example in LangFlow / Python

import requests

# 1. スキーマ取得(Dify HTTP ノードの代替)
schema = requests.get("http://localhost:3456/schema/comparison").json()
print(schema["prompt_context"])  # → LLM に注入するテキスト

# 2. 新旧比較表生成
spec = {
  "doc_title": "通信関係請負工事共通仕様書 比較表",
  "sections": [
    {
      "id": "section19",
      "title": "【19.施工方法】",
      "status": "changed",
      "old_paragraphs": [{"text": "19.施工方法および工事工程", "bold": True}],
      "new_paragraphs": [{"text": "20.施工方法および工事工程", "bold": True}],
      "notes": ["・名称変更に伴う見直し"],
      "comments": [{"anchor": "作業手順確認書類", "text": "名称変更", "column": "old"}],
    }
  ]
}

# ローカル保存 + パス返却
response = requests.post("http://localhost:3456/generate", json={
  "spec": spec,
  "output_filename": "比較表_第3回改正",
})
print(response.json())
# → {"success": true, "path": ".../比較表_第3回改正.docx", "download_url": "...", ...}

File Structure

docx-mcp/
├── src/
│   ├── index.js          # MCP stdio サーバー(Claude Desktop / Code)
│   ├── http-server.js    # HTTP REST サーバー(Dify / LangFlow)
│   ├── docx-generator.js # コア: JSON → 新旧比較表 .docx 変換エンジン
│   ├── manual-generator.js # コア: JSON → 仕様書 .docx 変換エンジン
│   ├── schema.js         # Zod バリデーション + LLM 注入用スキーマ定義
│   └── test.js           # テスト
├── docs/
│   └── dify-tool.yaml    # Dify Custom Tool / OpenAPI 定義
├── package.json
└── README.md

Environment Variables

Variable

Default

Description

OUTPUT_DIR

~/Desktop/docx-output

Save destination for generated files

PORT

3456

Port number for HTTP mode

Install Server
F
license - not found
A
quality
C
maintenance

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • Use your own Word templates to convert Markdown → DOCX/PDF/HTML from any MCP-compatible AI.

  • Real .docx and .xlsx files from structured data, with automatic Hebrew/Arabic RTL.

  • Generate PDFs from templates via AI chat. Works with Claude, ChatGPT, Cursor, and any MCP client.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bailangcheng818/docx-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server