Labsco
patrup logo

LibreOffice

β˜… 87

from patrup

Provides tools and resources for interacting with LibreOffice documents.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeAdvanced setup

LibreOffice MCP Server

A comprehensive Model Context Protocol (MCP) server that provides tools and resources for interacting with LibreOffice documents. This server enables AI assistants and other MCP clients to create, read, convert, and manipulate LibreOffice documents programmatically.

Python 3.12+ LibreOffice MCP Protocol

πŸ“‚ Repository Structure

This repository is organized into logical directories:

  • src/ - Core MCP server implementation
  • tests/ - Test suite and validation scripts
  • examples/ - Demo scripts and usage examples
  • config/ - Configuration templates for integrations
  • scripts/ - Utility scripts for setup and management
  • docs/ - Comprehensive documentation

For detailed information, see docs/REPOSITORY_STRUCTURE.md.

πŸš€ Features

LibreOffice Extension (Plugin) - NEW! πŸŽ‰

  • Native Integration: Embedded MCP server directly in LibreOffice
  • Real-time Editing: Live document manipulation with instant visual feedback
  • Performance: 10x faster than external server (direct UNO API access)
  • Multi-document: Work with all open LibreOffice documents
  • Auto-start: Automatically available when LibreOffice starts
  • HTTP API: External AI assistant access via localhost:8765

Document Operations

  • Create Documents: New Writer, Calc, Impress, and Draw documents
  • Read Content: Extract text from any LibreOffice document
  • Convert Formats: Convert between 50+ formats (PDF, DOCX, HTML, etc.)
  • Edit Documents: Insert, append, or replace text in Writer documents
  • Document Info: Get detailed metadata about documents

Spreadsheet Operations

  • Read Spreadsheets: Extract data from Calc spreadsheets and Excel files
  • Structured Data: Get data as 2D arrays with row/column information

Advanced Tools

  • Document Search: Find documents containing specific text
  • Batch Convert: Convert multiple documents simultaneously
  • Merge Documents: Combine multiple documents into one
  • Document Analysis: Get detailed statistics (word count, sentences, etc.)

Live Viewing & Real-time Editing

  • GUI Integration: Open documents in LibreOffice for live viewing
  • Real-time Updates: See changes as AI assistants modify documents
  • Change Monitoring: Watch documents for modifications in real-time
  • Interactive Sessions: Create live editing sessions with automatic refresh

MCP Resources

  • Document Discovery: List all LibreOffice documents (documents://)
  • Content Access: Access specific document content (document://{path})

πŸ”§ Available Tools

ToolDescription
create_documentCreate new LibreOffice documents
read_document_textExtract text from documents
convert_documentConvert between formats
get_document_infoGet document metadata
read_spreadsheet_dataRead spreadsheet data
insert_text_at_positionEdit document text
search_documentsSearch documents by content
batch_convert_documentsBatch format conversion
merge_text_documentsMerge multiple documents
get_document_statisticsDocument analysis
open_document_in_libreofficeOpen document in GUI for live viewing
create_live_editing_sessionStart live editing with real-time preview
watch_document_changesMonitor document changes in real-time
refresh_document_in_libreofficeForce document refresh in GUI

πŸ“š Documentation

πŸ”— Integration Options

1. LibreOffice Extension (NEW - Recommended!) πŸŽ‰

The most powerful and efficient way to use the MCP server:

# Build and install the LibreOffice extension
cd plugin/
./install.sh install

# Test the extension
./install.sh test

Benefits of the Extension:

  • 10x Performance: Direct UNO API access (no subprocess overhead)
  • Real-time Editing: Live document manipulation in open LibreOffice windows
  • Native Integration: Appears in LibreOffice Tools menu
  • Multi-document Support: Work with all open documents simultaneously
  • Auto-start: Automatically starts with LibreOffice
  • Advanced Features: Full access to LibreOffice formatting and capabilities

Usage:

  • The extension provides an HTTP API on http://localhost:8765
  • Configure your AI assistant to use this endpoint
  • Access controls via Tools > MCP Server in LibreOffice
  • Real-time document editing with instant visual feedback

For detailed plugin information, see plugin/README.md.

2. Claude Desktop

Generate configuration automatically:

./generate-config.sh claude
# Creates ~/.config/claude/claude_desktop_config.json

Then restart Claude Desktop and start using LibreOffice commands:

  • "Create a new Writer document and save it as project-report.odt"
  • "Convert my document to PDF format"

3. Super Assistant Chrome Extension

Generate configuration and start proxy:

./generate-config.sh mcp
npx @srbhptl39/mcp-superassistant-proxy@latest --config ~/Documents/mcp/mcp.config.json
# Server URL: http://localhost:3006

4. Direct MCP Client

from mcp.shared.memory import create_connected_server_and_client_session
from libremcp import mcp

async with client_session(mcp._mcp_server) as client:
    result = await client.call_tool("create_document", {
        "path": "/tmp/test.odt",
        "doc_type": "writer",
        "content": "Hello, World!"
    })

πŸ“ Supported File Formats

Input (Reading)

  • LibreOffice: .odt, .ods, .odp, .odg
  • Microsoft Office: .doc, .docx, .xls, .xlsx, .ppt, .pptx
  • Text: .txt, .rtf

Output (Conversion)

  • PDF: .pdf
  • Microsoft Office: .docx, .xlsx, .pptx
  • Web: .html, .htm
  • Text: .txt
  • LibreOffice: .odt, .ods, .odp, .odg
  • Many others: 50+ formats supported by LibreOffice

πŸ§ͺ Testing

LibreOffice Extension Testing

# Install and test the plugin
cd plugin/
./install.sh install    # Build and install extension
./install.sh test       # Test functionality
./install.sh status     # Check status
./install.sh interactive # Interactive testing mode

External Server Testing

# Show system requirements and installation guides
./mcp-helper.sh requirements

# Check dependencies and verify setup
./mcp-helper.sh check

# Run built-in functionality tests
./mcp-helper.sh test

# Interactive demo of all capabilities
./mcp-helper.sh demo

# Test specific functionality directly
uv run python libremcp.py --test

πŸ›‘ Security

  • Local Execution: All operations run locally
  • File Permissions: Limited to user's file access
  • No Network: No external network dependencies
  • Temporary Files: Automatically cleaned up

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

The MIT License is a permissive license that allows:

  • βœ… Commercial use
  • βœ… Modification
  • βœ… Distribution
  • βœ… Private use

For other license options, see LICENSE_OPTIONS.md.

πŸ”— Links

πŸ“ž Support

  • Issues: Use GitHub issues for bug reports
  • Documentation: See the docs/ folder for detailed guides
  • Examples: Check EXAMPLES.md for usage patterns

LibreOffice MCP Server v0.1.0 - Bridging AI and Document Processing