Python, NumPy, and Agentic AI for LibreOffice (Writer, Calc, and Draw)
Run Python and scientific compute directly in spreadsheet formulas, edit documents with private local-first AI, conduct autonomous web research, generate diagrams, and automate office workflows β without cloud lock-in.
The project is distributed as three standalone extension packages (install only one at a time):
| Package | What's Included | Best For |
|---|---|---|
π€ WriterAgent (WriterAgent.oxt) (Full stack) |
Everything in LibrePy and LibreHarper + AI sidebar, =PROMPT(), web research, Calc β Python converter, MCP server |
Users wanting the complete AI assistant, spreadsheet converter, and scientific compute suite |
π LibrePy (LibrePy.oxt) |
Python runtime, =PY(), NumPy, pandas, SymPy, Monaco code editor, domain helpers, OCR |
Users who want Python and Data Science in Calc/Writer without AI or API keys |
βοΈ LibreHarper (LibreHarper.oxt) |
Standalone offline Harper grammar engine for Writer | Users who only want fast, local grammar checking without AI or Python stacks |
Download .oxt Releases Β· Feature Index Β· NumPy in LibreOffice Guide Β· Discussions
- Native
=PY()Spreadsheet Formulas β Execute Python, NumPy, and pandas expressions directly inside Calc cells with automatic array spill, shared workbook kernels, and persistent scripts.=PY("np.mean(data)"; A1:A10)β Calculate array statistics directly on Calc ranges.=PY("data.to_pandas(date_cols=True)"; A1:C10)β Load sheet data into pandas with automatic type and date parsing.- NumPy in LibreOffice Guide Β· Data Shapes & Type Mapping
- Embedded Monaco Code Editor β Write, test, and debug multi-line Python scripts directly inside cells or through the Tools β Run Python Script environment with syntax highlighting, autocomplete, and diagnostics.
- Built-in Scientific & Analytics Domains β Ready-to-use helpers for EDA, outlier detection, OLS regression, KMeans clustering, Monte Carlo simulations, symbolic algebra (SymPy), plotting, and physical unit conversions (
convert_quantity(60, "mph", "m/s")β26.8224 m/s). Domain Reference Β· Analysis Helpers - Spreadsheet β Python Converter (WriterAgent) β Translate 235+ classic Calc/Excel formulas into clean Python expressions using the built-in
calc.*parity library while preserving constants, dates, and cell formats. Details - Local Vision & OCR β Extract text from embedded images or scanned documents directly into Writer and Calc via offline Docling OCR. Vision Guide
- Sidebar Chat with Multi-turn Tool Calling β Edit, restructure, or expand documents using natural language. 9 core tools plus dozens of specialized sub-agents for page layout, footnotes, bookmarks, revisions, and forms.
- Format-Preserving Edits β Surgical redlines and section rewrites maintain your existing formatting (bold, italics, highlights, font sizes, tables, and nested lists) without clobbering styles.
- Autonomous Web Research β Integrated private smolagents loop with DuckDuckGo. Synthesizes multiple web sources and updates open documents with real-time facts and citations. Agent Search
- Real-Time Grammar & Proofreading β Local, privacy-preserving grammar checking via Harper (fast, auto-installing), LanguageTool, or LLM endpoints with mixed-language sentence detection. Details
- Math & LaTeX Import β Converts LaTeX and MathML into native, editable LibreOffice Math objects. Math Guide
- Diagram & Presentation Generation β Generate, adjust, and style flowcharts, shapes, connectors, speaker notes, and slide transitions through chat commands or Python scripts. Details
- LO-DOM Semantic Tree β Structural understanding of headings, sections, tables, and relationships across entire documents. Semantic Tree
- Cross-Document Search & Memory β Query other documents in the same folder via local embeddings / hybrid search, with persistent cross-session agent memory. Embeddings Β· Memory
- Model Context Protocol (MCP) Server β Connect external IDEs and agents (Cursor, Claude Desktop, LM Studio) to read and edit open LibreOffice documents over
http://localhost:18765/mcp. MCP Protocol - Pluggable Agent Backends β Switch the chat engine to external agents such as Hermes, Claude Code, Mistral Vibe, Grok Build, or OpenCode via ACP. Cursor Plugin Β· LO Skill
Full catalog of capabilities: docs/features.md.
- Download your chosen
.oxtpackage from Latest Releases and double-click to install (or open LibreOffice and go to Tools β Extension Manager β Add). Remember to install only one extension package. - Restart LibreOffice.
- Quick Configuration:
- Python / LibrePy users: Open Calc, check Tools β LibrePy (or WriterAgent) β Settings β Python, and click Test to verify your environment and NumPy/pandas availability.
- AI / WriterAgent users: Open WriterAgent β Settings and enter your endpoint (e.g.
http://localhost:11434for local Ollama, or an OpenRouter / Together.AI API key). Open the sidebar via View β Sidebar β WriterAgent or press Ctrl+Q / Ctrl+E.
UI Modes: In classic toolbar mode, access tools through the top menubar. In tabbed/ribbon interfaces, use the WriterAgent chat sidebar and/or the Python sidebar (Writer + Calc): Settings
β, Pythonπ, LaTeX math or Edit cell, searchπ(WriterAgent chat only), and full menus viaβ°.
For detailed setup instructions, see the Install and Troubleshooting Guide.
Python in LibreOffice Writer
Spreadsheet Analytics & Dashboard
Hermes + Opus 4.6 (Autonomous Web Research)
Math Expressions & LaTeX
Arch Linux Resume
Diagrams in Draw
An in-LibreOffice LLM Evaluation Suite benchmarks models on real Writer, Calc, and Draw tasks and ranks them by Value (CΒ²/$) β average correctness squared Γ· average dollars per run, using live OpenRouter pricing.
| Rank | Model | Avg correctness | Avg score | Avg tokens | Avg cost ($) | Value (CΒ²/$) |
|---|---|---|---|---|---|---|
| 1 | openai/gpt-oss-120b | 0.980 | 0.942 | 3767.1 | 0.00025 | 3827.240 |
| 2 | google/gemini-3-flash-preview | 0.890 | 0.860 | 2957.2 | 0.00035 | 2234.257 |
| 3 | qwen/qwen3.5-9b | 0.730 | 0.691 | 4645.0 | 0.00050 | 1068.806 |
| 4 | nvidia/nemotron-3-nano-30b-a3b | 0.922 | 0.851 | 7195.5 | 0.00082 | 1037.536 |
| 5 | mistralai/devstral-2512 | 0.980 | 0.950 | 3000.8 | 0.00154 | 623.434 |
| 6 | inception/mercury-2 | 0.948 | 0.896 | 5150.9 | 0.00160 | 562.405 |
| 7 | minimax/minimax-m2.7 | 0.990 | 0.943 | 4671.9 | 0.00191 | 512.581 |
| 8 | deepseek/deepseek-v3.2 | 0.985 | 0.909 | 7575.4 | 0.00206 | 470.222 |
| 9 | qwen/qwen3.5-35b-a3b | 0.990 | 0.933 | 5671.1 | 0.00220 | 445.760 |
| 10 | x-ai/grok-4.1-fast | 0.950 | 0.886 | 6431.9 | 0.00204 | 442.733 |
| 11 | qwen/qwen3.5-27b | 0.993 | 0.942 | 5049.9 | 0.00259 | 380.538 |
| 12 | qwen/qwen3.5-122b-a10b | 0.990 | 0.950 | 3958.8 | 0.00308 | 318.312 |
| 13 | nvidia/nemotron-3-super-120b-a12b:free | 0.757 | 0.696 | 6388.4 | 0.00181 | 317.859 |
| 14 | allenai/olmo-3.1-32b-instruct | 0.323 | 0.306 | 1912.4 | 0.00046 | 226.704 |
| 15 | z-ai/glm-5.1 | 0.890 | 0.843 | 4677.8 | 0.00524 | 151.141 |
See docs/eval-benchmarks.md for scoring methodology and insights.
| Topic | Documentation Link |
|---|---|
| Feature Index | docs/features.md |
| NumPy & Python in Calc | docs/enabling_numpy_in_libreoffice.md Β· docs/calc-py-data-shapes.md |
| LibrePy Core Architecture | docs/scripting-librepy-split.md |
| Domain Helper Functions | docs/scripting-numpy-domains.md Β· docs/calc-analysis-tools.md |
| Full Architecture | docs/writeragent-architecture.md Β· docs/framework-formal-verification.md |
| Model Context Protocol (MCP) | docs/mcp-protocol.md |
| Embeddings & Search | docs/embeddings.md |
| Benchmarks | docs/eval-benchmarks.md |
| Localization (34 Locales) | docs/localization.md |
| Code Explorer | DeepWiki |
| Cursor / Agent Skills | cursor-libreoffice Β· libreoffice-skill |
Under the hood, all agentic interactions are governed by a formally verified finite state machine with strict type checking and static analysis.
A chronicle of building a Python runtime and AI suite inside LibreOffice:
- Week 1: Initial fork, sidebar chat, multi-turn tools, and async streaming
- Week 2 & 3: MCP, research sub-agent, voice support, and evaluation dashboard
- Week 4β6: State machines, formal verification, and specialized toolsets
- Week 6 & 7: Async grammar checking and TeX import support
- Week 8+: NumPy compute bridge,
=PY()Calc add-in, Monaco editor, and LibrePy core split
Prerequisites: Python 3.11β3.13 for development (pinned to 3.13 via .python-version), uv. Run make check-setup to verify. On macOS: install make, gettext.
git clone https://github.com/KeithCu/writeragent.git
cd writeragent
uv python install 3.13
uv sync
make deploy # Builds & installs WriterAgent.oxt (or: make deploy writer)
make test
make helpTo build and test the standalone extension variants:
# Standalone Python / NumPy compute suite (LibrePy)
make build-core # Produces build/LibrePy.oxt
make deploy-core # Installs LibrePy.oxt (removes WriterAgent)
# Standalone Harper grammar checker (LibreHarper)
make build-harper # Produces build/LibreHarper.oxt
make deploy-harper # Installs LibreHarper.oxtSee AGENTS.md (invariants), docs/repo-map.md (entry points), and docs/scripting-librepy-split.md for architecture details.
| Project | Contribution |
|---|---|
| localwriter | Original Writer LLM extension (John Balis) |
| LibreCalc AI Assistant | Calc AI foundation and inspiration |
| LibreOffice MCP Extension | MCP server patterns, Makefile, tool registry |
| Hermes Agent | Tool-call parsers, JSON repair, memory patterns |
| latex2mathml | LaTeX β MathML |
| mathml-to-latex | MathML β LaTeX (Writer formula export) |
| isodate | ISO 8601 duration parse/format (Calc wire) |
GNU GPL v3 (or later) β see LICENSE. Originally MPL 2.0; relicensed in 2026 for stronger reciprocity and library compatibility.
| Year | Contribution | Contributor |
|---|---|---|
| 2024 | Original release | John Balis |
| 2025β2026 | Config, registries, build system | quazardous |
| 2026 | Calc integration (originally MIT) | LibreCalc AI Assistant |
| 2026 | Modifications and relicensing | KeithCu |







