Labsco
ext-sakamoro logo

Aseprite MCP

โ˜… 22

from ext-sakamoro

A server for programmatic interaction with Aseprite, enabling batch processing and automation for sprite creation and management.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeQuick setup

Aseprite MCP Tools v2.0

ๆ—ฅๆœฌ่ชž็‰ˆใฏใ“ใกใ‚‰ | macOS Setup Guide

A powerful Python MCP (Model Context Protocol) server for programmatic interaction with Aseprite, featuring enhanced error handling, configuration management, batch processing, and more!

๐Ÿš€ What's New in v2.0

  • ๐Ÿ›ก๏ธ Comprehensive Error Handling: Custom exceptions with detailed, actionable error messages
  • ๐Ÿ”ง Configuration Management: Pydantic-based settings with JSON/YAML support
  • ๐Ÿ“ Advanced Logging: Structured logging with performance metrics
  • ๐ŸŽจ Palette Management: Create, apply, and extract color palettes
  • โšก Batch Processing: Process multiple files in parallel
  • ๐Ÿ—๏ธ Lua Script Builder: Clean, type-safe Lua script generation
  • ๐Ÿ”’ Enhanced Security: Input validation and path traversal protection
  • ๐Ÿงช Full Test Coverage: Comprehensive unit tests

๐Ÿ“‹ Features

Core Drawing Tools

  • Canvas Operations: Create sprites, add layers and frames
  • Drawing Tools: Pixels, lines, rectangles, circles, and fill operations
  • Export Tools: Export to various formats with scaling and layer support

New Palette Tools (v2.0)

  • Preset Palettes: GameBoy, NES, PICO-8, CGA, Monochrome, Sepia
  • Custom Palettes: Create and apply custom color schemes
  • Palette Extraction: Extract colors from existing images
  • Color Remapping: Replace colors throughout sprites

Batch Processing (v2.0)

  • Batch Resize: Resize multiple sprites maintaining aspect ratio
  • Batch Export: Convert multiple files to different formats
  • Batch Palette Apply: Apply palettes to multiple files
  • Custom Scripts: Run Lua scripts on file sets

๐Ÿ—๏ธ Architecture

Project Structure

aseprite-mcp/
โ”œโ”€โ”€ aseprite_mcp/
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”œโ”€โ”€ commands.py      # Aseprite command execution
โ”‚   โ”‚   โ”œโ”€โ”€ config.py        # Configuration management
โ”‚   โ”‚   โ”œโ”€โ”€ exceptions.py    # Custom exceptions
โ”‚   โ”‚   โ”œโ”€โ”€ logging.py       # Logging system
โ”‚   โ”‚   โ”œโ”€โ”€ lua_builder.py   # Lua script builder
โ”‚   โ”‚   โ””โ”€โ”€ validation.py    # Input validation
โ”‚   โ””โ”€โ”€ tools/
โ”‚       โ”œโ”€โ”€ batch.py         # Batch processing
โ”‚       โ”œโ”€โ”€ canvas.py        # Canvas operations
โ”‚       โ”œโ”€โ”€ drawing.py       # Drawing tools
โ”‚       โ”œโ”€โ”€ export.py        # Export functions
โ”‚       โ””โ”€โ”€ palette.py       # Palette management
โ”œโ”€โ”€ tests/                   # Unit tests
โ”œโ”€โ”€ examples/                # Example scripts
โ””โ”€โ”€ config.example.yaml      # Configuration example

Error Handling

try:
    result = await create_canvas(-100, 200, "test.aseprite")
except ValidationError as e:
    print(f"Validation failed: {e}")
except AsepriteError as e:
    print(f"Aseprite error: {e}")

Lua Script Builder

from aseprite_mcp.core.lua_builder import LuaBuilder

builder = LuaBuilder()
builder.create_sprite(200, 200)
builder.begin_transaction()
builder.set_color("FF0000")
builder.for_loop("i", 0, 10)
    builder.draw_pixel("i * 10", "i * 10")
builder.end_loop()
builder.end_transaction()
builder.save_sprite("output.aseprite")

script = builder.build()  # Returns clean Lua code

๐Ÿงช Testing

Run all tests:

pytest tests/ -v

Run specific test:

pytest tests/test_validation.py -v

Run demo script:

python examples/demo_improvements.py

๐Ÿ“ Logging

Logs include:

  • Operation tracking
  • Performance metrics
  • Error details with context
  • Structured JSON output (optional)

Example log:

2024-06-11 10:30:45 - aseprite_mcp - INFO - Operation: create_canvas
2024-06-11 10:30:45 - aseprite_mcp - INFO - Canvas created successfully
2024-06-11 10:30:45 - aseprite_mcp - INFO - Performance: create_canvas took 0.234s

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Follow the coding standards:
    • Use type hints
    • Add input validation
    • Include error handling
    • Write unit tests
    • Update documentation
  4. Submit a pull request

๐Ÿ“„ License

MIT License - see LICENSE file for details

๐Ÿ™ Credits

  • Original implementation: Divyansh Singh
  • v2.0 improvements: Enhanced error handling, configuration, batch processing, and more

๐Ÿ“š Additional Resources