redo
Restore a previously undone change in CSV files to correct mistakes or revert decisions during data editing.
Instructions
Redo a previously undone operation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes |
Implementation Reference
- src/csv_editor/server.py:508-514 (handler)The primary handler function for the 'redo' tool, registered via @mcp.tool decorator. It receives the session_id and delegates execution to the internal _redo_operation helper function.@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)
- Helper function implementing the core redo logic. Retrieves the session, calls session.redo(), handles errors, and formats the response using OperationResult.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()