Skip to main content
Glama
KitchenSink4AI

io.github.nometalalchemist/kitchensink4xl

Apply Edits

apply_edits
Destructive

Apply a batch of cell edits to an Excel file as a single atomic operation, validating all changes before writing and automatically restoring the original file if verification fails.

Instructions

Apply many addressed edits as ONE atomic batch. edits is a list of {op, location, ...}: set_value {value}, set_formula {formula}, clear {what: contents|formats|all}, write_range {data: 2D array}. location is any location object, including a stale-checked get_grid_view anchor.

Every location is resolved and every op validated BEFORE anything is written, so a single bad edit refuses the whole batch and the file stays byte-for-byte unchanged. The batch then takes ONE backup (prev/anchor slots in .ks4xl-backups), does ONE atomic save, and runs ONE verify-after-write, which restores from the backup if the produced file fails to read back as intended. Formula edits are normalized and flag recalculation; each write_range op honors the 200,000-cell ceiling. A hazardous workbook refuses unless allow_loss is true; refuses while the file is open in Excel. Returns the count of edits applied and cells touched.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
editsYesEdits applied as ONE atomic batch: {op, location, ...}.
backupNo
allow_lossNo
verify_comNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.2.0
    • changedOutput schema / (root)
      Previous value: -{
      -  "additionalProperties": true,
      -  "type": "object"
      -}New value: +null
  2. Changed4 schema fields changedv1.1.0
    • addedInput schema / properties / edits / description
      Added value: +"Edits applied as ONE atomic batch: {op, location, ...}."
    • addedInput schema / properties / edits / items / properties
      Added value: +{
      +  "data": {
      +    "description": "Rows of cell values, rectangular: every row the same length.",
      +    "items": {
      +      "items": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "number"
      +          },
      +          {
      +            "type": "boolean"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "description": "A cell value: text, a number, a boolean, or null to clear. A string beginning with '=' is stored as a formula."
      +      },
      +      "type": "array"
      +    },
      +    "type": "array"
      +  },
      +  "formula": {
      +    "type": "string"
      +  },
      +  "location": {
      +    "anyOf": [
      +      {
      +        "type": "string"
      +      },
      +      {
      +        "type": "object"
      +      }
      +    ]
      +  },
      +  "op": {
      +    "enum": [
      +      "set_value",
      +      "set_formula",
      +      "clear",
      +      "write_range"
      +    ],
      +    "type": "string"
      +  },
      +  "value": {
      +    "anyOf": [
      +      {
      +        "type": "string"
      +      },
      +      {
      +        "type": "number"
      +      },
      +      {
      +        "type": "boolean"
      +      },
      +      {
      +        "type": "null"
      +      }
      +    ],
      +    "description": "A cell value: text, a number, a boolean, or null to clear. A string beginning with '=' is stored as a formula."
      +  },
      +  "what": {
      +    "enum": [
      +      "contents",
      +      "formats",
      +      "all"
      +    ],
      +    "type": "string"
      +  }
      +}
    • addedInput schema / properties / edits / items / required
      Added value: +[
      +  "op",
      +  "location"
      +]
    • addedInput schema / properties / edits / items / type
      Added value: +"object"
  3. First observedv1.0.0

TDQS

A4.8/5.0
Behavior5/5

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

The description goes far beyond the annotations. Annotations indicate destructiveHint=true and readOnlyHint=false, but the description details the atomic all-or-nothing behavior, pre-validation, single backup, atomic save, verify-after-write, and restore-on-failure. It also clarifies refusal conditions and the 200,000-cell ceiling for write_range. This offers deep behavioral insight that annotations only hint at.

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?

The description is rich and detailed, but it is somewhat lengthy. It front-loads the core purpose ('atomic batch') and then provides necessary behavioral details. There is little redundancy, but the density could be slightly reduced for quicker scanning.

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?

Given the complexity of the tool (1-5 parameters, multiple edit operations), the description covers all critical aspects: atomicity, validation, backup, verify, restoration, limitations, and refusal conditions. It also clarifies return value ('Returns the count of edits applied and cells touched'), even with no output schema. The description is sufficient for an agent to invoke 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 description coverage is only 20%, meaning most parameters (edits, backup, allow_loss, verify_com) are not well described in the schema. The description compensates by explaining the edits structure with op values and their parameters, and clarifies backup/restore behavior for backup and verify. However, it does not detail the precise schema for backup or verify_com beyond defaults, so a slight gap remains.

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?

The description clearly states 'Apply many addressed edits as ONE atomic batch', specifying the verb (apply), resource (edits), and the atomic batch behavior. It distinguishes itself from siblings like set_cell, write_range, and clear_range by emphasizing the batch atomicity.

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

Usage Guidelines5/5

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

The description explicitly covers when to use it ('Apply many addressed edits as ONE atomic batch'), and implicitly guides away from single-edit tools like set_cell or write_range for multiple edits. It also provides exclusions: 'refuses while the file is open in Excel' and 'A hazardous workbook refuses unless allow_loss is true', which are clear usage conditions.

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