Skip to main content
Glama
ext-sakamoro

Aseprite MCP Tools

by ext-sakamoro

extract_palette_from_image

Extract color palettes from Aseprite images for pixel art projects. Specify maximum colors and optionally save the palette file.

Instructions

Extract a color palette from an existing image.

Args: filename: Name of the Aseprite file to extract palette from max_colors: Maximum number of colors to extract (default: 16) output_filename: Optional filename to save the palette

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes
max_colorsNo
output_filenameNo

Implementation Reference

  • The handler function that extracts unique colors from an Aseprite image and creates a new palette.
    async def extract_palette_from_image(
        filename: str,
        max_colors: int = 16,
        output_filename: Optional[str] = None
    ) -> str:
        """Extract a color palette from an existing image.
    
        Args:
            filename: Name of the Aseprite file to extract palette from
            max_colors: Maximum number of colors to extract (default: 16)
            output_filename: Optional filename to save the palette
        """
        try:
            # Validate inputs
            file_path = validate_file_path(filename, must_exist=True)
            
            if max_colors < 1 or max_colors > 256:
                raise ValidationError("max_colors", max_colors, "Max colors must be between 1 and 256")
            
            # Build Lua script
            builder = LuaBuilder()
            builder.open_sprite(str(file_path))
            builder.add_line('local spr = app.activeSprite')
            builder.if_condition('not spr')
            builder.add_line('error("No active sprite")')
            builder.end_if()
            builder.add_line()
            
            # Extract unique colors
            builder.add_line('local colorSet = {}')
            builder.add_line('local colorList = {}')
            builder.add_line()
            
            # Iterate through all pixels in all cels
            builder.for_loop('_, cel', 'ipairs(spr.cels)')
            builder.add_line('local img = cel.image')
            builder.if_condition('img')
            builder.for_loop('y', 0, 'img.height - 1')
            builder.for_loop('x', 0, 'img.width - 1')
            builder.add_line('local pixel = img:getPixel(x, y)')
            builder.add_line('local color = spr.pixelColor.rgba(pixel)')
            builder.if_condition('color.a > 0')  # Skip transparent pixels
            builder.add_line('local key = string.format("%02X%02X%02X", color.r, color.g, color.b)')
            builder.if_condition('not colorSet[key]')
            builder.add_line('colorSet[key] = true')
            builder.add_line('table.insert(colorList, color)')
            builder.if_condition(f'#colorList >= {max_colors}')
            builder.add_line('break')
            builder.end_if()
            builder.end_if()
            builder.end_if()
            builder.end_loop()
            builder.if_condition(f'#colorList >= {max_colors}')
            builder.add_line('break')
            builder.end_if()
            builder.end_loop()
            builder.end_if()
            builder.if_condition(f'#colorList >= {max_colors}')
            builder.add_line('break')
            builder.end_if()
            builder.end_loop()
            builder.add_line()
            
            # Create palette from extracted colors
            builder.add_line('local palette = Palette(#colorList)')
            builder.for_loop('i, color', 'ipairs(colorList)')
            builder.add_line('palette:setColor(i - 1, color)')
            builder.end_loop()
            
            # Apply palette to sprite
            builder.add_line('spr:setPalette(palette)')
            
            # Save if output filename specified
            if output_filename:
                output_path = validate_file_path(output_filename, must_exist=False)
                builder.save_sprite(str(output_path))
            else:
                builder.save_sprite()
            
            builder.add_line('return #colorList')
            
            # Execute script
            cmd = get_command()
            success, output = cmd.execute_lua_script(builder.build())
            
            return f"Extracted palette with up to {max_colors} colors from {file_path}"
            
        except (ValidationError, AsepriteError) as e:
            return f"Failed to extract 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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that the tool extracts a palette from an Aseprite file and optionally saves it, but lacks critical details: whether it modifies the original image, what permissions or file access are needed, error handling (e.g., if the file doesn't exist), rate limits, or the format of the extracted palette (e.g., RGB values, hex codes). This is inadequate for a mutation-like 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 appropriately sized and front-loaded: the first sentence states the core purpose, followed by a clear 'Args:' section listing parameters with brief explanations. There's no wasted text, though it could be more structured (e.g., bullet points). Every sentence adds value, making it efficient for an AI agent to parse.

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?

Given the complexity (a tool that processes image files to extract data), lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects (e.g., side effects, error cases), output details (what the extracted palette looks like), or full parameter semantics. For a 3-parameter tool with 0% schema coverage and no annotations, this minimal description is insufficient for reliable agent 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 adds some semantics: 'filename' is the Aseprite file to extract from, 'max_colors' limits the palette size with a default of 16, and 'output_filename' optionally saves the palette. However, it doesn't explain parameter constraints (e.g., valid file paths, integer ranges for max_colors, output file formats) or interactions (e.g., if output_filename is null, what happens?). This partially compensates but leaves gaps.

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 tool's purpose: 'Extract a color palette from an existing image.' It specifies the verb ('extract') and resource ('color palette'), and distinguishes it from sibling tools like 'create_palette' or 'get_palette_info'. However, it doesn't explicitly differentiate from 'apply_preset_palette' or 'batch_apply_palette', which are related but distinct operations.

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. It doesn't mention sibling tools like 'get_palette_info' (which might retrieve palette metadata) or 'create_palette' (which might generate a palette from scratch), nor does it specify prerequisites (e.g., the image must be in Aseprite format) or exclusions (e.g., not for modifying palettes). Usage is implied only by the tool name and basic description.

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