tb-word-mgagent
v0.3.1MCP server that hands a document outline to the Traffic Builders Word Managed Agent, then retrieves the finished .docx
A Model Context Protocol (MCP) server that hands a document outline to Anthropic's hosted Managed Agent for building Traffic Builders-branded Word documents, then retrieves the finished file once it's done. This is a sibling of tb-ppt-mgagent (the parent folder) — same Managed Agents wiring, same brand-asset-attachment pattern via the Files API — pointed at a separate agent/environment configured to write .docx instead of .pptx, and at a Word-specific design brief (TrafficBuilders-Word-Handoff.md) instead of the slide-deck one.
Summary extracted from the README.
Traffic Builders Word MCP Server
A Model Context Protocol (MCP) server that hands a document outline to Anthropic's hosted Managed Agent for building Traffic Builders-branded Word documents, then retrieves the finished file once it's done.
This is a sibling of tb-ppt-mgagent (the parent folder) — same Managed Agents wiring, same brand-asset-attachment pattern via the Files API — pointed at a separate agent/environment configured to write .docx instead of .pptx, and at a Word-specific design brief (TrafficBuilders-Word-Handoff.md) instead of the slide-deck one. See the parent README for the full rationale behind the resources-attachment approach and the Managed Agents SDK quirks (e.g. files.download() returning a plain Response, not a writeToFile()-capable object) — it isn't repeated here.
Available tools
-
generate_tb_word_document(outline, template?, docType?, clientName?, contactPerson?, author?, date?, version?, cover?, numberedHeadings?, tableOfContents?, filename?, attachments?)— creates a session against the configured agent + environment, attaches the brand assetresources(brief, logos, Outfit + Figtree fonts), uploads any chat attachments and mounts them too, sends the outline as the first message, returns{ success, sessionId, message, attachmentsAttached, imageWarnings? }. Does not wait for the document to finish.templateis one ofstandaard(default),formeel,contract,bold(see the brief;contractis currently built likeformeel, legal structure still to be defined).clientNameis the Opdrachtgever;contactPerson,author,date(dd-mm-jjjj, default today) andversion(default 0.1) fill the meta table/bar of formeel, contract and bold. The footer text© Traffic Builders B.V. 2001–{creation year} · P.J. Oudweg 4, 1314 CH Almereis fixed; the server computes the creation year and passes it to the agent.cover,numberedHeadingsandtableOfContents(auto|yes|no, defaultauto) override the brief's default logic: nothing unless the document is 5+ pages, a whitepaper, offerte or formal document (strategie, mediaplan, plan van aanpak, beleidsdocument); TOC when numbered or 5+ pages.attachmentsis an optional array (max 10) of{ path? | url? | data? | fileId?, filename?, mimeType?, placement? }— any file type (images embedded as numbered figures, PDFs/spreadsheets/documents as source material).imagesstill works as a deprecated alias. See Chat attachments. -
get_tb_word_document_result(sessionId)— checks on a generation started above, following the same idle/end_turn/file-list/download flow as the PowerPoint server'sget_tb_powerpoint_result, but filtering for a.docxfilename instead of.pptx.
Chat attachments
Same behaviour as the PowerPoint sibling. An MCP tool call cannot see chat attachments by itself, so the calling model passes a reference:
path(preferred in Claude Desktop / Claude Code): the attachment is stored on disk and the model knows its absolute path. The server reads the file itself, so no bytes travel through the model.url: a directly fetchable URL (server-sidefetch).data: base64 bytes, as a last resort (costs tokens).fileId: a file already in the Files API, mounted without re-uploading.
Each file is uploaded to the Anthropic Files API and mounted at /mnt/session/uploads/user-attachments/<n>-<name>; the first message tells the agent to embed images as numbered figures with a caption at the given placement and to use other files as source material. A source that fails (bad path, HTTP error) is skipped and reported in imageWarnings instead of failing the whole call.
Optional hardening: set TB_DOC_ATTACHMENT_ROOTS to one or more folders (separated by ; on Windows, : elsewhere); path attachments outside them are refused. Unset means any readable local file is allowed.
Setup
-
Install dependencies (from this
word/folder):npm install -
Build the project:
npm run build -
Upload the brand assets (one time, or again whenever an asset changes):
.\uploadAssets.ps1 -ApiKey "sk-ant-..."Uploads
TrafficBuilders-Word-Handoff.md, all fivelogos/*.png, andfonts/Outfit-VariableFont_wght.ttfto the Files API, and prints afile_idper asset along with the matchingTB_DOC_*env var name. -
Configure environment variables:
ANTHROPIC_API_KEY— Anthropic API key with Managed Agents access.ANTHROPIC_AGENT_ID— the Word-document agent's id. This must be a different Managed Agent than the PowerPoint server's (or at least one configured/prompted to produce.docxoutput) — the env var name is the same as the sibling server's on purpose, since each MCP server process gets its own isolatedenvblock in the client config (step 5), so there's no actual collision.ANTHROPIC_ENVIRONMENT_ID— e.g.env_01VHzZmqBababsghFjQoAGFx.ANTHROPIC_API_BASE— optional, overrides the SDK's default API base URL.TB_DOC_OUTPUT_DIR— required forget_tb_word_document_result. Local folder that's synced to GCS by something outside this server; finished.docxfiles are written here.TB_DOC_PUBLIC_URL_BASE— required forget_tb_word_document_result. Base URL the synced folder is served from, used to build the returned download link.TB_DOC_LOGO_ICON_WHITE_LARGE_FILE_ID,TB_DOC_FONT_BODY_FILE_ID— the large white brand mark (bold cover/back) and the Figtree body font; fromuploadAssets.ps1like the other asset ids.TB_DOC_ATTACHMENT_ROOTS— optional. Folders thatpathattachments must live in.TB_DOC_LOG_FILE— optional. Path to the task log file. Defaults tologs/tasks.lognext to this package.TB_DOC_DESIGN_BRIEF_FILE_ID,TB_DOC_LOGO_HORIZONTAL_FILE_ID,TB_DOC_LOGO_HORIZONTAL_WHITE_FILE_ID,TB_DOC_LOGO_ICON_FILE_ID,TB_DOC_LOGO_ICON_WHITE_FILE_ID,TB_DOC_LOGO_ICON_TAGLINE_FILE_ID,TB_DOC_FONT_FILE_ID— all optional but strongly recommended, from step 3. PrefixedTB_DOC_(rather than reusing the PowerPoint server'sTB_*names) so both servers' file ids can live in the same secrets store without colliding.
-
Register with your MCP client (Claude Desktop / TypingMind's local MCP connector), as its own separate server entry alongside
tb-ppt-mgagent:"tb-word-mgagent": { "command": "node", "args": [ "/path/to/tb-ppt-mgAgent/word/build/index.js" ], "env": { "ANTHROPIC_API_KEY": "sk-ant-...", "ANTHROPIC_AGENT_ID": "agent_...", "ANTHROPIC_ENVIRONMENT_ID": "env_...", "TB_DOC_OUTPUT_DIR": "/path/to/gcs-synced-folder", "TB_DOC_PUBLIC_URL_BASE": "https://storage.googleapis.com/your-bucket/your-prefix", "TB_DOC_DESIGN_BRIEF_FILE_ID": "file_...", "TB_DOC_LOGO_HORIZONTAL_FILE_ID": "file_...", "TB_DOC_LOGO_HORIZONTAL_WHITE_FILE_ID": "file_...", "TB_DOC_LOGO_ICON_FILE_ID": "file_...", "TB_DOC_LOGO_ICON_WHITE_FILE_ID": "file_...", "TB_DOC_LOGO_ICON_TAGLINE_FILE_ID": "file_...", "TB_DOC_FONT_FILE_ID": "file_..." } }This package isn't published to npm yet — register it from a local checkout as shown above (
npm run buildfirst). If you do want to publish it separately, give it a distinct npm name (already set to@unboundai/tb-word-mgagentinpackage.json) and follow the samenpm version/npm publishflow as the parent package.
Task logging
Same JSON-lines format as the parent server, written to TB_DOC_LOG_FILE (default logs/tasks.log in this folder) and mirrored to stderr, with docxCandidates in place of pptxCandidates at the files_listed step.
Design brief reference
TrafficBuilders-Word-Handoff.md, logos/, and fonts/ in this folder are this server's source material. Unlike the PowerPoint brief, the "Traffic Builders Design System" Claude Design project doesn't (yet) contain real Word/report templates to sync against — the brief's page-setup and Word-Styles sections are this project's own translation of the same brand tokens into standard Word conventions, and it says so explicitly at the top. See its closing section for the recommended next step (attaching a real approved .docx as a reference once one exists) and for what to do if the design-system project later adds real document templates.
Development
# Watch mode
npm run dev