Token导航 LogoToken导航TokenDH.com
Docx Editor MCP logo
AI代理stdio官方级别未说明来源级核验

Docx Editor MCP

MCP Server

一个基于Model Context Protocol (MCP)的服务器,用于创建、编辑和提取Microsoft Word文档(.docx)数据,支持与AI助手无缝集成。

工具数

34

提示词数

0

GitHub Stars

1

资源数

0
PythonClaudeAI代理Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

merzano369

提供方

merzano369

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install -r requirements.txt

详细介绍

DOCX编辑器MCP服务器

![Python](https://www.python.org/) ![MCP](https://modelcontextprotocol.io/) ![License](LICENSE) ![python-docx](https://python-docx.readthedocs.io/)

一个强大的 模型上下文协议(MCP)服务器 用于从Microsoft Word文档中创建、编辑和提取数据(.docx).专为与Claude Desktop、Kilocode和其他MCP兼容客户端等AI助手无缝集成而设计。

📋 目录

✨ 特性

文档创建和管理

  • 创建新文档 具有预先配置的专业风格(Times New Roman,14pt,对齐,1.15行距)
  • 加载现有模板 用于修改
  • 保存文档 到任何指定路径

内容编辑

  • 添加标题 自动造型(居中,Times New Roman,16pt)
  • 添加段落 具有可定制的对齐方式(左、中、右、对齐)
  • 插入格式化文本 具有粗体、斜体、自定义字体大小和语言属性
  • 创建项目符号和编号列表 具有自动格式化功能

文档分析和提取

  • 提取所有文档参数 结构化JSON包括:

- 核心属性(作者、标题、主题、关键字、创建/修改日期) - 自定义属性(用户定义的元数据) - 文档变量(用于邮件合并和自动化) - 节属性(边距、页面大小、方向) - 样式定义(字体、颜色、间距、缩进) - 编号和列表定义 - 页眉和页脚内容 - 表结构

模板生成

  • 应用提取的参数 创建具有相同格式的新文档
  • 设置核心属性 编程(作者、标题、主题等)
  • 设置自定义属性 用于文档元数据

文档结构分析

  • 获取全面的文档结构摘要
  • 列出所有带有级别和文本的标题
  • 清点段落和表格
  • 预览文档内容

📦 安装

先决条件

  • Python 3.10或更高版本
  • pip包管理器

快速开始

  1. 克隆存储库:
   git clone https://github.com/yourusername/docx-editor-mcp.git
   cd docx-editor-mcp
  1. 安装依赖项:
   pip install -r requirements.txt
  1. 验证安装:
   python -c "from docx import Document; from mcp.server.fastmcp import FastMCP; print('Installation successful!')"

⚙️ 配置

了解MCP服务器

重要提示: MCP服务器使用JSON-RPC协议通过stdio进行通信。它们不打算直接从命令行运行以供交互使用。相反,它们必须由MCP客户端启动。

Claude桌面配置

将以下内容添加到您的Claude Desktop配置文件中:

窗户: %APPDATA%\Claude\claude_desktop_config.json\ macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "docx-editor": {
      "command": "python",
      "args": ["C:\\path\\to\\docx-editor-mcp\\server.py"]
    }
  }
}

千码/VS码配置

添加到您的VS代码设置或Kilocode配置中:

{
  "mcp.servers": {
    "docx-editor": {
      "command": "python",
      "args": ["/path/to/docx-editor-mcp/server.py"]
    }
  }
}

🔧 可用工具

文档创建和管理

工具说明
create_document(filename)使用默认专业样式创建新文档
save_document(filename)将当前文档保存到指定路径
load_template(filename)加载现有文档进行修改

内容添加

工具说明
add_heading(text, level)添加具有默认样式的标题(级别1-6)
add_heading_custom(text, level, font_size)添加具有自定义字体大小的标题
add_paragraph(text, alignment, indent_first_line)添加带有对齐选项的段落
add_formatted_text(paragraph_index, text, bold, italic, font_size, lang)将样式文本附加到段落中
add_list_item(text, style)添加项目符号或编号列表项
insert_header_near_text(target_text, header_title, position)插入相对于现有文本的标题
insert_line_or_paragraph_near_text(target_text, line_text, position)插入相对于现有文本的段落
insert_numbered_list_near_text(target_text, list_items, position, bullet_type)插入相对于现有文本的列表
format_text(paragraph_index, start_pos, end_pos, bold, italic...)设置段落中特定字符范围的格式
search_and_replace(find_text, replace_text)在整个文档中全局替换文本
delete_paragraph(paragraph_index)按索引删除段落
create_custom_style(style_name, bold, italic, color, font_size...)创建自定义段落样式

表格操作

参数提取

工具说明
extract_document_parameters(filename, compact, all_styles)将所有文档参数提取为JSON
extract_core_properties(filename)提取元数据(作者、标题、日期等)
extract_custom_properties(filename)提取用户定义的自定义特性
extract_document_variables(filename)提取文档变量以实现自动化
extract_section_properties(filename)提取页边距、页面大小、方向
extract_styles_info(filename, all_styles, compact)提取样式定义
get_document_structure(filename)获取标题、段落、表格摘要

模板生成

📖 使用示例

创建新文档

问你的AI助手:

Create a new Word document called "report.docx" with:
- A heading "Annual Report 2024"
- A paragraph about company performance
- A bullet list with key achievements

服务器将执行:

create_document("report.docx")
add_heading("Annual Report 2024", level=1)
add_paragraph("The company has shown remarkable growth this year...")
add_list_item("Revenue increased by 25%", style="List Bullet")
add_list_item("Expanded to 3 new markets", style="List Bullet")
save_document()

提取文档参数

Extract all parameters from "template.docx" and show me the styles used.

返回结构化JSON:

{
  "core_properties": {
    "author": "John Doe",
    "title": "Company Template",
    "created": "2024-01-15T10:30:00"
  },
  "sections": [{
    "margins": {
      "top_mm": 15,
      "bottom_mm": 15,
      "left_mm": 20,
      "right_mm": 20
    },
    "orientation": "portrait"
  }],
  "styles": {
    "paragraph_styles": {
      "Normal": {
        "font": {"name": "Times New Roman", "size_pt": 14},
        "paragraph_format": {"alignment": "JUSTIFY", "line_spacing": 1.15}
      }
    }
  }
}

克隆文档模板

Extract parameters from "template.docx" and create a new document "new_report.docx" with the same formatting.
params = extract_document_parameters("template.docx")
apply_template_parameters(params, "new_report.docx")
# Now add your content...
add_heading("New Report", level=1)
add_paragraph("Your content here...")
save_document()

分析文档结构

Load "document.docx" and show me its structure.

退货:

{
  "headings": [
    {"index": 0, "level": "Heading 1", "text": "Introduction"},
    {"index": 5, "level": "Heading 2", "text": "Methodology"}
  ],
  "paragraphs": [
    {"index": 1, "style": "Normal", "text_preview": "This document describes..."},
    {"index": 2, "style": "Normal", "text_preview": "The following sections..."}
  ],
  "tables_count": 2
}

🛠 技术栈

组件技术
语言Python 3.10+
协议模型上下文协议(MCP)
MCP框架FastMCP
文档引擎python docx
沟通基于stdio的JSON-RPC

依赖项

mcp>=1.0.0
python-docx>=0.8.11

默认文档样式

新文档是使用专业默认样式创建的:

元素样式
普通文本Times New Roman,14pt,对齐,行距1.15
标题1Times New Roman,16pt,居中,无粗体
标题2Times New Roman,16pt,居中,无粗体
边距顶部/底部:15mm,左侧/右侧:20mm
第一行缩进12.7毫米(1.27厘米)

🤝 贡献

欢迎投稿!以下是您可以提供帮助的方式:

入门指南

  1. 分叉存储库
  2. 克隆你的叉子:
   git clone https://github.com/yourusername/docx-editor-mcp.git
  1. 创建要素分支:
   git checkout -b feature/amazing-feature
  1. 进行更改并提交:
   git commit -m "Add amazing feature"
  1. 推到您的分支:
   git push origin feature/amazing-feature
  1. 打开拉取请求

贡献指南

  • 遵循PEP 8风格指南
  • 将文档字符串添加到所有新函数中
  • 更新任何新功能的文档
  • 在提交之前彻底测试您的更改

功能请求和Bug报告

  • 打开问题以获取错误报告或功能请求
  • 提供错误的详细描述和复制步骤
  • 包括功能请求示例

📄 许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。

______________________________________________________________________

Made with ❤️ for the MCP community

目录标签

目录标签

PythonClaudeAI代理文档编辑本地部署Word处理MCP协议文档解析模板生成

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

34

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP