Document Operator MCP

Document Operator MCP

Enables AI assistants to read, modify, and create Word (.docx) and Excel (.xlsx) files through natural language commands, including batch queries and temporary table management.

Category
Visit Server

README

Document Operator MCP

License: MIT Python MCP

一个 MCP (Model Context Protocol) Server,让 AI 助手(Claude Desktop、Trae、Cursor 等)能够通过自然语言操作 Word(.docx) 和 Excel(.xlsx) 文档。


功能

类别 操作 说明
Word 📖 读取全文 / 指定段落 支持查看文档结构(标题、段落、表格)
📊 提取表格 提取所有表格数据
✏️ 修改段落 修改、追加、插入段落
🔍 搜索替换 全文搜索并替换文本
Excel 📖 读取数据 读取 Sheet、单元格、区域
✏️ 写入单元格 按地址或行列号写入
🗂️ 管理 Sheet 添加、删除、列出 Sheet
📝 创建文件 创建新的 xlsx 文件
临时表 📊 批量查询 按指定Sheet/行/列批量提取数据
💾 内存暂存 将查询结果存入命名临时表
📤 导出保存 将临时表保存为 .xlsx 文件

快速开始

1. 安装

# 方式一:pip 安装
pip install git+https://github.com/dai-zw/document-operator-mcp.git

# 方式二:uvx(推荐)
uvx --from git+https://github.com/dai-zw/document-operator-mcp.git document-operator-mcp

2. 配置到 AI 客户端

Claude Desktop

{
  "mcpServers": {
    "document-operator": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/dai-zw/document-operator-mcp.git", "document-operator-mcp"]
    }
  }
}

Trae IDE / Cursor

在项目的 .trae/mcp.json.cursor/mcp.json 中添加:

{
  "mcpServers": {
    "document-operator": {
      "command": "python",
      "args": ["-m", "document_operator_mcp.server"]
    }
  }
}

或直接指定路径:

{
  "mcpServers": {
    "document-operator": {
      "command": "python",
      "args": [".trae/skills/document-operator/mcp_server/server.py"]
    }
  }
}

3. 开始对话

配置完成后,在 AI 对话中可以直接说:

  • "读取这份 word 文档 d:/report.docx"
  • "把第3段改成:项目已完成"
  • "在 excel 的 B2 填入 500"
  • "列出这个表格有哪些 sheet"
  • "把文档里所有的'旧系统'替换成'新平台'"
  • "从 data.xlsx 的 Sheet1 读取第2-50行的 A、C、F 列,存为临时表 tb1,然后保存到 extract.xlsx"

AI 会自动调用对应的 MCP Tool 完成操作。


本地开发

# 克隆项目
git clone https://github.com/dai-zw/document-operator-mcp.git
cd document-operator-mcp

# 安装依赖
pip install -e .

# 启动 MCP Server(stdio 模式)
python -m document_operator_mcp.server

# 用 MCP Inspector 调试
mcp dev document_operator_mcp/server.py

提供的 Tool 列表(14 个)

Word 工具

Tool 用途
read_docx 读取全文或指定段落
read_docx_tables 提取所有表格
write_docx 修改 / 追加 / 插入段落
replace_docx_text 全文搜索替换
get_docx_info 查看文档结构

Excel 工具

Tool 用途
read_xlsx 读取 Sheet / 单元格 / 区域
write_xlsx 写入单元格
list_xlsx_sheets 列出所有 Sheet
create_xlsx 创建新工作簿
manage_xlsx_sheet 添加或删除 Sheet

临时表 / 批量查询工具

Tool 用途
query_xlsx 从 Excel 批量读取指定Sheet/行/列,可选存入内存临时表
get_temp_table 查看内存临时表数据
save_temp_table 将临时表保存为 .xlsx 文件
list_temp_tables 列出当前会话所有临时表

批量查询典型工作流:

query_xlsx("data.xlsx", sheet_name="Sheet1", start_row=2, end_row=100, columns="A,C,F", output_table_name="mydata")
get_temp_table("mydata")                                    # 查看数据
save_temp_table("mydata", "output.xlsx")                    # 保存为新文件

技术栈

限制

  • Word 仅支持 .docx 格式,不支持旧版 .doc
  • Excel 仅支持 .xlsx 格式
  • Word "分页" 操作为段落级近似(python-docx 不支持原生页码)
  • 修改操作会直接保存到原文件,请注意备份

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured