Skip to main content
Glama

redo

Reverse an undo action in the CSV Editor MCP server to restore a previously performed operation, ensuring uninterrupted data manipulation and analysis workflows.

Instructions

Redo a previously undone operation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYes

Implementation Reference

  • Registration of the MCP tool named 'redo' using the @mcp.tool decorator. This is the entry point for the tool call.
    @mcp.tool async def redo( session_id: str, ctx: Context = None ) -> Dict[str, Any]: """Redo a previously undone operation.""" return await _redo_operation(session_id, ctx)
  • Main handler function for the redo tool. Retrieves the session, calls session.redo(), handles errors and logging, returns formatted result.
    async def redo_operation( session_id: str, ctx: Context = None ) -> Dict[str, Any]: """ Redo a previously undone operation. Args: session_id: Session identifier ctx: FastMCP context Returns: Dict with success status and redo result """ try: manager = get_session_manager() session = manager.get_session(session_id) if not session: return OperationResult( success=False, message="Session not found", error=f"No session with ID: {session_id}" ).model_dump() if ctx: await ctx.info(f"Redoing operation for session {session_id}") result = await session.redo() if result["success"]: if ctx: await ctx.info(f"Successfully redid operation: {result.get('message')}") return OperationResult( success=True, message=result["message"], session_id=session_id, data=result ).model_dump() else: return OperationResult( success=False, message="Failed to redo operation", error=result.get("error") ).model_dump() except Exception as e: logger.error(f"Error redoing operation: {str(e)}") if ctx: await ctx.error(f"Failed to redo operation: {str(e)}") return OperationResult( success=False, message="Failed to redo operation", error=str(e) ).model_dump()
  • CSVSession.redo() method: performs the redo by calling history_manager.redo(), restores dataframe snapshot, triggers auto-save if needed.
    async def redo(self) -> Dict[str, Any]: """Redo the previously undone operation.""" if not self.history_manager: return {"success": False, "error": "History is not enabled"} if not self.history_manager.can_redo(): return {"success": False, "error": "No operations to redo"} try: operation, data_snapshot = self.history_manager.redo() if data_snapshot is not None: self.df = data_snapshot # Trigger auto-save if configured if self.auto_save_manager.should_save_after_operation(): await self.auto_save_manager.trigger_save(self._save_callback, "redo") return { "success": True, "message": f"Redid operation: {operation.operation_type}", "operation": operation.to_dict(), "can_undo": self.history_manager.can_undo(), "can_redo": self.history_manager.can_redo() } else: return { "success": False, "error": "No snapshot available for redo" } except Exception as e: logger.error(f"Error during redo: {str(e)}") return {"success": False, "error": str(e)}
  • Core HistoryManager.redo() implementation: pops operation from redo_stack, advances current_index, returns operation and snapshot for restoration.
    def redo(self) -> Tuple[Optional[OperationHistory], Optional[pd.DataFrame]]: """Redo the previously undone operation.""" if not self.can_redo(): return None, None # Get operation from redo stack operation = self.redo_stack.pop() # Move index forward self.current_index += 1 # Get the snapshot at this position if available snapshot = None if self.current_index < len(self.history): snapshot = self.history[self.current_index].data_snapshot if snapshot is not None: snapshot = snapshot.copy() # Save state if self.storage_type != HistoryStorage.MEMORY: self._save_history() logger.info(f"Redid operation: {operation.operation_type}") return operation, snapshot

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/santoshray02/csv-editor'

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