loading…
Search for a command to run...
loading…
Enables interaction with LibreOffice documents (Writer, Calc, Impress, Draw) via MCP, supporting document management, data analysis, and database operations usi
Enables interaction with LibreOffice documents (Writer, Calc, Impress, Draw) via MCP, supporting document management, data analysis, and database operations using the OooDev library.
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.
OooDev Integration:
XSpreadsheetDocument, XTextDocument) with OooDev classes (CalcDoc, WriteDoc).Lo class to manage LibreOffice connections, replacing manual UnoUrlResolver setup.Calc, Write, and Chart2 for document operations.Preserved Features:
open_document, close_document, get_sheet_names, get_cell_value, set_cell_value, create_new_sheet, insert_text, create_chart, and apply_style.CalcDoc.get_sheet_names() instead of XSpreadsheetDocument.getSheets()).parse_cell_address helper, though OooDev’s CalcDoc.rng() method reduces its necessity in some cases.New Base Tools:
run_query, list_tables, create_table, and insert_data to support LibreOffice Base operations, using OooDev’s database access methods.com::sun::star::sdb namespace from api.md but use OooDev’s simplified interfaces.New Data Analysis Tools:
create_pivot_table, sort_range, and calculate_statistics to enhance Calc’s data analysis capabilities.Chart2 module for pivot table creation and Calc module for sorting and statistics.Additional Tools:
new_document to create new documents of various types, leveraging OooDev’s create_doc methods.save_document to save documents using OooDev’s save_doc.run_macro to execute Python macros, using OooDev’s MacroLoader context manager.insert_form_control to insert form controls in Calc sheets, using OooDev’s Forms module.WriteDoc, CalcDoc, DrawDoc for Writer, Calc, Draw, and Impress documents, covering com::sun::star::text, sheet, draw, and presentation namespaces.com::sun::star::sdb and sdbc functionalities.Chart2 and Calc modules for pivot tables, sorting, and statistics, aligning with com::sun::star::chart2 and sheet.Forms and MacroLoader for com::sun::star::form and script namespaces.Write.style) for com::sun::star::style.ooodev.units for unit conversions, ooodev.form for advanced forms, ooodev.draw for shapes) could be added as tools.Lo.cache) could be implemented for frequent operations.pip install ooo-dev-tools) and LibreOffice is running with a socket connection (port 2083).open_document, run_query, or create_pivot_table.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;"
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.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)").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.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.insert_slide: Inserts a new slide at a specified position in a presentation.add_shape: Adds a shape (e.g., rectangle, circle) to a Draw page with position and size.run_macro: Runs a Basic macro stored in the document.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("doc_id") to get all table names in a database.delete_table("doc_id", "table_name") to remove a table.insert_data("doc_id", "table_name", {"ID": 1, "Name": "Test"}) to add a row.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("doc_id", "Sheet1", "A1:B10", "bar", "C12") to create a bar chart.apply_conditional_formatting("doc_id", "Sheet1", "A1:A10", "A1>10", "Good"), assuming "Good" is a defined cell style.Выполни в терминале:
claude mcp add libreoffice-mcp -- npx Безопасность
Низкий рискАвтоматическая эвристика по публичным данным — не гарантия безопасности.