Skip to main content
Glama

LibreOffice MCP Tools

npm version

[!WARNING] このプロジェクトは GitHub Copilot によって作成 されており、人間による完全なレビューは行われていません。 コードにはバグ、セキュリティ上の問題、または予期しない動作が含まれている可能性があります。自己責任で使用してください。 十分なレビューなしに本番環境で使用しないでください。

Model Context Protocol (MCP) サーバーであり、AIエージェント(Claude、Copilot、Gemini、Cursorなど)がLibreOfficeを介して Officeドキュメントを読み取り、書き込み、編集 する機能を提供します。LLMのコンテキスト使用量を最小限に抑える、トークン効率に優れた設計になっています。

chrome-devtools-mcp のアーキテクチャに触発されています。

✨ 特徴

  • 22種類のMCPツール: 読み取り、書き込み、スプレッドシート、プレゼンテーションをカバー

  • トークン効率に優れた設計: アウトライン優先のナビゲーション、範囲ベースのアクセス、ページネーション

  • 幅広いフォーマットサポート: DOCX, DOC, XLSX, XLS, PPTX, PPT, ODT, ODS, ODP, RTF, CSV, TXT, PDF

  • レガシーフォーマットブリッジ: .doc, .xls, .ppt はLibreOfficeを介して解析前に自動変換

  • 基本的な読み取りにはLibreOffice不要: ネイティブパーサーがDOCX, XLSX, PPTXを直接処理

  • LibreOfficeが必要なケース: レガシーフォーマット、PDFエクスポート、フォーマット変換

Related MCP server: docx-mcp-server

📋 サポートされているフォーマット

フォーマット

拡張子

読み取り

書き込み

メソッド

Word 2007+

.docx, .dotx

✅

✅

ネイティブ (mammoth read / JSZip OOXML write)

Word 97-2003

.doc, .dot

✅

✅

LibreOfficeブリッジ

Excel 2007+

.xlsx, .xlsm

✅

✅

ネイティブ (ExcelJS)

Excel 97-2003

.xls

✅

✅

LibreOfficeブリッジ

PowerPoint 2007+

.pptx

✅

✅

ネイティブ (JSZip OOXML)

PowerPoint 97-2003

.ppt

✅

✅

LibreOfficeブリッジ

OpenDocument Text

.odt

✅

✅

LibreOfficeブリッジ

OpenDocument Spreadsheet

.ods

✅

✅

LibreOfficeブリッジ

OpenDocument Presentation

.odp

✅

✅

LibreOfficeブリッジ

Rich Text Format

.rtf

✅

✅

LibreOfficeブリッジ

CSV

.csv

✅

✅

ネイティブ

PDF

.pdf

✅ (テキスト)

❌

LibreOffice CLI

プレーンテキスト

.txt

✅

✅

ネイティブ

🚀 クイックスタート

前提条件

  • Node.js 20+

  • LibreOffice (基本的なDOCX/XLSX/PPTXの読み取りにはオプション; .doc/.xls/.pptおよびフォーマット変換には必須)

インストール

npxを使用する場合(推奨 — インストール不要):

{
  "mcpServers": {
    "libreoffice": {
      "command": "npx",
      "args": ["-y", "@passerbyflutter/libreoffice-mcp-tools"]
    }
  }
}

グローバルインストール:

npm install -g @passerbyflutter/libreoffice-mcp-tools

ソースからインストール:

git clone https://github.com/passerbyflutter/libreoffice-mcp-tools
cd libreoffice-mcp-tools
npm install
npm run build

MCPクライアントの設定

MCPクライアントの設定(例: Claude Desktopの claude_desktop_config.json)に追加します:

{
  "mcpServers": {
    "libreoffice": {
      "command": "npx",
      "args": ["-y", "@passerbyflutter/libreoffice-mcp-tools"],
      "env": {
        "SOFFICE_PATH": "/path/to/soffice"
      }
    }
  }
}

または、プロジェクトルートの .mcp.json を使用します:

{
  "mcpServers": {
    "libreoffice": {
      "command": "npx",
      "args": ["-y", "@passerbyflutter/libreoffice-mcp-tools"]
    }
  }
}

CLIオプション

node build/bin/libreoffice-mcp.js [options]

  --libreoffice-path <path>   Path to soffice executable
                              (default: auto-detected or SOFFICE_PATH env)

🛠 ツールリファレンス

ドキュメント管理

ツール

説明

document_open

ファイルを開く → docId ハンドルを返す。レガシーフォーマットを自動ブリッジ

document_close

ドキュメントハンドルと一時ファイルを解放

document_list

開いているすべてのドキュメントを一覧表示

document_create

新しい空のドキュメントを作成 (Writer/Calc/Impress)

document_save

現在または新しいパスに保存

document_export

LibreOfficeを介してエクスポート (PDF, HTML, CSVなど)

document_convert

ファイルフォーマットを変換 (DOC→DOCX, XLSX→CSVなど)

読み取り (トークン効率重視)

ツール

説明

document_get_metadata

タイトル、作成者、単語数/ページ数、日付

document_get_outline

見出し (Writer) / シート名 (Calc) / スライドタイトル (Impress)

document_read_text

Markdown形式でページ分割されたドキュメントテキスト

document_read_range

特定の段落またはスライド範囲

document_search

周辺コンテキストを含むテキスト検索

書き込み (Writer)

ツール

説明

document_insert_text

先頭/末尾/見出しの後ろに挿入

document_replace_text

検索と置換 (最初またはすべての出現箇所)

document_insert_paragraph

特定のインデックスに段落を挿入

document_apply_style

見出し/段落スタイルを適用

スプレッドシート (Calc)

ツール

説明

spreadsheet_list_sheets

行数/列数を含むシート名

spreadsheet_get_range

JSON + Markdownテーブルとしてのセル範囲

spreadsheet_set_cell

セル値または数式を設定

spreadsheet_set_range

2次元の値範囲を設定

spreadsheet_add_sheet

新しいシートを追加

spreadsheet_get_formulas

範囲内の数式を取得

プレゼンテーション (Impress)

ツール

説明

presentation_list_slides

インデックス付きのスライドタイトル

presentation_get_slide

スライドの全コンテンツ (タイトル、本文、ノート)

presentation_get_notes

発表者ノート

presentation_add_slide

新しいスライドを追加 (LibreOfficeが必要)

presentation_update_slide

スライドのコンテンツを更新

💡 トークン節約ワークフロー

最大限のトークン効率を得るには、このパターンに従ってください:

1. document_open(filePath) → get docId
2. document_get_metadata(docId) → understand size/type
3. document_get_outline(docId) → see structure
4. document_read_range(docId, startIndex=N, endIndex=M) → read specific section

ドキュメント全体をダンプする代わりに、必要な場所に正確に移動します。

スプレッドシートのワークフロー:

1. document_open(path) → docId
2. spreadsheet_list_sheets(docId) → see all sheets
3. spreadsheet_get_range(docId, sheetName="Sales", range="A1:D20") → targeted data

🏗 アーキテクチャ

src/
├── index.ts                # createMcpServer() — MCP server factory
├── LibreOfficeAdapter.ts   # soffice subprocess manager
├── DocumentContext.ts      # Open document registry
├── DocumentSession.ts      # Per-document state + format bridge
├── McpResponse.ts          # Response builder (text/JSON/markdown)
├── Mutex.ts                # Serializes LibreOffice subprocess calls
├── parsers/
│   ├── DocxParser.ts           # DOCX read → {paragraphs, outline, metadata} (mammoth)
│   ├── DocxOoxmlEditor.ts      # DOCX write → direct JSZip OOXML manipulation (format-preserving)
│   ├── XlsxParser.ts           # XLSX read/write via ExcelJS
│   ├── PptxParser.ts           # PPTX read → {slides[]} (JSZip XML)
│   └── PptxOoxmlEditor.ts      # PPTX write → add/update slides, create PPTX (JSZip OOXML)
├── formatters/
│   ├── MarkdownFormatter.ts
│   ├── JsonFormatter.ts
│   └── TableFormatter.ts   # Spreadsheet → Markdown table
└── tools/
    ├── documents.ts         # open/close/list/create
    ├── reader.ts            # metadata/outline/read/search
    ├── writer.ts            # insert/replace/style
    ├── spreadsheet.ts       # get/set cells/ranges/sheets
    ├── presentation.ts      # slides/notes
    └── converter.ts         # save/export/convert

🧪 テスト

# Create sample fixtures
node tests/create-fixtures.mjs

# Run smoke tests
npm test

📝 環境変数

変数

説明

SOFFICE_PATH

LibreOffice soffice 実行ファイルへのパス

DEBUG

詳細なログを出力するには lo-mcp:* に設定

📄 ライセンス

MIT

Available Tools

27 tools
document_apply_styleC

Apply a heading or paragraph style to a specific paragraph by index.

Inputs: docId (required), paragraphIndex (required), style (required).

document_closeA

Close an open document and release its resources (including any temp files from format bridging).

Inputs: docId (required).

document_convertA

Convert a document file to a different format using LibreOffice CLI. Creates a new file; original is not modified. Useful for: DOC→DOCX, DOCX→PDF, XLSX→CSV, etc. LibreOffice must be installed.

Inputs: filePath (required), format (required), outputPath.

document_createB

Create a new empty document and open it. Returns a docId. Supports creating: writer (text document → .docx), calc (spreadsheet → .xlsx), impress (presentation → .pptx).

Inputs: documentType (required), filePath (required).

document_exportA

Export a document to a different format using LibreOffice. Supports exporting to: PDF, HTML, TXT, DOCX, XLSX, PPTX, ODT, ODS, ODP, CSV. LibreOffice must be installed.

Inputs: docId (required), format (required), outputPath.

document_get_metadataA

Get metadata for an open document: title, author, page count, word count, format, file size, dates. Token-efficient: use this before reading document content to understand its size and structure.

Inputs: docId (required).

document_get_outlineA

Get the structural outline of a document:

  • Writer documents: headings hierarchy (H1, H2, H3...)

  • Calc spreadsheets: list of sheet names with row/column counts

  • Impress presentations: slide titles with index numbers Token-efficient: always call this before document_read_text to understand structure.

Inputs: docId (required).

document_insert_paragraphC

Insert a new paragraph at a specific index in a Writer document.

Inputs: docId (required), text (required), index (required), style.

document_insert_textB

Insert text into a Writer document at a specified position. Position options: 'start' (beginning), 'end' (end of document), or after a specific heading text.

Inputs: docId (required), text (required), position, headingText, +1 more.

document_listB

List all currently open documents with their docId, file path, format, and size.

Inputs: no named parameters.

document_openA

Open a document file and return a docId handle for use with other tools. Supports: .docx, .doc, .xlsx, .xls, .pptx, .ppt, .odt, .ods, .odp, .rtf, .csv, .txt, .pdf Legacy binary formats (.doc, .xls, .ppt, .odt, .ods, .odp, .rtf) are automatically converted via LibreOffice before parsing. Returns docId to use with all other document tools.

Inputs: filePath (required).

document_read_rangeA

Read a specific range of a document by paragraph index (for Writer) or slide index (for Impress). More token-efficient than document_read_text when you only need a specific section.

Inputs: docId (required), startIndex (required), endIndex.

document_read_textA

Read document content as Markdown text. For large documents, use limit/offset for pagination. Default returns up to 4000 characters. Use document_get_outline first to understand structure.

Inputs: docId (required), limit, offset, maxChars.

document_replace_textC

Find and replace text in a Writer document. Optionally replace all occurrences.

Inputs: docId (required), find (required), replace (required), replaceAll, +1 more.

document_saveB

Save the current state of a document to its file path (or a new path).

Inputs: docId (required), filePath.

presentation_add_slideC

Add a new slide to a presentation.

Inputs: docId (required), title (required), body, notes.

presentation_get_notesB

Get speaker notes for all slides or a specific slide.

Inputs: docId (required), slideIndex.

presentation_get_slideB

Get the full content of a specific slide: title, body text, and speaker notes.

Inputs: docId (required), slideIndex (required).

presentation_list_slidesA

List all slides in a presentation with their index and title. Token-efficient overview before reading content.

Inputs: docId (required).

presentation_update_slideC

Update the title or body text of an existing slide.

Inputs: docId (required), slideIndex (required), title, body.

spreadsheet_add_sheetC

Add a new sheet to a spreadsheet workbook.

Inputs: docId (required), sheetName (required), headers.

spreadsheet_get_formulasA

Get all formulas in a spreadsheet range (returns formula expressions, not computed values).

Inputs: docId (required), sheetName, range.

spreadsheet_get_rangeA

Read a range of cells from a spreadsheet sheet. Returns data as structured JSON and a markdown table. Use range like "A1:D10" for specific cells, or omit for paginated full sheet. Token-efficient: specify a range rather than reading the whole sheet.

Inputs: docId (required), sheetName, range, limit, +2 more.

spreadsheet_list_sheetsB

List all sheets in a spreadsheet with their names, row counts, and column counts.

Inputs: docId (required).

spreadsheet_set_cellA

Set the value or formula of a single cell in a spreadsheet. Changes are saved immediately.

Inputs: docId (required), cell (required), value (required), sheetName, +1 more.

spreadsheet_set_rangeC

Set multiple cell values in a spreadsheet. Provide a 2D array of values matching the range.

Inputs: docId (required), startCell (required), values (required), sheetName.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 27 tools

    Disambiguation4/5

    Most tools have distinct purposes with clear boundaries, such as document operations versus presentation or spreadsheet tools. However, some overlap exists: document_read_text and document_read_range both handle reading content, and document_convert and document_export both involve format conversion, which could cause minor confusion in selection.

    Naming Consistency5/5

    Tool names follow a highly consistent verb_noun pattern with clear prefixes (document_, presentation_, spreadsheet_) that group related operations. All names use snake_case uniformly, making them predictable and easy to parse for agents.

    Tool Count3/5

    With 27 tools, the count is borderline high for a single server, potentially overwhelming for agents. While the tools cover a broad range of LibreOffice operations, the number feels heavy and could be streamlined by consolidating overlapping functions like reading or conversion tools.

    Completeness5/5

    The tool set provides comprehensive coverage for document, presentation, and spreadsheet workflows, including creation, reading, updating, conversion, and metadata operations. There are no obvious gaps; agents can perform full CRUD/lifecycle tasks across all supported file types without dead ends.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Enables complete Office document lifecycle management for AI agents, including creation, editing, conversion, and templating of DOCX, XLSX, PPTX, PDF, and EML files.
      40
      57 PyPI
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to create and process office documents locally, including generating branded PDF, Word, Excel, and editable PowerPoint files from templates and themes, plus reading, OCR, form-filling, manipulation, and conversion of PDFs.
      1
      MIT