Golder docx MCP extension
golder-docx is a separate MCP stdio executable for reading, creating and
editing .docx files inside the current workspace. It uses
docxgo v2 for document construction
and template replacement, with a security layer in front: workspace-confined
paths, ZIP/XML resource limits, macro/embedded-content rejection, image
re-encoding and atomic output.
Build
GOWORK=off go build -o .build/golder-docx ./extension/plugins/docx/cmd/golder-docx
Install from the desktop GUI
Open Extensions → DOCX → Install & enable. No TOML edit is required. The
menu downloads the matching signed helper, shows the current phase and byte
progress, and then asks for the normal explicit source approval.
Download order is:
- direct GitHub release asset;
- every mirror prefix configured in
GOLDER_MIRROR (space-separated), one at
a time;
- the helper bundled with the desktop app, if the release or network is
unavailable.
Checksums come from the same release. Mirror checksum copies must agree, and
the archive and extracted binary are verified before installation. A failed
mirror is skipped and the next source is attempted; progress shows the source
host and source N/M. Set GOLDER_MIRROR=off to disable mirror fallback.
The installed helper lives under the protected Golder state directory. The
source is written disabled and is enabled only by the explicit GUI action.
Generate a disabled source table and merge it into $GOLDER_HOME/config.toml:
.build/golder-docx print-config
[mcp.servers.docx]
enabled = false
transport = "stdio"
command = "/abs/path/golder-docx"
args = ["serve"]
allowed_tools = ["docx_read", "docx_create", "docx_edit"]
call_timeout = "30s"
network = false
The workspace root is the process working directory. Use --root <dir> only
when the host does not start the plugin in the project directory; the root is
part of the source fingerprint and must be re-approved after a change.
golder mcp inspect docx
golder mcp enable docx --yes
docx_read (read-only)
{"path": "docs/report.docx", "format": "markdown", "max_chars": 200000}
format is text, markdown or outline. Returns paragraphs, table text and
image metadata (format, pixel size, alt text). It does not return image bytes,
execute macros, follow external links, or download anything. Document text is
untrusted data, not instructions.
docx_create
{
"path": "docs/report.docx",
"title": "Quarterly report",
"blocks": [
{"type": "heading", "level": 1, "text": "Summary"},
{"type": "paragraph", "text": "Revenue grew."},
{"type": "bullets", "items": ["one", "two"]},
{"type": "table", "rows": [["Name", "Value"], ["A", "1"]]},
{"type": "image", "path": "logo.png", "width_px": 240, "height_px": 120}
],
"overwrite": false
}
Images are decoded, pixel-limited, re-encoded as PNG and embedded. Headings use
the built-in Heading1..Heading6 styles. Output is written through a sibling
temp file and renamed into place; an existing file is kept unless
overwrite=true.
docx_edit
{
"path": "docs/template.docx",
"output": "docs/filled.docx",
"replacements": {"{{name}}": "Alice"},
"append": [{"type": "paragraph", "text": "Generated by golder"}],
"overwrite": false
}
Replacement is literal and case-sensitive. The input is never modified in
place; the output is a separate workspace-relative .docx. Macro-enabled,
encrypted, OLE, altChunk, ActiveX and embedded-object packages are rejected
before parsing.
Security boundary
| Control |
Limit |
Input .docx |
25 MiB |
| ZIP entries |
1024 |
| Single extracted part |
32 MiB |
| Total extracted |
128 MiB |
| Compression ratio |
200:1 |
| XML part |
32 MiB, depth 128 |
| Image |
20 MiB, 25 megapixels, 64 per document |
| Read output |
2M chars |
Output .docx |
50 MiB |
| Table |
200 rows × 50 columns, 20k cells |
Paths must be workspace-relative, end in .docx (images: PNG/JPEG/GIF), and
must not be symlinks. Absolute paths, .., NUL and backslash separators are
rejected. Output parents must resolve inside the workspace. Writes are atomic
and mode 0600.
The plugin does not use docxgo's JSON-RPC/CLI mode and does not perform a
byte-for-byte round-trip of untrusted input; it reads standard body content and
creates new documents from the structured model. The audit and threat model
are in docs/docx-plugin-design.md.
Tests
GOWORK=off go test ./extension/plugins/docx/...
The suite covers path traversal, symlinks, macro/.docm rejection, OLE
packages, deep XML, unsafe/duplicate part names, ZIP entry limits, overwrite
guards, read truncation, and create/read/edit round-trips with an image.
Versioning
The helper version lives in version/version.go and is reported by
golder-docx --version and MCP initialization. The docxgo dependency is pinned
to v2.16.0.