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:Authentication
Office CLI routes require a valid session. The gateway resolves the caller from the standard Allternit auth middleware and falls back to thex-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 adoc_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 setsession: true so the gateway opens a resident session first.
Request body
Allowed commands
Response
Render an artifact
view writes an HTML or PNG artifact that can be downloaded separately:
Download an artifact
Download the produced artifact or the original document by filename:Content-Type is inferred from the file extension (html, png, docx, etc.).
Capabilities
Probe the installedofficecli binary and list the commands the gateway will accept:
Live preview watch
Start a long-livedofficecli watch process for a document and proxy preview requests into it:
MCP passthrough
The gateway exposes the officecli MCP server overPOST /api/v1/office/cli/mcp. The gateway maintains one stdio MCP session per user, lazily spawns it, and retries once if the child dies.
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
WhenALLTERNIT_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.