Skip to main content
Glama

Build-Office-Gateway

One MCP door for Word, Excel, PowerPoint — and a PDF parser switchboard.

office-gateway is a Python MCP server built on one idea: an AI agent should never open an Office file itself. It asks the door; the door picks the hand.

The hands behind the door

Job

Hand

Light reads and edits on Word / Excel / PPT

officecli (external binary)

Complex Excel edits

the zero-loss XML engine (engines/xlsx/): unzip the xlsx, patch the exact cell XML, zip it back — no library round-trip that would drop styles, charts or pivots

Excel risk pre-check

formula-impact analysis before any write; writes that would clobber complex structures are intercepted and the agent is told to run analyze_formula_impact first

Dynamic formula recalculation

LibreOffice headless (engines/xlsx/libreoffice_recalc.py), then formula_check.py for runtime errors (#DIV/0!, #N/A, …)

PPTX generation

an external html2pptx Node.js engine (engines/pptx/ — manifest included, engine file not; see that README)

DOCX generation / templating

a C# OpenXML engine (engines/docx/), driven via dotnet run

Markdown ↔ Word conversion

Pandoc

PDF parsing

three strategies: MinerU (academic deep: two-column papers, formulas → LaTeX), MarkItDown (OCR / visual pages), PyMuPDF (fast plain text)

Related MCP server: pharos-ai-doc-genie

Safety gates

  • Every path must resolve inside OFFICE_GATEWAY_WORKSPACE_ROOT; segments like .git, .venv, node_modules, Trash are refused outright.

  • Excel writes run a pre-check first; if the workbook cannot be safely analysed, the write is blocked — fail closed.

Install

pip install .
# then point your MCP client at:
python server.py

External tools used when the corresponding action is requested: officecli, pandoc, magic-pdf (MinerU), LibreOffice, the .NET SDK, Node.js.

Configuration (environment variables)

Variable

Default

Purpose

OFFICE_GATEWAY_WORKSPACE_ROOT

~

the only directory tree the gateway will touch

OFFICECLI_PATH

officecli

path to the officecli binary

LO_MCP_PROFILE

~/.lo_mcp_profile

shared LibreOffice profile (lets headless runs hand off to an always-on listener)

Notes

  • Every account, key and password in the published sources is a mock. Real credentials never leave the machine.

  • The engines are pluggable on purpose: the door and the safety rules are the contribution here, and each hand can be swapped without touching the router.

Licence

MIT

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    C
    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
    65 PyPI
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides a unified interface for AI agents and scripts to read, create, and edit office documents (.docx, .xlsx, .pdf) via MCP tools, using Markdown as the intermediary format. Supports in-place patching with stable IDs, Jinja2 templating, and formatting preservation.
    1
    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