Skip to content

About

An MCP server and command line that let AI agents open, read, edit, render and compare Word, Excel and PowerPoint files with the ComOffice .NET SDK. MIT. Questions: support@comofficekit.com

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ComOffice for AI agents

comofficekit-mcp lets an AI agent open, read, edit, check and save Word, Excel and PowerPoint files. It is a Model Context Protocol server, and the same tools as a command line, built on the ComOffice .NET SDK.

The engine runs inside this process: no Office, no LibreOffice, no browser, and no network. An agent gets the document's real structure (paragraphs, tables, tracked changes and comments; cells with their formulas; slides by shape) and edits the original file. Each page can be drawn as an image, so the agent can look at what it changed before it saves. Parts of the file that no edit touched are saved as they were.

It runs on Windows x64 and Linux x64, and in a Linux container.

The tools

Tool What it does
open_document Opens a .docx, .xlsx, .xlsm, .csv, .tsv or .pptx file. Returns an id and a summary: pages, sheets or slides, and the fonts drawn in place of missing ones
create_document Creates an empty .docx, .xlsx or .pptx file and opens it
read_document Reads a part at a time. Word: paragraphs and tables, each paragraph's text with the tracked changes beside it, and the comments. Excel: cells with their input and the text they show. PowerPoint: each slide's text by shape, tables and notes
render_page Draws a page as a PNG image for the agent to look at
replace_text Replaces text in Word (in one edit, keeping formatting) or in a deck
set_cells Types into cells as Excel does, then reads back the recalculated values
resolve_revisions Accepts or rejects every tracked change in a Word document
compare_documents Compares two Word files and writes the differences as tracked changes. The revised file can also be plain text
save_document Saves in the document's own format
export_pdf Writes a PDF
close_document Closes a document

A typical loop: open_document → read_document → an edit → render_page to check it → save_document.

What you need

  • .NET 8 or later, on Windows x64 or Linux x64 (glibc). Linux also needs libxml2, as ComOffice on Linux describes.
  • A ComOffice licence key. The evaluation key in the ComOffice for Windows README works without signing up, until the date given there. To buy a licence, write to sales@comofficekit.com.

The server reads the key from COMOFFICEKIT_LICENSE_KEY, or a licence file from COMOFFICEKIT_LICENSE_FILE. A licence bound to one application must name the application comofficekit-mcp.

Build it

Each release of ComOffice for Windows and Linux attaches its .NET package. scripts/fetch-package.sh (or scripts/fetch-package.ps1 on Windows) puts the latest one in packages/, which nuget.config uses:

scripts/fetch-package.sh
dotnet publish -c Release -r linux-x64 --self-contained false -o publish     # or -r win-x64

The program is publish/comofficekit-mcp (comofficekit-mcp.exe on Windows).

Connect an agent

The server's tools work only on files in one folder: the one --root names, or the current folder. They do not follow links. Most agents take a configuration like this one:

{
  "mcpServers": {
    "comoffice": {
      "command": "/path/to/publish/comofficekit-mcp",
      "args": ["--root", "/path/to/your/documents"],
      "env": { "COMOFFICEKIT_LICENSE_KEY": "<your licence key>" }
    }
  }
}

With Claude Code:

claude mcp add comoffice --env COMOFFICEKIT_LICENSE_KEY="$COMOFFICEKIT_LICENSE_KEY" -- /path/to/publish/comofficekit-mcp --root "$PWD"

In a Linux container

The Dockerfile takes the published program:

scripts/fetch-package.sh
dotnet publish -c Release -r linux-x64 --self-contained false -o publish
docker build -t comofficekit-mcp .

An agent then starts it with the folder mounted at /work, and the key passed from its own environment:

{
  "mcpServers": {
    "comoffice": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "--network", "none", "-v", "/path/to/your/documents:/work",
               "-e", "COMOFFICEKIT_LICENSE_KEY", "comofficekit-mcp"],
      "env": { "COMOFFICEKIT_LICENSE_KEY": "<your licence key>" }
    }
  }
}

The image has no fonts of its own. Documents are drawn in the two the package carries until their own fonts are installed; the Dockerfile shows how.

From a shell

For agents that run commands instead of using MCP, and for scripts. Each command prints JSON:

comofficekit-mcp info contract.docx
comofficekit-mcp read contract.docx --from 0 --count 50
comofficekit-mcp render contract.docx 1 page1.png --dpi 96
comofficekit-mcp replace offer.docx "{{name}}" "Ada Lovelace" offer-ada.docx
comofficekit-mcp set-cells budget.xlsx Sheet1 budget-2027.xlsx B2=1200 "C2==B2*12" --read C20
comofficekit-mcp compare contract.docx contract-v2.docx changes.docx --author Review
comofficekit-mcp accept-all changes.docx clean.docx
comofficekit-mcp pdf deck.pptx deck.pdf

comofficekit-mcp help lists them all.

How it behaves

  • One folder. In the server, every path is inside the --root folder, and links are not followed.
  • Nothing overwritten by surprise. A tool that writes refuses an existing file unless the agent passes overwrite: true. Edits change nothing on disk until save_document.
  • No network. The engine makes no network call. With --network none, the container has none at all.
  • One document at a time. The engine works on one document at a time within a process, so the server runs one call at a time, each with a two-minute limit. At most 16 documents stay open; opening a 17th closes the one open longest.

Licence

This repository is under the MIT licence (LICENSE). The ComOffice SDK it uses is not open source: it is used under its own licence, with a licence key. The server also uses the Model Context Protocol C# SDK (ModelContextProtocol, Apache-2.0) and Microsoft.Extensions.Hosting (MIT).

About

An MCP server and command line that let AI agents open, read, edit, render and compare Word, Excel and PowerPoint files with the ComOffice .NET SDK. MIT. Questions: support@comofficekit.com

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages