Skip to main content
Glama

rollback

Revert to a previous checkpoint version when a merge produces incorrect results, allowing you to undo changes by specifying how many versions to roll back.

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 implementation of the rollback tool logic: retrieves checkpoint history, validates the number of steps, restores the target checkpoint state from Redis, and returns a success message or error.
    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}`); } }
  • MCP server handler for the 'rollback' tool call: parses input using the schema and delegates execution to ProjectBrain.rollback().
    case 'rollback': { const input = RollbackInputSchema.parse(args || {}); const result = await this.brain.rollback(input.steps); return { content: [{ type: 'text', text: result }], }; }
  • src/index.ts:85-99 (registration)
    Registration of the 'rollback' tool in the MCP ListToolsRequestHandler, defining name, description, and input schema.
    { 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, }, }, }, },
  • Zod schema definition for RollbackInput and corresponding TypeScript type inference.
    export const RollbackInputSchema = z.object({ steps: z.number().int().positive().default(1), }); export type CheckpointInput = z.infer<typeof CheckpointInputSchema>; export type RollbackInput = z.infer<typeof RollbackInputSchema>;

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