Skip to main content
Glama

execute_wordjs

Execute Office.js code in a live Word document to read or edit paragraphs, tables, searches, and tracked changes, then return results after syncing context.

Instructions

Execute arbitrary Office.js code inside the live Word document. The code runs inside Word.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. Common operations: read the body (context.document.body), insert paragraphs, search and replace, work with tables, read tracked changes.

Input Schema

NameRequiredDescriptionDefault
codeYesOffice.js code to execute. Runs inside Word.run() with 'context' available. Use 'return' to send back a result.
documentIdNoTarget document ID from list_documents. Optional when only one document is connected.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.6.0

TDQS

B3.4/5.0
Behavior3/5

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

With no annotations, the description carries the full burden. It discloses the execution model (wrapped in Word.run, context variable, return mechanism), which is genuinely useful. But it omits safety/permission implications of arbitrary code execution, error behavior, and whether a failed run can mutate or corrupt the document — significant gaps for a mutation-capable tool.

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 purpose, then execution details, then a compact list of common operations. Every sentence is informative and there is little waste, though the trailing operations list is somewhat loose.

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

Completeness3/5

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

Explains the execution context and how to retrieve return values, which is helpful given there is no output schema. But for a code-execution tool it should say more about documentId behavior, failure/error handling, and safety expectations.

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

Parameters3/5

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

Schema coverage is 100%, so both parameters (code, documentId) are already fully documented, including the Word.run context and the single-document default. The description adds only marginal detail beyond the schema, so baseline 3 applies.

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

Purpose4/5

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

States a specific verb+resource: 'Execute arbitrary Office.js code inside the live Word document.' The Word targeting distinguishes it from execute_officejs/execute_exceljs siblings, though it never explicitly contrasts with them. An agent can tell what it does.

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

Usage Guidelines3/5

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

Offers in-context API guidance (context.sync after loading properties, return values) and lists common operations, which implies when it's useful. However, it never routes the agent to the many specific Word siblings (insert_paragraph, replace_text, read_table) for simple tasks, nor says when this raw-escape-hatch tool should be preferred over them.

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