LibreOffice MCP服务器
一个全面的模型上下文协议(MCP)服务器,提供与LibreOffice文档交互的工具和资源。该服务器使AI助手和其他MCP客户端能够以编程方式创建、读取、转换和操纵LibreOffice文档。
  
🚀 特性
LibreOffice扩展插件-推荐!
- 本机集成:直接在LibreOffice中嵌入MCP服务器
- 实时编辑:实时文档操作,提供即时视觉反馈
- 演出:比外部服务器快10倍(直接访问UNO API)
- 9综合工具:从32个单独的工具减少到更好的用户体验
- 跟踪更改支持:全面的修订跟踪意识
- 多文档:处理所有打开的LibreOffice文档
- HTTP API:通过本地主机访问外部AI助手:8765
文档操作
- 创建文档:新建Writer、Calc、Impress和Draw文档
- 阅读内容:提取带有visible_content的文本,以提高跟踪更改的意识
- 导航:段落级导航、光标定位、文档大纲
- 编辑:插入、格式化、选择和替换文本
- 搜索:查找/替换为跟踪更改意识(跳过跟踪删除)
- 评论:添加和检索文档注释
- 跟踪更改:启用、禁用、列出、接受/拒绝修订
🔧 9个综合MCP工具
MCP接口提供9个逻辑工具组(由32个单独的工具合并而成):
| 工具 | 操作 | 描述 |
|---|---|---|
document | 创建、信息、列表、内容、状态 | 文档管理 |
structure | 大纲、段落、范围、计数 | 文档导航 |
cursor | goto_deral、goto_position、position、context | 光标控制 |
selection | 段落、范围、删除、替换 | 文本选择 |
search | 查找、替换、替换_all | 搜索/替换(跟踪更改感知) |
track_changes | 状态、启用、禁用、列表、接受、拒绝、接受全部、拒绝全部 | 修订跟踪 |
comments | 列表,添加 | 评论管理 |
save | 保存、导出 | 保存/导出文档 |
text | 插入,格式化 | 文本插入和格式化 |
看 docs/TOOL_REFERENCE.md 以获取完整的文档。
📋 需求
- 办公套件:24.2+(必须通过命令行访问)
- python: 3.12+
- UV包装管理器:用于依赖关系管理
🛠 安装
LibreOffice扩展(推荐)
# Clone the repository
git clone https://github.com/jwingnut/mcp-libre.git
cd mcp-libre
# Build and install the LibreOffice extension
cd plugin/
./build.sh
unopkg add ../build/libreoffice-mcp-extension-1.0.0.oxt
# Restart LibreOffice安装后:
- 打开LibreOffice编写器
- 首选 工具>MCP服务器>启动MCP服务器
- HTTP API现已在
http://localhost:8765
FastMCP桥(用于克劳德代码)
# Install FastMCP
pip install fastmcp httpx
# Configure Claude Code
claude mcp add libreoffice -- fastmcp run /path/to/libreoffice_mcp_server.py🎯 快速开始
使用Claude代码
配置后,您可以使用自然语言命令:
"Get document info"
→ document(action="info")
"Find all occurrences of 'hello'"
→ search(action="find", query="hello")
"Enable track changes"
→ track_changes(action="enable")
"Go to paragraph 5 and get context"
→ cursor(action="goto_paragraph", n=5)
→ cursor(action="context")HTTP API示例
# Check server status
curl http://localhost:8765/health
# Get document info
curl -X POST http://localhost:8765/tools/get_document_info_live -d '{}'
# Find text
curl -X POST http://localhost:8765/tools/find_text_live \
-H "Content-Type: application/json" \
-d '{"query": "hello"}'
# Enable Track Changes
curl -X POST http://localhost:8765/tools/set_track_changes_live \
-H "Content-Type: application/json" \
-d '{"enabled": true}'📂 存储库结构
mcp-libre/
├── plugin/ # LibreOffice extension
│ ├── pythonpath/
│ │ ├── uno_bridge.py # UNO API wrapper
│ │ └── mcp_server.py # HTTP API server
│ ├── build.sh # Build script
│ └── README.md # Plugin documentation
├── libreoffice_mcp_server.py # FastMCP bridge (9 consolidated tools)
├── docs/
│ ├── TOOL_REFERENCE.md # Complete tool documentation
│ └── KNOWN_ISSUES_AND_ROADMAP.md
├── src/ # Legacy external server
├── tests/ # Test suite
└── README.md📚 文档
🆕 最近更新
v0.3.0-工具整合
- 将32个工具合并为9个逻辑组
- 减少权限提示,提高用户体验
- 每个工具使用
action路由参数
v0.2.0-跟踪变更意识
- 添加了7个跟踪变更管理工具
- 搜索/替换现在跳过跟踪的删除
get_paragraph回报visible_content领域find_text回报track_changes_active领域
v0.1.0-初始版本
- 25个单独的MCP工具
- 本地主机上的HTTP API:8765
- LibreOffice扩展与UNO API集成
🛡 安全
- 本地执行:所有操作都在本地运行
- 文件权限:仅限于用户的文件访问
- 没有网络:无外部网络依赖关系
- 电子邮件隐私:使用GitHub noreply电子邮件进行提交
🤝 贡献
- 分叉存储库
- 创建要素分支
- 进行更改
- 提交拉取请求
📄 许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
🔗 链接
- 仓库:https://github.com/jwingnut/mcp-libre
- MCP规范: https://spec.modelcontextprotocol.io/
- 办公套件: https://www.libreoffice.org/
- FastMCP: https://github.com/modelcontextprotocol/python-sdk
______________________________________________________________________
*LibreOffice MCP服务器v0.3.0-基于AI的文档编辑*
