Skip to main content
Glama

edit_docx

Replace exact text in a Word .docx even where it spans formatting runs, writing a new outputPath (the original is kept). oldText must occur expectedOccurrences times (default 1). part: body (default), header, footer or all. mode xml replaces XML copied from read_file docxMode xml. Images, fields and untouched parts are preserved; signed files are refused.

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": {
      "inputPath": "<inputPath>",
      "outputPath": "<outputPath>",
      "oldText": "<oldText>",
      "newText": "<newText>"
    },
    "name": "edit_docx"
  }
}

Input Schema

NameRequiredDescriptionDefault
modeNotext
partNo
newTextYes
oldTextYes
deviceIdNoComputer name or id
inputPathYes
outputPathYes
workSessionIdNoFrom create_work_session
expectedOccurrencesNo
includeHeadersFootersNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changed
    • changedInput schema / properties / deviceId / description
      Previous value: -"Computer name or id; optional with one computer or a default"New value: +"Computer name or id"
    • removedInput schema / properties / newText / maxLength
      Removed value: -100000
    • removedInput schema / properties / oldText / maxLength
      Removed value: -100000
    • removedInput schema / properties / oldText / minLength
      Removed value: -1
  2. Changed2 schema fields changed
    • changedInput schema / properties / deviceId / description
      Previous value: -"Computer name or id from list_devices. Optional with one computer online or a default set."New value: +"Computer name or id; optional with one computer or a default"
    • changedInput schema / properties / workSessionId / description
      Previous value: -"Work session from create_work_session. Pass the same ID on every call in this conversation; omit for legacy unscoped work."New value: +"From create_work_session"
  3. Changed1 schema field changed
    • addedInput schema / properties / workSessionId
      Added value: +{
      +  "description": "Work session from create_work_session. Pass the same ID on every call in this conversation; omit for legacy unscoped work.",
      +  "format": "uuid",
      +  "type": "string"
      +}
  4. First observed

TDQS

A4.3/5.0
Behavior4/5

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

Annotations declare readOnlyHint=false and destructiveHint=false, and the description backs that up by explaining the original file is preserved and a new outputPath is written — no annotation contradiction. It further discloses that images, fields and untouched parts are preserved, that signed files are refused, and that oldText must occur expectedOccurrences times. It stops short of describing what happens on an occurrence mismatch (error vs partial write) or whether an existing outputPath is overwritten.

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

Conciseness5/5

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

Four dense sentences, front-loaded with the core action and output effect, then matching rules, then scoping options, then preservation/refusal caveats. No filler or restatement of the tool name.

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?

For a 10-parameter mutation tool with no output schema and 20% schema coverage, the description covers the critical semantics well but omits three parameters (deviceId, workSessionId, includeHeadersFooters) and never says what the call returns (e.g., the resulting file path) or how partial/ambiguous matches are reported. Adequate but with real gaps for a tool of this complexity.

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 only 20%, so the description must compensate, and it does for oldText, newText, outputPath, expectedOccurrences (default 1), part (body default, header/footer/all) and mode. It leaves deviceId, workSessionId and includeHeadersFooters unexplained, and does not describe the accepted format of part's regex-allowed 'word/headerN.xml' values beyond the enum-like enumeration.

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 ('Replace exact text in a Word .docx'), plus a distinguishing technical capability ('even where it spans formatting runs') and the output contract ('writing a new outputPath, the original is kept'). This clearly separates it from siblings like edit_spreadsheet, edit_block and read_file.

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 concrete selection guidance for the alternatives that matter: mode 'xml' is for XML copied from read_file with docxMode xml, and 'part' selects body/header/footer/all. It also states a precondition (signed files are refused). It does not explicitly contrast with edit_block or say when this is preferable to read_file-then-rewrite, but the mode routing is clear.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources