Skip to main content
Glama

configure_auto_save

Enable and customize auto-save settings for CSV Editor sessions, allowing backup strategies, intervals, directory paths, and file formats to ensure data security and recovery.

Instructions

Configure auto-save settings for a session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
backup_dirNo
custom_pathNo
enabledNo
encodingNoutf-8
formatNocsv
interval_secondsNo
max_backupsNo
modeNoafter_operation
session_idYes
strategyNobackup

Implementation Reference

  • Core handler function that implements the logic for configuring auto-save settings in a CSV session. It retrieves the session, builds the configuration dict, applies it via session.enable_auto_save(), and returns OperationResult.
    async def configure_auto_save( session_id: str, enabled: bool = True, mode: str = "after_operation", strategy: str = "backup", interval_seconds: Optional[int] = None, max_backups: Optional[int] = None, backup_dir: Optional[str] = None, custom_path: Optional[str] = None, format: str = "csv", encoding: str = "utf-8", ctx: Context = None ) -> Dict[str, Any]: """ Configure auto-save settings for a session. Args: session_id: Session identifier enabled: Whether auto-save is enabled mode: Auto-save mode ('disabled', 'after_operation', 'periodic', 'hybrid') strategy: Save strategy ('overwrite', 'backup', 'versioned', 'custom') interval_seconds: Interval for periodic saves (default 300) max_backups: Maximum number of backup files to keep (default 10) backup_dir: Directory for backup files custom_path: Custom path for saves (when strategy='custom') format: Export format ('csv', 'tsv', 'json', 'excel', 'parquet') encoding: File encoding (default 'utf-8') ctx: FastMCP context Returns: Dict with success status and configuration """ 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"Configuring auto-save for session {session_id}") # Build configuration config = { "enabled": enabled, "mode": mode, "strategy": strategy, "format": format, "encoding": encoding } if interval_seconds is not None: config["interval_seconds"] = interval_seconds if max_backups is not None: config["max_backups"] = max_backups if backup_dir is not None: config["backup_dir"] = backup_dir if custom_path is not None: config["custom_path"] = custom_path # Apply configuration result = await session.enable_auto_save(config) if result["success"]: if ctx: await ctx.info(f"Auto-save configured: {mode} mode, {strategy} strategy") return OperationResult( success=True, message=f"Auto-save configured successfully", session_id=session_id, data=result["config"] ).model_dump() else: return OperationResult( success=False, message="Failed to configure auto-save", error=result.get("error") ).model_dump() except Exception as e: logger.error(f"Error configuring auto-save: {str(e)}") if ctx: await ctx.error(f"Failed to configure auto-save: {str(e)}") return OperationResult( success=False, message="Failed to configure auto-save", error=str(e) ).model_dump()
  • MCP tool registration using @mcp.tool decorator. This wrapper function defines the tool interface and schema through type annotations and delegates to the core handler.
    @mcp.tool async def configure_auto_save( session_id: str, enabled: bool = True, mode: str = "after_operation", strategy: str = "backup", interval_seconds: Optional[int] = None, max_backups: Optional[int] = None, backup_dir: Optional[str] = None, custom_path: Optional[str] = None, format: str = "csv", encoding: str = "utf-8", ctx: Context = None ) -> Dict[str, Any]: """Configure auto-save settings for a session.""" return await _configure_auto_save( session_id, enabled, mode, strategy, interval_seconds, max_backups, backup_dir, custom_path, format, encoding, ctx )
  • Enum type definitions for 'mode' and 'strategy' parameters, providing schema validation for allowed values in the tool inputs.
    class AutoSaveMode(str, Enum): """Auto-save trigger modes.""" DISABLED = "disabled" AFTER_OPERATION = "after_operation" # Save after each operation PERIODIC = "periodic" # Save at regular intervals HYBRID = "hybrid" # Both after operation and periodic class AutoSaveStrategy(str, Enum): """Auto-save file strategies.""" OVERWRITE = "overwrite" # Overwrite original file BACKUP = "backup" # Create backup files with timestamp VERSIONED = "versioned" # Keep numbered versions CUSTOM = "custom" # Save to custom path

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