Skip to main content
Glama
ext-sakamoro

Aseprite MCP Tools

by ext-sakamoro

export_layers

Export individual layers from Aseprite sprites as separate image files for editing, sharing, or integration into other projects.

Instructions

Export each layer of the sprite as a separate file.

Args: filename: Name of the Aseprite file to export output_dir: Directory to save the exported layers format: Output format (default: "png") scale: Export scale factor (default: 1.0)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes
output_dirYes
formatNopng
scaleNo

Implementation Reference

  • The export_layers function is defined here, which validates inputs, builds a Lua script to export individual layers of an Aseprite file, and executes the script using the LuaBuilder utility.
    async def export_layers(
        filename: str,
        output_dir: str,
        format: str = "png",
        scale: float = 1.0
    ) -> str:
        """Export each layer of the sprite as a separate file.
    
        Args:
            filename: Name of the Aseprite file to export
            output_dir: Directory to save the exported layers
            format: Output format (default: "png")
            scale: Export scale factor (default: 1.0)
        """
        try:
            # Validate inputs
            file_path = validate_file_path(filename, must_exist=True)
            output_path = validate_file_path(output_dir, must_exist=True)
            format = validate_export_format(format)
            
            if not output_path.is_dir():
                raise ValidationError("output_dir", str(output_path), "Must be a directory")
            
            if scale <= 0:
                raise ValidationError("scale", scale, "Scale must be positive")
            
            # Build Lua script to export each layer
            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()
            
            builder.add_line('local basename = app.fs.fileTitle(spr.filename)')
            builder.for_loop('i', 1, '#spr.layers')
            builder.add_line('local layer = spr.layers[i]')
            builder.add_comment('Hide all layers except current')
            builder.for_loop('j', 1, '#spr.layers')
            builder.add_line('spr.layers[j].isVisible = (i == j)')
            builder.end_loop()
            builder.add_line()
            
            # Export current layer
            output_template = str(output_path / f"{{basename}}_{{layer}}.{format}")
            builder.add_line(f'local outputFile = "{output_template}"')
            builder.add_line('outputFile = outputFile:gsub("{basename}", basename)')
            builder.add_line('outputFile = outputFile:gsub("{layer}", layer.name)')
            
            if scale != 1.0:
                builder.export_sprite('outputFile', scale)
            else:
                builder.add_line('spr:saveCopyAs(outputFile)')
            
            builder.end_loop()
            
            # Restore all layers visibility
            builder.for_loop('i', 1, '#spr.layers')
            builder.add_line('spr.layers[i].isVisible = true')
            builder.end_loop()
            
            # Execute script
            cmd = get_command()
            success, output = cmd.execute_lua_script(builder.build())
            
            return f"Layers exported successfully to {output_path}"
            
        except (ValidationError, AsepriteError) as e:
            return f"Failed to export layers: {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 the action ('Export') but fails to describe permissions needed, whether files are overwritten, error handling, or output behavior (e.g., file naming conventions). This is inadequate for a tool that modifies the filesystem.

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

Conciseness5/5

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

The description is front-loaded with the core purpose in the first sentence, followed by a structured Args section. Every sentence adds value—no fluff or repetition. It's appropriately sized for a tool with four parameters.

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

Completeness3/5

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

Given no annotations, no output schema, and 0% schema description coverage, the description is moderately complete. It covers parameters well but lacks behavioral context (e.g., side effects, errors) and output details. For a filesystem-modifying tool, this leaves gaps in understanding the full operation.

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

Parameters4/5

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

Schema description coverage is 0%, but the description compensates by explaining all four parameters in the Args section, adding meaning beyond the schema's titles. It clarifies 'filename' as the Aseprite file, 'output_dir' as the save location, and provides defaults for 'format' and 'scale'. However, it lacks details on parameter constraints (e.g., valid formats).

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

Purpose5/5

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

The description clearly states the specific action ('Export each layer of the sprite as a separate file') with the resource ('Aseprite file'), distinguishing it from sibling tools like 'export_sprite' (which likely exports the entire sprite) and 'batch_export' (which may handle multiple files). It uses precise verbs and specifies the scope of the operation.

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 'export_sprite' or 'batch_export'. It lacks context about prerequisites (e.g., file must exist), exclusions, or comparisons to sibling tools, leaving the agent to infer usage scenarios.

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