Skip to main content
Glama
ext-sakamoro

Aseprite MCP Tools

by ext-sakamoro

batch_apply_palette

Apply a color palette to multiple Aseprite files simultaneously to maintain consistent visual style across pixel art projects.

Instructions

Apply a palette to multiple Aseprite files.

Args: input_dir: Directory containing input files palette_file: Path to palette file or preset name file_pattern: File pattern to match (default: "*.aseprite") create_backup: Create backup of original files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
input_dirYes
palette_fileYes
file_patternNo*.aseprite
create_backupNo

Implementation Reference

  • Implementation of the batch_apply_palette tool which iterates over files in a directory and applies a specified palette.
    async def batch_apply_palette(
        input_dir: str,
        palette_file: str,
        file_pattern: str = "*.aseprite",
        create_backup: bool = True
    ) -> str:
        """Apply a palette to multiple Aseprite files.
    
        Args:
            input_dir: Directory containing input files
            palette_file: Path to palette file or preset name
            file_pattern: File pattern to match (default: "*.aseprite")
            create_backup: Create backup of original files
        """
        try:
            # Validate inputs
            input_path = validate_file_path(input_dir, must_exist=True)
            
            if not input_path.is_dir():
                raise ValidationError("input_dir", str(input_path), "Must be a directory")
            
            # Check if palette_file is a preset or file
            from .palette import PRESET_PALETTES
            is_preset = palette_file.lower() in PRESET_PALETTES
            
            if not is_preset:
                palette_path = validate_file_path(palette_file, must_exist=True)
            
            # 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}"
            
            # Process each file
            results = []
            errors = []
            
            for file in files:
                try:
                    # Create backup if requested
                    if create_backup:
                        backup_file = file.with_suffix(file.suffix + ".bak")
                        import shutil
                        shutil.copy2(file, backup_file)
                    
                    # Apply palette
                    if is_preset:
                        from .palette import apply_preset_palette
                        result = await apply_preset_palette(str(file), palette_file)
                    else:
                        # Extract palette from file and apply
                        builder = LuaBuilder()
                        builder.open_sprite(str(palette_path))
                        builder.add_line('local paletteSpr = app.activeSprite')
                        builder.add_line('local sourcePalette = paletteSpr.palettes[1]')
                        
                        builder.open_sprite(str(file))
                        builder.add_line('local targetSpr = app.activeSprite')
                        builder.add_line('targetSpr:setPalette(sourcePalette)')
                        builder.save_sprite()
                        
                        cmd = get_command()
                        success, output = cmd.execute_lua_script(builder.build())
                        result = f"Applied palette to {file.name}"
                    
                    results.append(result)
                    
                except Exception as e:
                    errors.append(f"Failed {file.name}: {e}")
                    if not get_config().batch.continue_on_error:
                        break
            
            # Summary
            summary = f"Batch apply palette completed:\n"
            summary += f"- Processed: {len(results)} files\n"
            summary += f"- Failed: {len(errors)} files\n"
            
            if create_backup:
                summary += "- Backups created with .bak extension\n"
            
            if results:
                summary += "\nSuccessful:\n" + "\n".join(results[:10])
                if len(results) > 10:
                    summary += f"\n... and {len(results) - 10} more"
            
            if errors:
                summary += "\n\nErrors:\n" + "\n".join(errors[:5])
                if len(errors) > 5:
                    summary += f"\n... and {len(errors) - 5} more"
            
            return summary
            
        except (ValidationError, AsepriteError) as e:
            return f"Failed to batch apply palette: {e}"
        except Exception as e:
            return f"Unexpected error: {e}"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool modifies files and has a backup option, but doesn't clarify important aspects like whether changes are destructive, what happens on errors, or if there are rate limits. The description is insufficient for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with a clear purpose statement followed by parameter explanations. Each sentence adds value, though the parameter section could be more integrated with the main description rather than appearing as a separate block.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a batch mutation tool with 4 parameters, 0% schema coverage, no annotations, and no output schema, the description is inadequate. It doesn't explain the return value, error handling, or important behavioral constraints needed for safe operation. The tool modifies multiple files but lacks sufficient context for reliable use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It provides basic explanations for all 4 parameters, clarifying what each expects (e.g., 'palette_file' can be a path or preset name). However, it lacks details on format requirements, constraints, or examples that would fully compensate for the schema gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Apply a palette') and target resources ('multiple Aseprite files'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'apply_preset_palette' or 'remap_colors', which might have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'apply_preset_palette' or 'batch_process_custom'. It mentions basic parameters but doesn't explain prerequisites, appropriate contexts, or exclusions for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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