Skip to main content
Glama
ext-sakamoro

Aseprite MCP Tools

by ext-sakamoro

add_frame

Add a new frame to an Aseprite file at a specified position to extend animation sequences or insert intermediate frames for pixel art workflows.

Instructions

Add a new frame to the Aseprite file.

Args: filename: Name of the Aseprite file to modify after_frame: Frame index after which to add the new frame (0-based, optional)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes
after_frameNo

Implementation Reference

  • The 'add_frame' tool handler that validates input, builds the script using 'LuaBuilder', and executes it.
    @mcp.tool()
    async def add_frame(filename: str, after_frame: Optional[int] = None) -> str:
        """Add a new frame to the Aseprite file.
    
        Args:
            filename: Name of the Aseprite file to modify
            after_frame: Frame index after which to add the new frame (0-based, optional)
        """
        try:
            # Validate inputs
            file_path = validate_file_path(filename, must_exist=True)
            
            # Build Lua script
            builder = LuaBuilder()
            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()
            builder.begin_transaction()
            builder.add_frame(after_frame)
            builder.end_transaction()
            builder.save_sprite()
            
            # Execute script
            cmd = get_command()
            success, output = cmd.execute_lua_script(builder.build(), str(file_path))
            
            return f"New frame added successfully to {file_path}"
            
        except (ValidationError, AsepriteError) as e:
            return f"Failed to add frame: {e}"
        except Exception as e:
            return f"Unexpected error: {e}"
  • The helper method in 'LuaBuilder' that generates the actual Lua code for adding a frame to an Aseprite sprite.
    def add_frame(self, after_frame: Optional[int] = None) -> 'LuaBuilder':
        """Add a new frame to the sprite."""
        if after_frame is not None:
            self.add_line(f'app.activeSprite:newFrame({after_frame + 1})')  # Lua is 1-indexed
        else:
            self.add_line('app.activeSprite:newFrame()')
        return self

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