这是一个基于模型上下文协议(MCP)的服务器,它允许Claude Desktop在Microsoft Word、Excel和PDF文件上执行各类文档操作,极大地拓展了Claude Desktop的文档处理能力。
该MCP服务器要求使用Python 3.10或更高版本。下面为你提供详细的安装步骤。
运行设置脚本来自动安装依赖项并配置Claude Desktop:
git clone https://github.com/alejandroBallesterosC/document-edit-mcp
cd document-edit-mcp
./setup.sh
此操作将完成以下步骤:
如果你更喜欢手动安装,可按以下步骤操作:
cd claude-document-mcp
python -m venv .venv
source .venv/bin/activate # 在Windows上:.venv\Scripts\activate
pip install -e .
claude_desktop_config.json文件到:~/Library/Application Support/Claude/%APPDATA%\Claude\该服务器遵循模型上下文协议规范,以向Claude Desktop提供文档处理功能:
以下是使用该服务器API的一些基础示例:
# 创建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文件
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文件
create_pdf_file(filepath: str, content: str) -> Dict
# 将Word转换为PDF
convert_word_to_pdf(source_path: str, target_path: str) -> Dict
create_word_document(filepath: str, content: str) -> Dict
edit_word_document(filepath: str, operations: List[Dict]) -> Dict
convert_txt_to_word(source_path: str, target_path: str) -> Dict
create_excel_file(filepath: str, content: str) -> Dict
edit_excel_file(filepath: str, operations: List[Dict]) -> Dict
convert_csv_to_excel(source_path: str, target_path: str) -> Dict
create_pdf_file(filepath: str, content: str) -> Dict
convert_word_to_pdf(source_path: str, target_path: str) -> Dict
服务器将所有操作同时记录到控制台和logs/document_mcp.log文件中,以便于故障排除。
本项目采用MIT许可证。
欢迎任何贡献!请随时提交Pull Request。