libre-office-mcp
jacobNar/libre-office-mcp
An MCP server with tools to create documents with Libre Office. Currently supports Libre Office Draw
Instalação
npx convez-ai jacobNar/libre-office-mcp1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.
Métricas
README
A tradução para o português deste README ainda está na fila.
LibreOffice Draw MCP Server
A Model Context Protocol (MCP) server that connects to a local headless LibreOffice Draw instance via the UNO API, exposing tools to programmatically draw Database/ER Diagrams (entities and sticky connectors).
Section 1: System Environment & Virtual Environment Setup
Choose the installation track matching your operating system:
On Linux (Ubuntu/Debian)
- Install system-level python-uno bindings:
sudo apt update sudo apt install python3-uno - Create your virtual environment with global system packages enabled so it can load the
unomodule:python3 -m venv --system-site-packages .venv - Activate the environment:
source .venv/bin/activate - Install python dependencies:
pip install fastmcp
On Windows
- Create a standard virtual environment:
python -m venv .venv - Activate it:
.venv\Scripts\activate - Install python dependencies:
pip install fastmcp
Section 2: python-uno Environment Configuration (Windows Only)
Windows does not distribute a system-level python-uno package. To run the server inside your Windows environment:
Option A: Use the LibreOffice Bundled Python (Recommended / Easiest)
LibreOffice comes with its own Python executable that pre-configures all UNO path bindings. You can execute the server directly using:
& "C:\Program Files\LibreOffice\program\python.exe" server.py
Option B: Link System Python to LibreOffice UNO
- Set the following environment variables on your PC:
PATH: AddC:\Program Files\LibreOffice\programto your PATH.URE_BOOTSTRAP: Set tovnd.sun.star.pathname:C:\Program Files\LibreOffice\program\fundamentalrc(or the equivalent path in your installation).
- Copy
uno.pyandunohelper.pyfromC:\Program Files\LibreOffice\programinto your.venv\Lib\site-packagesfolder.
Section 3: Codebase Architecture
The codebase is organized into modular classes adhering to DRY, Separation of Concerns, and comment-free style guidelines:
- config.py: Configuration class for connection parameters and models.
- libreoffice_client.py: Class encapsulating UNO client operations (connecting, drawing shapes, linking shapes, and saving).
- server.py: FastMCP server exposing tools using the default
stdiotransport.
Section 4: Testing & Execution Playbook
1. Launch LibreOffice in Headless Listening Mode
Launch LibreOffice locally with a socket listener on port 2002:
# On Linux/macOS
sudo soffice "--accept=socket,host=127.0.0.1,port=2002;urp;" --headless --norestore --nologo --nodefault
# On Windows
& "C:\Program Files\LibreOffice\program\soffice.exe" "--accept=socket,host=127.0.0.1,port=2002;urp;" --headless --norestore --nologo --nodefault
(Make sure the host IP in config.py matches the listener host).
2. Run the MCP Server
To run the server over a network port using the Server-Sent Events (SSE) transport:
python server.py
This starts the server process listening on port 8000. The server endpoint will be available at http://<host-ip>:8000/sse.
3. Connect to the MCP Server Remotely
From your other computer on the Tailscale network, you can connect to the running MCP server by pointing your client application to the SSE URL:
http://<Tailscale-IP>:8000/sse
For example, you can configure the remote server in your client's configuration file (such as claude_desktop_config.json):
{
"mcpServers": {
"libreoffice-draw": {
"url": "http://<Tailscale-IP>:8000/sse"
}
}
}