mcpField
D
docx-forge

docx-forge

本地服务
github.com/mdfifty50-boop生产力027 周前更新

关于 docx-forge

docx-forge 是用于创建、读取和编辑 Word 文档的 MCP 服务,支持结构化内容和 Markdown。它提供模板替换、文档合并及可选的 PDF 导出,无需安装 Microsoft Word。

主要功能

  1. 01从 Markdown 创建 DOCX
  2. 02读取文本、标题和元数据
  3. 03追加章节并替换文本
  4. 04添加格式化表格并合并文件
  5. 05将 DOCX 导出为 PDF
  6. 06查看文档统计信息

适用场景

  1. 01根据模板生成合同和提案
  2. 02通过 Agent 工作流制作结构化报告
  3. 03提取现有 Word 文件的内容
  4. 04将多个章节文件合并为一份文档

MCP 相关

向 MCP 客户端提供文档创建、读取、编辑、合并、统计和 PDF 导出工具,并提供使用指南资源。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"mdfifty50-boop-docx-forge": {
"command": "npx",
"args": [
"-y",
"docx-forge-mcp"
]
}
}
}
启动命令npx -y docx-forge-mcp

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npmdocx-forge-mcp0.1.1

工具

9

收录的工具列表 · 更新于 3 周前

此工具无需参数。

详细介绍

docx-forge-mcp

用于创建和操作 Word 文档(.docx)的 MCP 服务——面向 AI Agent 的生产级文档自动化工具。

直接通过 Agent 工作流生成合同、报告、提案和合规文档。无需安装 Word。

npm License: MIT MCP Compatible


为什么选择 docx-forge-mcp?

Word 文档是合同、合规报告、法律协议和商业提案的默认格式,尤其是在企业和政府工作流中。此 MCP 服务让 AI Agent 能以编程方式创建和操作 .docx 文件,无需安装 Office、使用 UI 自动化,也无需猜测文件格式。

截至 2026 年,只有 1 个竞品能通过 MCP 操作 Word 文档。此服务以生产级、经过全面测试的实现填补了这一空缺。


工具

工具描述
create_document根据标题和 Markdown 内容创建新的 .docx
read_document从 .docx 中提取文本、标题、段落和元数据
add_section在现有 .docx 中追加新章节(标题 + 正文)
replace_text查找并替换文本,非常适合替换模板变量
add_table在 .docx 中插入带粗体表头的格式化表格
merge_documents将多个 .docx 文件合并为一个
export_to_pdf通过 LibreOffice 或 pandoc 将 .docx 转换为 PDF
get_document_stats获取字数、页数估算、章节数和表格数

安装

Claude Desktop

添加到你的 claude_desktop_config.json:

{
  "mcpServers": {
    "docx-forge": {
      "command": "npx",
      "args": ["docx-forge-mcp"]
    }
  }
}
Cursor

添加到你的 .cursor/mcp.json:

{
  "mcpServers": {
    "docx-forge": {
      "command": "npx",
      "args": ["docx-forge-mcp"]
    }
  }
}
手动安装(Node.js)
npm install -g docx-forge-mcp
docx-forge-mcp

使用示例

根据模板创建合同
create_document(
  title="Service Agreement",
  content="# Parties\n\n**Client:** {{CLIENT_NAME}}\n**Provider:** Acme Corp\n\n## Scope of Work\n\n{{SCOPE}}\n\n## Payment\n\n{{PAYMENT_TERMS}}",
  outputPath="/tmp/contract.docx"
)

replace_text(filePath="/tmp/contract.docx", find="{{CLIENT_NAME}}", replace="TechCorp Ltd")
replace_text(filePath="/tmp/contract.docx", find="{{SCOPE}}", replace="Software development and consulting services.")
replace_text(filePath="/tmp/contract.docx", find="{{PAYMENT_TERMS}}", replace="Net 30 days. $15,000/month.")

export_to_pdf(filePath="/tmp/contract.docx", outputPath="/tmp/contract.pdf")
编写结构化报告
create_document(
  title="Q1 2026 Performance Report",
  content="## Executive Summary\n\nRevenue grew 34% YoY.",
  outputPath="/tmp/report.docx"
)

add_section(
  filePath="/tmp/report.docx",
  heading="Revenue Breakdown",
  content="Product A: $450K\nProduct B: $320K\nServices: $180K",
  headingLevel=2
)

add_table(
  filePath="/tmp/report.docx",
  headers=["Product", "Q1 Revenue", "Growth"],
  rows=[["Product A", "$450K", "+41%"], ["Product B", "$320K", "+28%"], ["Services", "$180K", "+19%"]]
)

get_document_stats(filePath="/tmp/report.docx")
读取并检查现有文档
read_document(filePath="/path/to/existing.docx")
# Returns: { text, paragraphs[], headings[], metadata: { wordCount, fileSizeBytes, ... } }
将章节文件合并成一本书
merge_documents(
  filePaths=["/docs/ch1.docx", "/docs/ch2.docx", "/docs/ch3.docx"],
  outputPath="/docs/complete-manual.docx"
)

Markdown 支持

create_document 和 add_section 都接受 Markdown 内容:

Markdown结果
# Heading 1H1 标题
## Heading 2H2 标题
**bold text**粗体文本
*italic text*斜体文本
- item项目符号列表项
1. item编号列表项
---水平分隔线
空行段落分隔

导出 PDF

export_to_pdf 需要系统级转换器。它会按以下顺序尝试:

  1. LibreOffice(保真度最高)— sudo apt-get install libreoffice
  2. pandoc — sudo apt-get install pandoc

如果两者都不可用,该工具会返回 success: false,并提供安装说明。源 .docx 文件始终会保留。


资源

URI描述
docx-forge://usage-guide包含工作流示例的分步指南

依赖项


要求

  • Node.js >= 18.0.0
  • 无需安装 Microsoft Word 或 Office
  • 导出 PDF 需要 LibreOffice 或 pandoc(可选)

开发

git clone https://github.com/mdfifty50-boop/docx-forge-mcp
cd docx-forge-mcp
npm install
npm test        # Run test suite
npm start       # Start MCP server (stdio)

许可证

MIT — 参见 LICENSE


相关 MCP 服务

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。