Skip to main content
Glama
ext-sakamoro

Aseprite MCP Tools

by ext-sakamoro

get_palette_info

Retrieve palette details from an Aseprite file to analyze color information for pixel art projects.

Instructions

Get information about the current palette in an Aseprite file.

Args: filename: Name of the Aseprite file to inspect

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes

Implementation Reference

  • The get_palette_info tool handler implemented in palette.py. It uses a LuaBuilder to construct a script that queries the Aseprite API for palette information and executes it.
    @mcp.tool()
    async def get_palette_info(filename: str) -> str:
        """Get information about the current palette in an Aseprite file.
    
        Args:
            filename: Name of the Aseprite file to inspect
        """
        try:
            # Validate inputs
            file_path = validate_file_path(filename, must_exist=True)
            
            # 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()
            
            # Get palette info
            builder.add_line('local palette = spr.palettes[1]')
            builder.if_condition('not palette')
            builder.add_line('print("No palette found")')
            builder.add_line('return')
            builder.end_if()
            builder.add_line()
            
            builder.add_line('print("Palette information:")')
            builder.add_line('print("Number of colors: " .. #palette)')
            builder.add_line('print("\\nColors (index: hex):")')
            builder.for_loop('i', 0, 'math.min(#palette - 1, 255)')
            builder.add_line('local color = palette:getColor(i)')
            builder.add_line('print(string.format("%3d: #%02X%02X%02X", i, color.r, color.g, color.b))')
            builder.end_loop()
            
            # Execute script
            cmd = get_command()
            success, output = cmd.execute_lua_script(builder.build())
            
            if success and output:
                return f"Palette information for {file_path}:\n{output}"
            else:
                return f"No palette information found for {file_path}"
            
        except (ValidationError, AsepriteError) as e:
            return f"Failed to get palette info: {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