undo
Reverse the most recent change in your Strudel music pattern to correct mistakes or experiment with different compositions.
Instructions
Undo last action
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The main handler logic for the 'undo' tool. It checks if initialized, pops the previous pattern from undoStack, writes it to the controller, pushes current to redoStack, and returns success or 'Nothing to undo'.case 'undo': if (!this.isInitialized) { return 'Browser not initialized. Run init first.'; } if (this.undoStack.length > 0) { const currentUndo = await this.controller.getCurrentPattern(); this.redoStack.push(currentUndo); // Enforce bounds to prevent memory leaks if (this.redoStack.length > this.MAX_HISTORY) { this.redoStack.shift(); } const previous = this.undoStack.pop()!; await this.controller.writePattern(previous); return 'Undone'; } return 'Nothing to undo';
- Schema definition for the 'undo' tool, including name, description, and empty input schema (no parameters required).name: 'undo', description: 'Undo last action', inputSchema: { type: 'object', properties: {} }
- src/server/EnhancedMCPServerFixed.ts:571-573 (registration)Registration of the tool list handler which returns all tools including 'undo' via getTools().this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: this.getTools() }));
- Declaration of undoStack and redoStack used by the undo/redo functionality.private undoStack: string[] = []; private redoStack: string[] = [];