Skip to main content
Glama

undo

Destructive

Revert the last edit or several by stepping the editor's shared undo stack back, as Ctrl+Z does, and report what is now on top.

Instructions

Step the editor's undo stack back by one transaction, or by count of them, as Ctrl+Z does, and report what is now on top.

Use it to revert an edit made in the editor, by a tool or by a person: the stack is shared, so read get_undo_state first to see the label you are about to revert. One tool call that changed something is usually one transaction; begin_transaction and end_transaction make several edits one. Undo reverts objects in memory, not files: an edit already saved stays on disk until the next save.

Example: {"count": 3} undoes the last three transactions. It stops early at the bottom of the stack or at an undo barrier (set_undo_barrier), and actually_undone then falls short of requested. success is true even with nothing to undo: read applied, and re-read what you changed to confirm it.

Returns: { applied: bool, requested: int, actually_undone: int, undo_count: int, can_undo: bool, next_undo: string }

Input Schema

NameRequiredDescriptionDefault
countNoOptional. How many transactions to undo, at least 1 (default 1); stops early when the stack runs out or reaches an undo barrier. Below 1 is refused.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv2.0.0
    • addedInput schema / properties / count
      Added value: +{
      +  "description": "Optional. How many transactions to undo, at least 1 (default 1); stops early when the stack runs out or reaches an undo barrier. Below 1 is refused.",
      +  "type": "number"
      +}
  2. First observedv1.1.0

TDQS

A4.8/5.0
Behavior5/5

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

Goes well beyond the annotations: it discloses that undo affects objects in memory and not files (a saved edit stays on disk until the next save), that it stops early at stack bottom or an undo barrier, and that `success` can be true with nothing undone so the caller must read `applied`. Those are exactly the non-obvious behavioral traits an agent needs for a destructive operation.

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 action, then usage, then edge cases, then a compact returns block. Dense but almost every sentence earns its place; the only waste is mild overlap between the description and the `count` schema on early stopping.

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?

There is no output schema, and the description compensates by enumerating the return fields (applied, requested, actually_undone, undo_count, can_undo, next_undo) and explaining the trap of `success` being true when nothing was undone. For a single-parameter destructive tool, nothing material is left unexplained.

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 schema already carries the core meaning of `count` (minimum 1, default 1, early stop at barriers). The description still adds value with a concrete example ({"count": 3}) and by tying the count to the early-stop/actually_undone semantics, though it partly restates the schema.

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?

Specific verb (step back) plus resource (the editor's undo stack) with explicit scope (one transaction or `count` of them) and a familiar analogue (Ctrl+Z). It also states what it returns on top, which separates it cleanly from get_undo_state and set_undo_barrier mentioned in the text.

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?

Explicitly says when to use it (revert an edit made by a tool or a person), names the prerequisite (read get_undo_state first to see the label you are about to revert), and explains the transaction granularity including begin_transaction/end_transaction. That is genuine when/how guidance rather than implied usage.

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