Libreoffice
FreeNot checkedA WIP LibreOffice MCP adapter. Now supports Writer, Calc, Impress, and Draw, with potential for more Base and Math tools to be added.
About
A WIP LibreOffice MCP adapter. Now supports Writer, Calc, Impress, and Draw, with potential for more Base and Math tools to be added.
README
Explanation of the Refactor
Why OooDev?
The OooDev library, as detailed in api_documentation.md, provides a Pythonic abstraction over the LibreOffice UNO API, with classes like CalcDoc, WriteDoc, and utilities for charts, forms, and macros. It simplifies tasks like document creation, cell manipulation, and styling, reducing the need for low-level UNO interface queries (e.g., UnoRuntime.queryInterface). OooDev also supports modern Python features (e.g., type hints, context managers) and integrates with extensions like APSO and OooDev.oxt, making it ideal for a 1:1 MCP mapping.
Key Changes from Your Original Implementation
OooDev Integration:
- Replaced direct UNO API calls (e.g.,
XSpreadsheetDocument,XTextDocument) with OooDev classes (CalcDoc,WriteDoc). - Used OooDev’s
Loclass to manage LibreOffice connections, replacing manualUnoUrlResolversetup. - Leveraged OooDev utilities like
Calc,Write, andChart2for document operations.
- Replaced direct UNO API calls (e.g.,
Preserved Features:
- Kept all your original tools:
open_document,close_document,get_sheet_names,get_cell_value,set_cell_value,create_new_sheet,insert_text,create_chart, andapply_style. - Enhanced these tools to use OooDev methods (e.g.,
CalcDoc.get_sheet_names()instead ofXSpreadsheetDocument.getSheets()). - Maintained the
parse_cell_addresshelper, though OooDev’sCalcDoc.rng()method reduces its necessity in some cases.
- Kept all your original tools:
New Base Tools:
- Added
run_query,list_tables,create_table, andinsert_datato support LibreOffice Base operations, using OooDev’s database access methods. - These tools align with the
com::sun::star::sdbnamespace fromapi.mdbut use OooDev’s simplified interfaces.
- Added
New Data Analysis Tools:
- Added
create_pivot_table,sort_range, andcalculate_statisticsto enhance Calc’s data analysis capabilities. - Used OooDev’s
Chart2module for pivot table creation andCalcmodule for sorting and statistics.
- Added
Additional Tools:
- Added
new_documentto create new documents of various types, leveraging OooDev’screate_docmethods. - Added
save_documentto save documents using OooDev’ssave_doc. - Added
run_macroto execute Python macros, using OooDev’sMacroLoadercontext manager. - Added
insert_form_controlto insert form controls in Calc sheets, using OooDev’sFormsmodule.
- Added
Alignment with OooDev Features
- Document Management: Uses
WriteDoc,CalcDoc,DrawDocfor Writer, Calc, Draw, and Impress documents, coveringcom::sun::star::text,sheet,draw, andpresentationnamespaces. - Base Operations: Leverages OooDev’s database access for
com::sun::star::sdbandsdbcfunctionalities. - Data Analysis: Utilizes OooDev’s
Chart2andCalcmodules for pivot tables, sorting, and statistics, aligning withcom::sun::star::chart2andsheet. - Forms and Macros: Incorporates OooDev’s
FormsandMacroLoaderforcom::sun::star::formandscriptnamespaces. - Styling: Uses OooDev’s style methods (e.g.,
Write.style) forcom::sun::star::style.
Benefits of the Refactor
- Pythonic Interface: OooDev’s classes and methods are more intuitive and reduce boilerplate compared to UNO’s interface queries.
- Comprehensive Coverage: The adapter covers a broad range of OooDev functionalities, from basic document operations to advanced database and analysis tasks.
- Maintainability: OooDev’s abstractions simplify maintenance and future expansions (e.g., adding Math or more form controls).
- Error Handling: Robust error checking ensures reliability for LLM interactions via MCP.
Limitations and Future Enhancements
- Base Document Handling: The current Base tools use raw UNO interfaces for database operations, as OooDev’s Base support is less developed. Future versions could integrate OooDev’s Base-specific classes if added.
- Additional Tools: More OooDev features (e.g.,
ooodev.unitsfor unit conversions,ooodev.formfor advanced forms,ooodev.drawfor shapes) could be added as tools. - Performance: OooDev’s abstractions may introduce slight overhead; caching (e.g.,
Lo.cache) could be implemented for frequent operations.
How to Use
- Setup: Ensure OooDev is installed (
pip install ooo-dev-tools) and LibreOffice is running with a socket connection (port 2083). - Run the Server: Start the FastAPI server with this adapter.
- Interact via MCP: Use the MCP client to call tools like
open_document,run_query, orcreate_pivot_table.
- Coverage Across Applications: The adapter now supports Writer, Calc, Impress, and Draw, with potential for more Base and Math tools to be added.
- Rich Feature Set: It includes not just basic operations (e.g., opening documents, setting cell values) but also advanced features like styling, table insertion, image handling, charting, slide management, and shape drawing.
- Cross-Cutting Functionality: Tools like saving, exporting to PDF, and managing document properties apply to all LibreOffice document types, enhancing versatility.
- Error Handling: Each tool includes robust checks (e.g., document existence, type validation) to ensure reliability.
Old Documetnation
sudo useradd -m -s /bin/bash mcp-libreoffice
sudo mkdir -p /home/mcp-libreoffice/output
sudo chown -R mcp-libreoffice:mcp-libreoffice /home/mcp-libreoffice
sudo -u mcp-libreoffice soffice --headless --accept="socket,host=localhost,port=${LIBREOFFICE_PORT:-2083};urp;"
Original Features:
open_document: Opens a document from a URL and assigns it an ID.close_document: Closes a document by its ID.get_sheet_names: Retrieves all sheet names from a Calc spreadsheet.get_cell_value: Gets the value (numeric, text, or formula) of a specified cell in a Calc sheet.set_cell_value: Sets a cell’s value in a Calc sheet, handling both numbers and text.get_text_content: Retrieves the full text content of a Writer document.insert_text: Inserts text at a specific position in a Writer document.create_chart: Creates a chart in a Calc sheet based on a data range and chart type.parse_cell_address: Helper function to convert cell addresses (e.g., "A1") to column and row indices.- Spreadsheet Enhancements (Calc):
create_new_sheet: Adds a new sheet to a spreadsheet.set_cell_formula: Sets a formula in a spreadsheet cell (e.g., "=SUM(A1:A10)").
- Text Document Enhancements (Writer):
insert_table: Inserts a table with specified rows and columns at a position.apply_style: Applies a paragraph style to a text range.insert_image: Inserts an image from a URL at a specified position.
- Additional Document Management:
save_document: Saves a document to a URL with a specified filter (e.g., "writer8" for ODT).export_to_pdf: Exports a document to PDF format.get_document_properties: Retrieves metadata like title, author, subject, and keywords.set_document_properties: Updates document metadata.
- Presentation Tools (Impress):
insert_slide: Inserts a new slide at a specified position in a presentation.
- Drawing Tools (Draw):
add_shape: Adds a shape (e.g., rectangle, circle) to a Draw page with position and size.
- Macro Execution:
run_macro: Runs a Basic macro stored in the document.
Base Tools
The following tools further enhance database management capabilities:
list_tables(doc_id: str) -> list[str]: Retrieves a list of all table names in the database.delete_table(doc_id: str, table_name: str) -> str: Deletes a specified table from the database.insert_data(doc_id: str, table_name: str, data: dict) -> str: Inserts a single row of data into a table, with column names and values provided as a dictionary.- List Tables: Use
list_tables("doc_id")to get all table names in a database. - Delete Table: Call
delete_table("doc_id", "table_name")to remove a table. - Insert Data: Use
insert_data("doc_id", "table_name", {"ID": 1, "Name": "Test"})to add a row.
Data Analysis Tools
These tools extend Calc’s data analysis capabilities:
create_chart(doc_id: str, sheet_name: str, data_range: str, chart_type: str, target_cell: str) -> str: Creates a chart (e.g., bar, line) from a data range and places it at the target cell.apply_conditional_formatting(doc_id: str, sheet_name: str, range_address: str, condition: str, style: str) -> str: Applies conditional formatting to a range based on a condition (e.g., "value > 10") and a style.group_range(doc_id: str, sheet_name: str, range_address: str, by_rows: bool) -> str: Groups rows or columns in a range for outlining purposes.- Create Chart: Use
create_chart("doc_id", "Sheet1", "A1:B10", "bar", "C12")to create a bar chart. - Conditional Formatting: Apply with
apply_conditional_formatting("doc_id", "Sheet1", "A1:A10", "A1>10", "Good"), assuming "Good" is a defined cell style.
Potential Additions
- Base Tools: Create databases, manage forms, or run queries.
- Math Tools: Insert and edit mathematical formulas.
- Formatting Tools: Adjust font size, color, or alignment in Writer or Impress.
- Animation/Transition Tools: Add animations to Impress slides.
- Data Analysis Tools: Implement pivot tables or sorting in Calc.
Installing Libreoffice
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/WaterPistolAI/libreoffice-mcpFAQ
Is Libreoffice MCP free?
Yes, Libreoffice MCP is free — one-click install via Unyly at no cost.
Does Libreoffice need an API key?
No, Libreoffice runs without API keys or environment variables.
Is Libreoffice hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install Libreoffice in Claude Desktop, Claude Code or Cursor?
Open Libreoffice on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
GitHub
PRs, issues, code search, CI status
by GitHubFilesystem
Secure file operations with configurable access controls.
Memory
Knowledge graph-based persistent memory system.
Template MCP Server
A CLI tool to create a new Model Context Protocol server project with TypeScript support, dual transport options, and an extensible structure
by mcpdotdirectAmap Maps Mcp Server
MCP server for using the AMap Maps API
by duxiaohuiSupabase
Database, auth and storage
by SupabaseEverything
Reference / test server with prompts, resources, and tools.
Git
Tools to read, search, and manipulate Git repositories.
Sequential Thinking
Dynamic and reflective problem-solving through thought sequences.
Time
Time and timezone conversion capabilities.
Compare Libreoffice with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All development MCPs
