tb-ppt-mgagent

v0.8.0
@unboundai/tb-ppt-mgagent Checked 23 hours ago Published 27 days ago

MCP server that hands a presentation outline to the Traffic Builders PowerPoint Managed Agent, then retrieves the finished .pptx

A Model Context Protocol (MCP) server that hands a presentation outline to Anthropic's hosted Managed Agent for building Traffic Builders-branded PowerPoints, then retrieves the finished file once it's done. Brand assets (the design brief, logos, Outfit and Figtree fonts) are not assumed to already exist in the agent's environment. A Managed Agents "deployment" (scheduled/cron runs) was investigated as a way to pin a session to a specific pre-configured setup, but it only re-sends a fixed baked-in message on a schedule — it offers no extra asset-targeting capability over a plain session.

Summary extracted from the README.

Traffic Builders PowerPoint MCP Server

A Model Context Protocol (MCP) server that hands a presentation outline to Anthropic's hosted Managed Agent for building Traffic Builders-branded PowerPoints, then retrieves the finished file once it's done.

Brand assets (the design brief, logos, Outfit and Figtree fonts) are not assumed to already exist in the agent's environment. A Managed Agents "deployment" (scheduled/cron runs) was investigated as a way to pin a session to a specific pre-configured setup, but it only re-sends a fixed baked-in message on a schedule — it offers no extra asset-targeting capability over a plain session. So instead, this server uploads each brand asset once via the Files API (a one-time step, see Setup) and attaches them explicitly to every session it creates via the resources array, mounted into the sandbox for the agent to read.

Built against the official Managed Agents docs (session creation, session operations, events & streaming, files, event/type reference) using the official @anthropic-ai/sdk client, which sets the managed-agents-2026-04-01 beta header automatically for session endpoints.

Available tools

  • generate_tb_powerpoint(outline, deckType?, clientName?, filename?, attachments?) — creates a session against the configured agent + environment, attaches whichever brand asset resources are configured (see Setup), uploads any chat attachments to the Files API and mounts them too, sends the outline as the first message, returns { success, sessionId, message, attachmentsAttached, imageWarnings? }. Does not wait for the deck to finish. attachments is an optional array (max 10) of { path? | url? | data? | fileId?, filename?, mimeType?, placement? } — any file type (images to embed, PDFs/spreadsheets/documents as source material). images still works as a deprecated alias. See Chat attachments.

  • get_tb_powerpoint_result(sessionId) — checks on a generation started above:

    1. Retrieves the session. If its status isn't idle, returns { ready: false, status } — still running, try again later.
    2. If idle, finds the most recent session.status_idle event and checks its stop_reason.type. Only proceeds if it's end_turn (a clean finish) — a different stop reason (e.g. a budget cap) also returns { ready: false, ... } rather than treating the session as done.
    3. Lists files scoped to the session, filters for a .pptx filename (preferring one whose path looks like it's under an outputs directory), downloads it via the Files API into TB_PPT_OUTPUT_DIR (the local folder synced to GCS outside this server), and returns a download link built from TB_PPT_PUBLIC_URL_BASE.

Otto outlines and drafts

The outline agent (Otto) delivers outlines in a strict format (# Outline - ... header, ## Hoofdstuk N - ..., ### Slide N · TYPE · status blocks). Send those with outlineFormat: "otto-v1": the generator then builds exactly the listed slides in that order (section 11 of the design brief) and adds no agenda, dividers or closing slide.

  • generate_tb_powerpoint also takes outlineFormat (free | otto-v1), entity (trafficbuilders | unbound | shoq), deckType (pitch-lang, pitch-kort, pitch-afwijkend, publieke-talk, kennisdeling, rapportage) and draftId. outline becomes optional when a draftId is given.
  • Big decks do not fit in one tool call (the agent's output limit): start_tb_powerpoint_draft(entity, deckType, outlineHeader, clientName?, filename?) returns a draftId; append_tb_powerpoint_outline(draftId, partIndex, part) adds a batch (idempotent per partIndex, starting at 1; numbering must continue across parts); generate_tb_powerpoint(draftId) joins the parts and starts the session. Drafts are JSON files in TB_PPT_DRAFT_DIR and expire after 24 hours.
  • Checks: the server counts slides and chapters, warns about gaps in the slide numbering and about slides without a status, and refuses an otto-v1 outline without ### Slide blocks.
  • Entities: unbound uses the Traffic Builders brief (with TB_UNBOUND_LOGO_FILE_ID, if set, as the logo). shoq is refused until TB_SHOQ_DESIGN_BRIEF_FILE_ID points to a Shoq design brief.
  • Standard slides ([std: werktitel]): cover, afsluiter and rean-raamwerk are built from the design system's archetypes; other titles are mounted from TB_STD_SLIDES_FILE_IDS (JSON {"werktitel": "file_id"}); titles that are in neither become a placeholder slide.
  • Result: get_tb_powerpoint_result also returns placeholders (slide number + text of every open [AAN TE LEVEREN]) and buildNotes, read from placeholders.json and build-notes.md that the agent writes to its outputs.

Chat attachments

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-side fetch).
  • 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 insert images 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_PPT_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.

TypingMind (URL flow)

A plain MCP tool call (which is what generate_tb_powerpoint is) has no visibility into chat attachments at all — TypingMind only exposes resources.userMessage.attachments to a JavaScript-implementation regular plugin with the read_user_message permission, never to a native/remote MCP tool. So getting an attached image into a deck is a two-step chain:

  1. A small companion TypingMind plugin surfaces the attachment. In TypingMind's Admin Panel → Plugins → Create New Plugin, set up a plugin like this (a "Regular Plugin", separate from this MCP server's registration):

    • Name: get_chat_attachments
    • Description (used for tool selection): "Returns the direct URL, MIME type, and filename of any file/image the user attached to their most recent message in this chat. Call this whenever the user references an attachment (e.g. 'insert this logo', 'use this screenshot') so its URL can be passed to another tool such as generate_tb_powerpoint's images parameter."
    • Parameters: none
    • Permissions: read_user_message
    • Implementation type: JavaScript Code
      async function get_chat_attachments(params, userSettings, resources) {
        const attachments = (resources && resources.userMessage && resources.userMessage.attachments) || [];
        if (attachments.length === 0) {
          return JSON.stringify({ attachments: [], message: "No attachments found on the user's most recent message." });
        }
        return JSON.stringify({
          attachments: attachments.map(function (a) {
            return { url: a.url, type: a.type, name: a.name };
          })
        });
      }
      
    • Plugin Context (recommended, injected into the system prompt): "When the user says they attached/added/pasted an image or file and references it (e.g. 'zet dit logo op de titelslide'), call get_chat_attachments first to get its URL, then pass that URL into generate_tb_powerpoint's images array along with a placement describing what the user asked for, in their own words."
  2. The model chains the two tools itself. With both plugins active in the same chat, the flow the model follows is: user attaches an image and says where it goes → model calls get_chat_attachments → gets back { url, type, name } → calls generate_tb_powerpoint with images: [{ url, mimeType: type, filename: name, placement: "<what the user asked for>" }]. This server then fetches that URL itself (a plain server-side fetch — no browser/CORS involved), uploads the bytes to the Files API exactly like the brand logos, and mounts it into the session at /user-images/image-N.ext, telling the agent in the message text where to insert it.

One real unknown, worth testing before relying on this: it isn't confirmed whether the url TypingMind's attachment object returns is a plain, publicly-fetchable link, or one scoped to TypingMind's own browser session (which this server's server-side fetch() couldn't reach). Test it once by attaching an image, calling get_chat_attachments, and trying to fetch the returned URL independently (e.g. curl -I <url>) from outside TypingMind. If that fails, the fallback is already built in: images entries also accept data (base64 image bytes) instead of url — change the plugin's JS code above to fetch the attachment's url itself (fetch(a.url).then(r => r.arrayBuffer()), browser-side, where TypingMind's own session auth applies) and return base64-encoded data instead of url; no MCP-server code change is needed either way.

What's still an assumption

Every SDK call in src/index.ts (sessions.create, sessions.events.send, sessions.retrieve, sessions.events.list, files.list, files.download) is checked against @anthropic-ai/sdk's own .d.ts/source (installed version, not just the docs prose) — that's how a real bug was caught in 0.1.0: the docs' TypeScript sample for downloading a file shows content.writeToFile(path), but that method doesn't exist on the installed SDK. files.download() actually resolves to a plain Response; 0.1.1 fixes this by reading it with .arrayBuffer() and writing the bytes directly. The resources shape ({ type: "file", file_id, mount_path }) is likewise checked against the SDK source, not just the docs.

The one thing still not confirmed against a real response is the exact filename/path convention the Files API returns for a file the agent wrote to its outputs directory — the code guesses by matching /outputs?[\/]/i against the filename and falling back to any .pptx file on the session if nothing matches that pattern. If a real run's file list looks different, adjust the filter in get_tb_powerpoint_result in src/index.ts.

generate_tb_powerpoint's image-forwarding path (client.beta.files.upload(...), via the SDK's toFile() helper) is checked against the SDK source the same way, and is exercised by the same resources mechanism already used for brand assets — but the TypingMind-side attachment flow that's meant to feed it a URL has not been run end-to-end yet; see Sending an attached image from TypingMind for the one open question there.

Setup

  1. Install dependencies:

    npm install
    
  2. Build the project:

    npm run build
    
  3. Upload the brand assets (one time, or again whenever an asset changes):

    .\uploadAssets.ps1 -ApiKey "sk-ant-..."
    

    Without -ApiKey the script uses $env:ANTHROPIC_API_KEY, and otherwise ANTHROPIC_API_KEY=... from a .env file next to the script (git-ignored). Uploads TrafficBuilders-PPT-Handoff.md, all five logos/*.png, and both fonts/*-VariableFont_wght.ttf (Outfit, Figtree) to the Files API, and prints a file_id per asset along with the matching env var name. These are just config, not code — plug them into step 5 below and there's nothing else to change or republish.

  4. Configure environment variables:

    • ANTHROPIC_API_KEY — Anthropic API key with Managed Agents access.
    • ANTHROPIC_AGENT_ID — e.g. agent_01H8osDSMeEtGcEHT1ajzuin.
    • ANTHROPIC_ENVIRONMENT_ID — e.g. env_01VHzZmqBababsghFjQoAGFx.
    • ANTHROPIC_API_BASE — optional, overrides the SDK's default API base URL.
    • TB_PPT_OUTPUT_DIR — required for get_tb_powerpoint_result. Local folder that's synced to GCS by something outside this server; finished .pptx files are written here.
    • TB_PPT_PUBLIC_URL_BASE — required for get_tb_powerpoint_result. Base URL the synced folder is served from (e.g. https://storage.googleapis.com/bucket/prefix), used to build the returned download link.
    • TB_PPT_LOG_FILE — optional. Path to the task log file. Defaults to logs/tasks.log next to this package.
    • TB_PPT_DRAFT_DIR — optional. Folder for outline drafts (24 hours). Defaults to drafts/ next to this package.
    • TB_SHOQ_DESIGN_BRIEF_FILE_ID, TB_UNBOUND_LOGO_FILE_ID, TB_STD_SLIDES_FILE_IDS — optional, see Otto outlines and drafts.
    • TB_PPT_ATTACHMENT_ROOTS — optional. Folders that path attachments must live in.
    • TB_DESIGN_BRIEF_FILE_ID, TB_LOGO_HORIZONTAL_FILE_ID, TB_LOGO_HORIZONTAL_WHITE_FILE_ID, TB_LOGO_ICON_FILE_ID, TB_LOGO_ICON_WHITE_FILE_ID, TB_LOGO_ICON_TAGLINE_FILE_ID, TB_FONT_FILE_ID, TB_FONT_BODY_FILE_ID — all optional but strongly recommended, from step 3. Any left unset are just skipped (with a warning in the log) rather than failing the call — the deck still gets built, just without that asset available to the agent.
  5. Register with your MCP client (Claude Desktop / TypingMind's local MCP connector — same pattern as this repo's siblings, e.g. tb-gcs-assembly-mcp). Published to npm as @unboundai/tb-ppt-mgagent, so npx can run it without a local checkout:

    "tb-ppt-mgagent": {
      "command": "npx",
      "args": [
        "-y",
        "@unboundai/tb-ppt-mgagent"
      ],
      "env": {
        "ANTHROPIC_API_KEY": "sk-ant-...",
        "ANTHROPIC_AGENT_ID": "agent_...",
        "ANTHROPIC_ENVIRONMENT_ID": "env_...",
        "TB_PPT_OUTPUT_DIR": "/path/to/gcs-synced-folder",
        "TB_PPT_PUBLIC_URL_BASE": "https://storage.googleapis.com/your-bucket/your-prefix",
        "TB_DESIGN_BRIEF_FILE_ID": "file_...",
        "TB_LOGO_HORIZONTAL_FILE_ID": "file_...",
        "TB_LOGO_HORIZONTAL_WHITE_FILE_ID": "file_...",
        "TB_LOGO_ICON_FILE_ID": "file_...",
        "TB_LOGO_ICON_WHITE_FILE_ID": "file_...",
        "TB_LOGO_ICON_TAGLINE_FILE_ID": "file_...",
        "TB_FONT_FILE_ID": "file_...",
        "TB_FONT_BODY_FILE_ID": "file_..."
      }
    }
    

    Or, from a local checkout of this repo:

    "tb-ppt-mgagent": {
      "command": "node",
      "args": [
        "/path/to/tb-ppt-mgAgent/build/index.js"
      ],
      "env": { "...": "same as above" }
    }
    

Publishing a new version

npm version patch   # or minor/major
npm publish         # prepublishOnly rebuilds automatically; will prompt for a 2FA OTP

Task logging

Every tool call writes one JSON-lines entry to TB_PPT_LOG_FILE (default logs/tasks.log) and mirrors it to stderr (which the MCP host's own log viewer already shows, as seen in the [powerpoint-creator] logs). Each line has a timestamp, tool, and status, plus whatever's relevant to that outcome:

status tool meaning
started either call received, with its key arguments (outline preview/length, or sessionId)
attaching_assets generate_tb_powerpoint which brand asset resources are being attached (attached, a list of mount paths) and which env vars are unset (missing)
success generate_tb_powerpoint session created; includes sessionId and assetsAttached count
not_ready get_tb_powerpoint_result session isn't idle yet; includes sessionStatus
agent_message get_tb_powerpoint_result the agent's own most recent agent.message text, up to 500 chars, in agentMessagePreview — this is what the agent actually said, not our derived status. Logged once the session is idle, before the stop-reason check, so it's there even on not_end_turn
not_end_turn get_tb_powerpoint_result idle, but stop_reason wasn't end_turn; includes stopReason
listing_files get_tb_powerpoint_result about to call Files API list for this session
files_listed get_tb_powerpoint_result includes fileCount, every .pptx candidate found (pptxCandidates, each with id/filename/sizeBytes), and which one was chosenFileId
no_output_file get_tb_powerpoint_result finished cleanly but no .pptx found; includes fileCount
download_started get_tb_powerpoint_result about to call Files API download; includes fileId, filename, expectedSizeBytes
download_completed get_tb_powerpoint_result bytes received; includes downloadedBytes
saving_file get_tb_powerpoint_result about to write to destPath inside outputDir
file_saved get_tb_powerpoint_result write confirmed via fs.statSync; includes savedBytes and bytesMatch (should be true)
success get_tb_powerpoint_result fully done; includes filename, destPath, downloadUrl
invalid_arguments either zod validation failed; includes details
error either anything else threw; includes message

The agent's actual final message is also returned to the caller as agentMessage on every get_tb_powerpoint_result response (not just logged), so a not-quite-right run can be diagnosed from the tool's own output, not just the log file.

All entries include durationMs except the intermediate progress lines (attaching_assets, agent_message, listing_files, files_listed, download_started, download_completed, saving_file) — those are pure checkpoints, timed by their surrounding started/success/error lines instead. To see what's been run:

tail -f logs/tasks.log
# or, for just failures:
grep -E '"status":"(error|not_end_turn|no_output_file)"' logs/tasks.log

Development

# Watch mode
npm run dev

Both tools were smoke-tested end-to-end over the real MCP protocol (tools/list, and calling each with a dummy API key to confirm the SDK calls actually reach api.anthropic.com and get a real 401 authentication_error back rather than failing on a wrong method/shape before the network call) — including with asset env vars set, to confirm the resources array builds correctly.

Design brief reference

TrafficBuilders-PPT-Handoff.md, logos/, and fonts/ in this repo are the source material — pulled from the "Traffic Builders Design System" Claude Design project (colors, type scale, the 29 slide archetypes, brand logo PNGs, Outfit variable font) — that uploadAssets.ps1 uploads and every session attaches via resources. Update the files here first if the design system changes, then re-run uploadAssets.ps1 and update the env vars with the new file_ids. No slide-image assets are attached separately — the handoff brief embeds a literal HTML/CSS reference snippet per archetype, which is enough on its own (see its closing section for when a visual PNG reference would be worth adding).