Skip to main content
Glama

execute_officejs

Runs custom Office.js code inside the open PowerPoint presentation to add shapes, edit text, change colors, or manage slides in place without reimporting.

Instructions

Execute arbitrary Office.js code inside the live PowerPoint presentation. The code runs inside PowerPoint.run(async (context) => { ... }) with 'context' available as a variable. Use 'await context.sync()' after loading properties. Return a value to get it back as the tool result. For positioning, all values are in points (1 point = 1/72 inch). Common operations: add shapes, set text, change colors, add/delete slides. Edits run in place without reimporting the slide, so PowerPoint's current view position is preserved — prefer this over edit_shape_paragraphs / edit_slide_xml for text-only or formatting-only changes. Host limitations (live-tested on PowerPoint for Mac): (1) slide.shapes.getItemById and getItemByName do NOT exist — load shapes.load("id"), sync, then iterate shapes.items and match String(sh.id). (2) Loading textFrame paths (textFrame/hasText, textFrame/textRange/text) on shapes without text frames (Graphic/image shapes) fails the whole context.sync() with a bare InvalidArgument — load "id" first, then load textFrame paths only on shapes known to be text shapes, or wrap per-shape loads in separate syncs with try/catch.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>"
    },
    "name": "execute_officejs"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesOffice.js code to execute. Runs inside PowerPoint.run() with 'context' available. Use 'return' to send back a result.
presentationIdNoTarget presentation ID from list_presentations. Optional when only one presentation is connected.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.6.0

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does substantial work: it declares the runtime contract (context variable, mandatory context.sync(), return-to-get-result), discloses that edits mutate the live deck in place without reimport, and documents two live-tested host failure modes (missing getItemById/getItemByName, InvalidArgument from loading textFrame paths on non-text shapes). It stops short of stating the security/irreversibility profile of executing arbitrary code or what happens on thrown errors.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core contract in the first two sentences, then routing, then numbered host limitations — the ordering matches what an agent needs. The numbered limitation block is long but each item prevents a specific, repeatable failure, so little is padding; slightly tighter prose could cut the redundancy between 'rubric' clauses.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a two-parameter, output-schema-less code-execution tool, everything needed for a correct first call is present: execution context, sync requirement, unit conventions, return-value mechanism, mutation effect, and known host quirks with workarounds. No return-shape documentation is required since results are whatever the caller returns.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds genuine meaning to 'code' beyond the schema: the wrapper it runs inside, the availability of 'context', the required sync pattern, the return convention, and that all positioning values are in points (1/72 inch). 'presentationId' is not addressed in the description, which is acceptable given the schema documents it as optional-when-single-presentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Execute arbitrary Office.js code inside the live PowerPoint presentation') plus the execution wrapper (PowerPoint.run with 'context') and the effect of the edit (in-place, view preserved). It explicitly names the sibling tools it competes with (edit_shape_paragraphs / edit_slide_xml), so an agent can place it in the toolset without opening a schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a concrete routing rule: prefer this over edit_shape_paragraphs / edit_slide_xml for text-only or formatting-only changes, because edits run in place and preserve the view. It also lists common operations (add shapes, set text, change colors, add/delete slides). It does not state when NOT to reach for arbitrary code (e.g. when a dedicated sibling is safer or faster for structural edits), so the guidance covers one comparison rather than a full decision tree.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.