Skip to main content
Glama

checkpoint

Create a file state snapshot before making modifications to enable undo functionality for AI-driven code editing experiments.

Instructions

MANDATORY: ALWAYS call this function FIRST before making ANY file modifications, deletions, or creations. This creates a checkpoint to enable undo functionality. This must be called before every single file operation - no exceptions. Never modify files without calling checkpoint first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filesYesArray of file paths that will be modified, created, or deleted
descriptionNoConcise, action-focused description of the next specific change to be madeManual checkpoint

Implementation Reference

  • MCP tool handler for 'checkpoint': validates input (requires files array), invokes ChangeTracker.createCheckpoint, and returns formatted success response with captured files list.
    case "checkpoint": {
      const files = args?.files as string[];
      const description = (args?.description as string) || "Manual checkpoint";
      if (!files || files.length === 0) {
        throw new Error("Files array is required");
      }
      await changeTracker.createCheckpoint(files, description);
      return {
        content: [
          {
            type: "text",
            text: `✅ Checkpoint created: "${description}"\nFiles captured: ${files.length}\n${files.map(f => `  - ${f}`).join('\n')}`,
          },
        ],
      };
    }
  • JSON Schema definition for the 'checkpoint' tool input, specifying required 'files' array and optional 'description'.
    {
      name: "checkpoint",
      description: "MANDATORY: ALWAYS call this function FIRST before making ANY file modifications, deletions, or creations. This creates a checkpoint to enable undo functionality. This must be called before every single file operation - no exceptions. Never modify files without calling checkpoint first.",
      inputSchema: {
        type: "object",
        properties: {
          files: {
            type: "array",
            items: { type: "string" },
            description: "Array of file paths that will be modified, created, or deleted",
          },
          description: {
            type: "string",
            description: "Concise, action-focused description of the next specific change to be made",
            default: "Manual checkpoint",
          },
        },
        required: ["files"],
      },
    },
  • src/index.ts:79-81 (registration)
    Registers the 'checkpoint' tool (via TOOLS array) for MCP ListToolsRequestSchema, making it discoverable by clients.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: TOOLS,
    }));
  • Implements checkpoint logic: iterates files, captures contents of existing ones, tracks potential new files, creates UndoCheckpoint object, and pushes to undoStack.
    async createCheckpoint(files: string[], description: string = "Manual checkpoint"): Promise<void> {
      const fileContents = new Map<string, string>();
      const createdFiles = new Set<string>();
    
      console.error(`[DEBUG] Creating checkpoint: ${description}`);
      console.error(`[DEBUG] Files to checkpoint: ${files.join(', ')}`);
    
      for (const filepath of files) {
        if (!existsSync(filepath)) {
          console.error(`[DEBUG] File will be created: ${filepath}`);
          createdFiles.add(filepath);
        } else {
          const content = readFileSync(filepath, "utf-8");
          fileContents.set(filepath, content);
          console.error(`[DEBUG] Captured content for ${filepath}: ${content.length} characters`);
        }
      }
    
      const checkpoint: UndoCheckpoint = {
        files: fileContents,
        createdFiles,
        timestamp: new Date(),
        description,
      };
    
      this.undoStack.push(checkpoint);
      console.error(`[DEBUG] Checkpoint created. Stack size: ${this.undoStack.length}`);
      console.error(`[DEBUG] Files to be created: ${Array.from(createdFiles).join(', ') || 'none'}`);
      console.error(`[DEBUG] Existing files captured: ${fileContents.size}`);
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It clearly indicates this is a prerequisite action for enabling undo functionality, implying it's a safe, non-destructive setup operation. However, it doesn't specify what happens if called multiple times, error conditions, or system-specific constraints like rate limits or permissions.

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

Conciseness3/5

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

The description is appropriately sized but repetitive ('This must be called before every single file operation - no exceptions. Never modify files without calling checkpoint first'). While front-loaded with the mandatory instruction, it could be more concise by eliminating redundancy while maintaining clarity.

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 tool with no annotations and no output schema, the description provides strong contextual completeness regarding its critical role in the workflow. It clearly explains the tool's purpose, mandatory usage, and relationship to file operations. However, it doesn't describe what the tool returns or confirm successful checkpoint creation, leaving some gaps.

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?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema (e.g., it doesn't explain format requirements for file paths or provide examples for the description field). Baseline 3 is appropriate when schema does the heavy lifting.

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 explicitly states the tool's purpose: 'creates a checkpoint to enable undo functionality' before file operations. It specifies the verb ('creates a checkpoint') and resource ('file modifications, deletions, or creations'), distinguishing it from siblings like 'undo' or 'list_undos' that handle existing checkpoints.

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 provides explicit usage instructions: 'ALWAYS call this function FIRST before making ANY file modifications, deletions, or creations' and 'before every single file operation - no exceptions'. It clearly states when to use it (before file changes) and when not to (without file changes), with strong emphasis on mandatory usage.

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/khalilbalaree/undo-mcp'

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