Overview

The Office CLI Gateway lets agents and integrations read, mutate, and render Microsoft Office documents (docx, xlsx, pptx) by running the officecli binary server-side. The gateway handles document uploads, resident sessions, batch commands, artifact generation, live previews, and an MCP passthrough surface. Use the gateway when you need to:
  • Extract or update text, tables, or slides in Office documents.
  • Generate rendered HTML or PNG previews of a document.
  • Mail-merge documents from JSON data.
  • Expose officecli capabilities to an MCP client.

Base URL

All Office CLI gateway routes are mounted under the protected router:
Local development:

Authentication

Office CLI routes require a valid session. The gateway resolves the caller from the standard Allternit auth middleware and falls back to the x-allternit-user-id header in local development. Documents are isolated per user; one user cannot access another user’s uploads or artifacts.

Endpoints

Upload a document

Upload a binary Office document. The call returns a doc_id used for all subsequent operations.

Request headers

Response

Execute a command

Run any allowed officecli command against an uploaded document. Commands that modify the document should set session: true so the gateway opens a resident session first.

Request body

Allowed commands

Response

A non-zero exit code still returns HTTP 200 when officecli produced structured JSON output:

Render an artifact

view writes an HTML or PNG artifact that can be downloaded separately:
Response:

Download an artifact

Download the produced artifact or the original document by filename:
The response Content-Type is inferred from the file extension (html, png, docx, etc.).

Capabilities

Probe the installed officecli binary and list the commands the gateway will accept:
Response:

Live preview watch

Start a long-lived officecli watch process for a document and proxy preview requests into it:
Response:
Proxy the preview:
Stop the watch:
Response:

MCP passthrough

The gateway exposes the officecli MCP server over POST /api/v1/office/cli/mcp. The gateway maintains one stdio MCP session per user, lazily spawns it, and retries once if the child dies.
Response:
To target an uploaded document, pass doc_id at the top level. The gateway resolves the path, rewrites @doc placeholders inside params, and strips doc_id before forwarding:

Live filesystem mode

When ALLTERNIT_OFFICECLI_LIVE_FS is enabled, commands may target an absolute on-disk path via live_path instead of an uploaded doc_id. This is intended for trusted gateways that edit documents in place. Artifact-producing commands and file-creation verbs still require the upload flow.

Resource and lifecycle limits

Error codes