Skip to main content
Glama
coderdeep11

Claude Infinite Context

by coderdeep11

rollback

Revert to a previous checkpoint version to correct errors from merges or restore earlier project states.

Instructions

Revert to a previous checkpoint version. Useful if a merge produced incorrect results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stepsNoNumber of versions to roll back (default: 1)

Implementation Reference

  • Core handler function that performs the rollback by retrieving checkpoint history from Redis and restoring a previous project state.
    async rollback(steps: number = 1): Promise<string> {
      const sessionId = this.ensureInitialized();
    
      try {
        logger.info('Rolling back checkpoint', { sessionId, steps });
    
        const history = await this.redis.getCheckpointHistory(sessionId);
    
        if (history.length === 0) {
          return 'No checkpoint history available to rollback.';
        }
    
        if (steps > history.length) {
          return `Only ${history.length} checkpoints available. Cannot rollback ${steps} steps.`;
        }
    
        // Get the target checkpoint (index is steps because history[0] is current)
        const targetCheckpoint = history[steps];
    
        // Restore the state
        await this.redis.updateStateWithLock(sessionId, async () => {
          return targetCheckpoint.state;
        });
    
        logger.info('Rollback completed', {
          targetVersion: targetCheckpoint.version,
          targetTimestamp: targetCheckpoint.timestamp,
        });
    
        return `Rolled back to version ${targetCheckpoint.version} (${new Date(
          targetCheckpoint.timestamp
        ).toLocaleString()})`;
      } catch (error) {
        logger.error('Rollback failed', { error, sessionId });
        throw new Error(`Rollback failed: ${error}`);
      }
    }
  • Zod schema for validating the rollback tool input (number of steps to rollback).
    export const RollbackInputSchema = z.object({
      steps: z.number().int().positive().default(1),
    });
    
    export type CheckpointInput = z.infer<typeof CheckpointInputSchema>;
  • src/index.ts:86-99 (registration)
    Tool registration in the listTools handler, defining name, description, and input schema for MCP discovery.
      name: 'rollback',
      description:
        'Revert to a previous checkpoint version. Useful if a merge produced incorrect results.',
      inputSchema: {
        type: 'object',
        properties: {
          steps: {
            type: 'number',
            description: 'Number of versions to roll back (default: 1)',
            default: 1,
          },
        },
      },
    },
  • MCP tool call dispatcher case that parses input schema and delegates to ProjectBrain.rollback.
    case 'rollback': {
      const input = RollbackInputSchema.parse(args || {});
      const result = await this.brain.rollback(input.steps);
      return {
        content: [{ type: 'text', text: result }],
      };
    }
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/coderdeep11/claude-memory-mcp'

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