Claude 文档 MCP 服务器是一个基于 Model Context Protocol (MCP) 的服务器,它允许 Claude Desktop 对 Microsoft Word、Excel 和 PDF 文件执行各种文档操作,极大地提升了文档处理的效率和便捷性。
此 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\此服务器遵循 Model Context Protocol 规范,以提供文档操作功能供 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。