Skip to main content
Glama

checkpoint

Create a checkpoint before modifying, deleting, or creating files to enable undo functionality. Ensures safe file operations by saving states prior to changes.

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
descriptionNoConcise, action-focused description of the next specific change to be madeManual checkpoint
filesYesArray of file paths that will be modified, created, or deleted

Implementation Reference

  • MCP tool handler for 'checkpoint': validates input arguments, invokes ChangeTracker.createCheckpoint, formats and returns success response with captured files.
    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')}`, }, ], }; }
  • Tool schema definition for 'checkpoint' including name, description, and inputSchema 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 list of available tools, including 'checkpoint', for the ListToolsRequestSchema.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS, }));
  • Core implementation of checkpoint creation in ChangeTracker class: reads current file contents, identifies new files, creates UndoCheckpoint, pushes to undo stack.
    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}`); }
  • Type definition for UndoCheckpoint used by the checkpoint system.
    interface UndoCheckpoint { files: Map<string, string>; // filepath -> content createdFiles: Set<string>; // files that were created (didn't exist before) timestamp: Date; description: string; }

Other Tools

Related 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