Skip to main content
Glama

Undo

photopea_undo
Destructive

Reverse one or more recent editing steps in the active document. Use after applying filters, adjustments, or fills to revert changes.

Instructions

Undo one or more recent actions in the active document. Each step reverses one operation from the history. Use after destructive operations (apply_filter, apply_adjustment, fill_selection) to revert changes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stepsNoNumber of history steps to undo (default 1)

Implementation Reference

  • The async handler for photopea_undo tool. It calls buildUndo(params.steps) to generate the script, sends activity, executes the script via the bridge, and returns the result.
    }, async (params) => {
      const script = buildUndo(params.steps);
      bridge.sendActivity({ type: "activity", id: "", tool: "undo", summary: `Undo ${params.steps} step(s)` });
      const result = await bridge.executeScript(script);
      if (!result.success) return { isError: true, content: [{ type: "text" as const, text: result.error || "Failed to undo" }] };
      return { content: [{ type: "text" as const, text: `Undid ${params.steps} step(s)` }] };
    });
  • Input schema for photopea_undo: a single 'steps' parameter (z.number().int().positive().default(1)) describing how many history steps to undo.
    inputSchema: {
      steps: z.number().int().positive().default(1).describe("Number of history steps to undo (default 1)"),
    },
  • Registration of photopea_undo tool via server.registerTool with title 'Undo' and description explaining its purpose.
    server.registerTool("photopea_undo", {
      title: "Undo",
      description: "Undo one or more recent actions in the active document. Each step reverses one operation from the history. Use after destructive operations (apply_filter, apply_adjustment, fill_selection) to revert changes.",
      inputSchema: {
        steps: z.number().int().positive().default(1).describe("Number of history steps to undo (default 1)"),
      },
      annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
    }, async (params) => {
      const script = buildUndo(params.steps);
      bridge.sendActivity({ type: "activity", id: "", tool: "undo", summary: `Undo ${params.steps} step(s)` });
      const result = await bridge.executeScript(script);
      if (!result.success) return { isError: true, content: [{ type: "text" as const, text: result.error || "Failed to undo" }] };
      return { content: [{ type: "text" as const, text: `Undid ${params.steps} step(s)` }] };
    });
  • The buildUndo function generates a Photoshop/Photopea script that accesses history states and sets the active history state to undo the specified number of steps.
    export function buildUndo(steps: number = 1): string {
      const lines: string[] = [];
      lines.push(`var _hs = app.activeDocument.historyStates;`);
      lines.push(`var _target = Math.max(0, _hs.length - 1 - ${steps});`);
      lines.push(`app.activeDocument.activeHistoryState = _hs[_target];`);
      lines.push(`app.echoToOE('ok');`);
      return lines.join("\n");
    }
Behavior3/5

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

Annotations already indicate destructiveHint=true and readOnlyHint=false. The description adds that each step reverses one history operation, which is expected. No contradiction, but limited additional insight beyond annotations.

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?

Two sentences, no fluff. Front-loaded with the main action and purpose, followed by usage guidance. Every sentence is valuable.

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?

For a simple tool with one parameter and clear annotations, the description is complete. It explains what it does, when to use it, and how many steps it affects. No missing information.

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?

The input schema has 100% coverage with a clear description for 'steps'. The description reiterates the concept but adds no new meaning beyond 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?

The description clearly states 'Undo one or more recent actions in the active document' with a specific verb and resource. It distinguishes from sibling tools like 'photopea_redo' and explicitly mentions use after destructive operations.

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?

The description explicitly states when to use the tool ('Use after destructive operations') and lists examples. It does not provide negative guidance but is sufficient for this simple tool.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/attalla1/photopea-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server