Document Operations (Word, Excel, PDF)

Document Operations (Word, Excel, PDF)

🚀 用于Claude Desktop的文档编辑MCP服务器

这是一个基于模型上下文协议(MCP)的服务器,它允许Claude Desktop在Microsoft Word、Excel和PDF文件上执行各类文档操作,极大地拓展了Claude Desktop的文档处理能力。

🚀 快速开始

该MCP服务器要求使用Python 3.10或更高版本。下面为你提供详细的安装步骤。

✨ 主要特性

Microsoft Word 操作

  • 可使用文本创建新的Word文档。
  • 支持编辑现有Word文档,包括添加、修改或删除段落和标题。
  • 能够将文本文件(.txt)转换为Word文档。

Excel 操作

  • 可从JSON或CSV格式的文本创建新的Excel电子表格。
  • 支持编辑现有的Excel文件,如更新单元格、范围,添加或删除行、列、工作表。
  • 能够将CSV文件转换为Excel。

PDF 操作

  • 可使用文本创建新的PDF文件。
  • 能够将Word文档转换为PDF文件。

📦 安装指南

自动安装(推荐)

运行设置脚本来自动安装依赖项并配置Claude Desktop:

git clone https://github.com/alejandroBallesterosC/document-edit-mcp
cd document-edit-mcp
./setup.sh

此操作将完成以下步骤:

  1. 创建虚拟环境。
  2. 安装所需的依赖项。
  3. 配置服务器以供Claude Desktop使用。
  4. 创建必要的目录。

手动安装(如果需要)

如果你更喜欢手动安装,可按以下步骤操作:

  1. 安装依赖项:
cd claude-document-mcp
python -m venv .venv
source .venv/bin/activate  # 在Windows上:.venv\Scripts\activate
pip install -e .
  1. 配置Claude Desktop: 复制claude_desktop_config.json文件到:
  • Mac~/Library/Application Support/Claude/
  • Windows%APPDATA%\Claude\
  1. 重启Claude Desktop。

📚 详细文档

模型上下文协议集成

该服务器遵循模型上下文协议规范,以向Claude Desktop提供文档处理功能:

  • 工具:提供了对Word、Excel和PDF操作的操纵函数。
  • 资源:提供了有关功能的信息。
  • 提示:(目前尚未实现)

💻 使用示例

基础用法

以下是使用该服务器API的一些基础示例:

Microsoft Word

# 创建Word文档
create_word_document(filepath: str, content: str) -> Dict

# 编辑Word文档
edit_word_document(filepath: str, operations: List[Dict]) -> Dict

# 将TXT转换为Word
convert_txt_to_word(source_path: str, target_path: str) -> Dict

Excel

# 创建Excel文件
create_excel_file(filepath: str, content: str) -> Dict

# 编辑Excel文件
edit_excel_file(filepath: str, operations: List[Dict]) -> Dict

# 将CSV转换为Excel
convert_csv_to_excel(source_path: str, target_path: str) -> Dict

PDF

# 创建PDF文件
create_pdf_file(filepath: str, content: str) -> Dict

# 将Word转换为PDF
convert_word_to_pdf(source_path: str, target_path: str) -> Dict

📄 API文档

Microsoft Word

创建Word文档

create_word_document(filepath: str, content: str) -> Dict

编辑Word文档

edit_word_document(filepath: str, operations: List[Dict]) -> Dict

将TXT转换为Word

convert_txt_to_word(source_path: str, target_path: str) -> Dict

Excel

创建Excel文件

create_excel_file(filepath: str, content: str) -> Dict

编辑Excel文件

edit_excel_file(filepath: str, operations: List[Dict]) -> Dict

将CSV转换为Excel

convert_csv_to_excel(source_path: str, target_path: str) -> Dict

PDF

创建PDF文件

create_pdf_file(filepath: str, content: str) -> Dict

将Word转换为PDF

convert_word_to_pdf(source_path: str, target_path: str) -> Dict

🔧 技术细节

服务器将所有操作同时记录到控制台和logs/document_mcp.log文件中,以便于故障排除。

📄 许可证

本项目采用MIT许可证。

🤝 贡献

欢迎任何贡献!请随时提交Pull Request。

  • 0 关注
  • 0 收藏,8 浏览
  • system 提出于 2025-09-29 11:57

相似服务问题

相关AI产品