Skip to main content
Glama
ext-sakamoro

Aseprite MCP Tools

by ext-sakamoro

batch_export

Export multiple Aseprite files to different formats like PNG, GIF, or JPG in a single operation, converting pixel art projects for sharing or further use.

Instructions

Batch export multiple Aseprite files to another format.

Args: input_dir: Directory containing input files output_dir: Directory for exported files format: Export format (png, gif, jpg, etc.) scale: Export scale factor file_pattern: File pattern to match (default: "*.aseprite")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
input_dirYes
output_dirYes
formatNopng
scaleNo
file_patternNo*.aseprite

Implementation Reference

  • The batch_export tool implementation and its handler logic.
    @mcp.tool()
    async def batch_export(
        input_dir: str,
        output_dir: str,
        format: str = "png",
        scale: float = 1.0,
        file_pattern: str = "*.aseprite"
    ) -> str:
        """Batch export multiple Aseprite files to another format.
    
        Args:
            input_dir: Directory containing input files
            output_dir: Directory for exported files
            format: Export format (png, gif, jpg, etc.)
            scale: Export scale factor
            file_pattern: File pattern to match (default: "*.aseprite")
        """
        try:
            # Validate inputs
            input_path = validate_file_path(input_dir, must_exist=True)
            output_path = validate_file_path(output_dir, must_exist=True)
            format = validate_export_format(format)
            
            if not input_path.is_dir():
                raise ValidationError("input_dir", str(input_path), "Must be a directory")
            if not output_path.is_dir():
                raise ValidationError("output_dir", str(output_path), "Must be a directory")
            
            # Find all matching files
            files = list(input_path.glob(file_pattern))
            if not files:
                return f"No files matching '{file_pattern}' found in {input_path}"
            
            # Batch process each file
            processor = BatchProcessor()
            
            async def progress_callback(completed, total, current_file):
                print(f"Progress: {completed}/{total} - Processing {current_file}")
            
            # Define export operation
            def export_file(file_path: str, output_format: str, export_scale: float) -> str:
                output_file = Path(output_path) / Path(file_path).with_suffix(f".{output_format}").name
                
                cmd = get_command()
                args = ["--batch", file_path]
                
                if export_scale != 1.0:
                    args.extend(["--scale", str(export_scale)])
                
                args.extend(["--save-as", str(output_file)])
                
                success, output = cmd.run_command(args)
                return f"Exported to {output_file}"
            
            # Process files
            results = await processor.process_files(
                [str(f) for f in files],
                export_file,
                {"output_format": format, "export_scale": scale},
                progress_callback
            )
            
            # Summary
            summary = f"Batch export completed:\n"
            summary += f"- Total files: {results['total']}\n"
            summary += f"- Exported: {results['completed']}\n"
            summary += f"- Failed: {results['failed']}\n"
            summary += f"- Output directory: {output_path}"
            
            if results['errors']:
                summary += f"\n\nErrors:\n"
                for error in results['errors'][:5]:
                    summary += f"- {error['file']}: {error['error']}\n"
                if len(results['errors']) > 5:
                    summary += f"... and {len(results['errors']) - 5} more errors"
            
            return summary
            
        except (ValidationError, AsepriteError) as e:
            return f"Failed to batch export: {e}"
        except Exception as e:
            return f"Unexpected error: {e}"

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/ext-sakamoro/AsepriteMCP'

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