Skip to main content
Glama

Edit Excel cells, Word text or PDF pages

office_edit
DestructiveIdempotent

Use this when the user asks to change an Excel workbook (.xlsx, .xlsm) , a Word document (.docx, .docm) or a PDF in an approved project, without Office or another program. Workbook: values (rows of cells) are written from the range's top-left cell; formulas recalculate when the file is next opened in Excel. Document: oldText is replaced by newText inside paragraphs of the body, headers, footers and notes, across formatting runs, only when it occurs exactly expectedReplacements times (default 1); the new text takes the formatting where the match starts. PDF: operations delete pages or insert pages laid out from markdown or copied from another PDF in the project, in order. A deleted page leaves the file with its content and bookmarks; deleting also removes the accessibility tags (tagsRemoved). Pages with form fields cannot be deleted or copied; a signed or encrypted PDF is refused. Everything else in the file stays as it was. Changes files on the computer. Needs the sessionId from execution_session_open and a new operationId; each call is metered as one execution. A short result is returned inline within about two seconds; otherwise keep the returned IDs for operation_status and operation_output and do not resend the call.

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": {
      "sessionId": "<sessionId>",
      "operationId": "<operationId>",
      "path": "<path>"
    },
    "name": "office_edit"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYesWorkbook (.xlsx, .xlsm), document (.docx, .docm) or PDF (.pdf) path relative to the selected project root (or the workspace root)
rangeNoWorkbooks (required): top-left cell (C3), a range matching the values' size (C3:E5), or with a sheet (Sheet1!C3)
sheetNoWorkbooks: sheet name or 0-based index (default: the first sheet, or the sheet named in range)
valuesNoWorkbooks (required): rows of cells, text, a number, true/false, null (empty) or {formula: "=A1*2"}, up to 1 MiB as JSON
newTextNoDocuments (required): replacement text (may be empty)
oldTextNoDocuments (required): exact text to find inside one paragraph (tabs and line breaks allowed)
sessionIdYesexecutionSessionId returned by execution_session_open
deadlineAtNoOptional UTC admission deadline at most 60 seconds ahead (queue start timeout, NOT process execution lifetime)
operationsNoPDFs (required): 1-100 steps applied in order, page numbers from 1 as the document stands after the steps before: {type: "delete", pages: [2, 3]} or {type: "insert", at: 1 (before page 1; page count + 1 appends), markdown} or {type: "insert", at, sourcePath (another PDF in the project), sourcePages? (default all)}
operationIdYesA new random UUID v4 for this call; reuse it only to retry this same call
expectedSha256NoSHA-256 of the current file; the edit is refused if the file changed (recommended, from office_read)
idempotencyKeyNoOptional retry key, 8-128 chars of [A-Za-z0-9._:-]; defaults to operationId
efficiencyProfileNoOptional, unverified label of the client's model, recorded as display metadata in the device owner's local activity statistics. Omit when unknown. Never send credentials or conversation content.
expectedReplacementsNoDocuments: how many times oldText must occur; all are replaced (default 1)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.2/5.0
Behavior5/5

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

Beyond the destructiveHint=true annotation, it discloses what is actually lost: deleting a page removes accessibility tags (tagsRemoved) while content and bookmarks remain, form-field pages cannot be deleted or copied, and signed/encrypted PDFs are refused. It also covers formula recalculation timing, formatting inheritance on text replacement, metering (one execution per call), and the ~2s inline-result vs. polling fallback — exactly the operational context an agent needs before mutating files.

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?

It is front-loaded with the 'Use this when...' trigger and organized by format keyword (Workbook/Document/PDF), so scanning is feasible despite the length. The single dense paragraph packs multiple constraints per sentence and would be more navigable as bullets, but almost every clause carries distinct information.

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

Completeness4/5

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

For a 14-parameter tool with nested objects, no output schema, and three distinct operating modes, the description covers prerequisites, per-mode semantics, failure conditions, and the async completion path. Minor gaps remain — deadlineAt/admission-timeout behavior and the retry/idempotency interplay are only documented in the schema, not the description — but an agent has enough to call it correctly.

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 real semantics on top: values are written from the range's top-left cell, oldText must occur exactly expectedReplacements times or the edit is refused, and operationId should be reused only for retrying the same call. Page-numbering behavior across sequential PDF steps ('as the document stands after the steps before') is likewise clarified beyond the schema.

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?

The description names a specific verb ('change') and resource set (.xlsx/.xlsm, .docx/.docm, PDF) and immediately branches into per-format behavior, so an agent can tell this is an in-place editor rather than a whole-file writer. It never names the sibling office_write as the alternative for creating or replacing whole files, so the boundary against that sibling is left implicit.

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?

It gives a clear triggering condition (user asks to change an existing Office/PDF file in an approved project, without Office installed) and hard preconditions (sessionId from execution_session_open, a fresh operationId, optional expectedSha256 from office_read). It omits an explicit 'do not use for new files — use office_write' exclusion, which is the main guidance gap for a 14-parameter mutation tool.

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.