像素艺术创作工具

aseprite-mcp是一个基于MCP协议的Aseprite服务器,允许通过AI助手创建、编辑和导出像素艺术精灵、动画和精灵表。

  • by ayigityol
  • JavaScript
  • 本地部署
  • 7 星标
  • 更新于
在 GitHub 查看 ayigityol/aseprite-mcp

使用说明

阿司匹林

一 主控程序 服务器 像素精灵 --从任何AI助手创建、编辑和导出像素艺术精灵、动画和精灵表。

完全通过高级mcp工具绘制和动画,无需手动编辑像素!

特性

  • 43工具 跨越11个类别
  • 原生绘图,可通过以下方式配置画笔厚度 app.useTool()
  • 细笔划的像素完美算法(布雷森汉姆线、中点圆)
  • 跨平台——Windows、macOS、Linux
  • 安全——防止Lua注入,沙盒执行
  • 零运行时依赖性 @modelcontextprotocol/sdk

工具概览

类别 工具 示例
精灵 6 create_sprite, resize_sprite, crop_sprite
图层 4 add_layer, set_layer_properties, list_layers
框架 4 add_frame, set_frame_duration, list_frames
标签 3 create_tag, remove_tag, list_tags
绘图 7 draw_rect, draw_circle, draw_line, draw_ellipse, fill_area, outline, draw_pixels
变换 5 replace_color, flip_sprite, rotate_sprite, flatten_layers, merge_down
调色板 4 get_palette, set_palette_colors, load_palette, resize_palette
摄氏度 3 move_cel, set_cel_opacity, clear_cel
出口 3 export_sprite_sheet, export_frame, export_layers
切片 2 create_slice, remove_slice
效用 2 run_script, get_aseprite_version

📖 完整参数参考: docs/API.md文件


快速开始

需求

安装

# npm global
npm install -g aseprite-mcp

# or from source
git clone https://github.com/ayigityol/aseprite-mcp.git
cd aseprite-mcp && npm install && npm run build

配置

GitHub Copilot CLI (~/.copilot/mcp-config.json)
{
  "mcpServers": {
    "aseprite": {
      "type": "local",
      "command": "node",
      "tools": ["*"],
      "args": ["/path/to/aseprite-mcp/build/index.js"],
      "env": { "ASEPRITE_PATH": "/path/to/aseprite" }
    }
  }
}
Claude Desktop (claude_desktop_config.json)
{
  "mcpServers": {
    "aseprite": {
      "command": "node",
      "args": ["/path/to/aseprite-mcp/build/index.js"],
      "env": { "ASEPRITE_PATH": "/path/to/aseprite" }
    }
  }
}
VS Code / Cursor (.vscode/mcp.json)
{
  "servers": {
    "aseprite": {
      "command": "node",
      "args": ["/path/to/aseprite-mcp/build/index.js"],
      "env": { "ASEPRITE_PATH": "/path/to/aseprite" }
    }
  }
}
Installed globally via npm
{
  "mcpServers": {
    "aseprite": {
      "command": "aseprite-mcp"
    }
  }
}

环境变量

变量 描述
ASEPRITE_PATH Aseprite可执行文件的路径。如果未设置,则自动检测。
DEBUG 设置 "true" 用于详细的stderr日志记录。

自动检测在所有平台上搜索标准安装路径,以及系统PATH。


建筑

sequenceDiagram
    participant Client as MCP Client
    participant Server as aseprite-mcp
    participant Aseprite as Aseprite CLI

    Client->>Server: Tool call (JSON-RPC via stdio)
    Server->>Server: Generate Lua script
    Server->>Aseprite: aseprite -b --script temp.lua
    Aseprite->>Aseprite: Execute Lua (headless)
    Aseprite-->>Server: stdout: __RESULT__{"success":true, ...}
    Server->>Server: Parse JSON, cleanup temp file
    Server-->>Client: Tool result
graph LR
    A[Tool Call] --> B{Thickness > 1?}
    B -->|Yes| C[app.useTool<br/>Native Brush]
    B -->|No| D[image:drawPixel<br/>Pixel Algorithms]
    C --> E[Save & Return]
    D --> E

所有操作运行 无头的 --没有打开GUI窗口。


码头工人

# Build
docker build -t aseprite-mcp .

# Run (mount your Aseprite binary + working directory)
docker run --rm -i \
  -v /path/to/aseprite:/usr/local/bin/aseprite:ro \
  -v ./sprites:/sprites \
  aseprite-mcp

# Or use Docker Compose
docker compose up

必须将炸药装入容器中。映像仅打包MCP服务器。


发展

npm run build       # Compile TypeScript
npm run watch       # Recompile on changes
npm test            # Run 74 unit tests (vitest)
npm run test:watch  # Watch mode
npm run inspector   # MCP Inspector for interactive testing

安全

  • luaEscape() --通过逃逸防止Lua注射 \, ", \n, \r
  • luaPath() --规范化和转义文件路径
  • execFile() --参数数组,无shell插值
  • pcall() 包裹 --所有生成的Lua脚本都有错误处理程序
  • 仅限本地 --没有数据发送到外部服务

故障排除

问题 解决方案
“找不到优先级可执行文件” 设置 ASEPRITE_PATH env var到完整路径
工具返回一个优先级错误 设置 DEBUG=true 查看stderr输出
“未找到图层”/“未找到标记” 名称区分大小写--使用 list_layers 或 list_tags 首先
Sprite不会保存 确保输出目录存在

许可证

麻省理工学院