aseprite-mcp 0.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. aseprite_mcp-0.4.1/.env.example +20 -0
  2. aseprite_mcp-0.4.1/.gitignore +26 -0
  3. aseprite_mcp-0.4.1/.python-version +1 -0
  4. aseprite_mcp-0.4.1/LICENSE +21 -0
  5. aseprite_mcp-0.4.1/PKG-INFO +180 -0
  6. aseprite_mcp-0.4.1/README.en.md +163 -0
  7. aseprite_mcp-0.4.1/README.md +163 -0
  8. aseprite_mcp-0.4.1/aseprite_mcp/__init__.py +8 -0
  9. aseprite_mcp-0.4.1/aseprite_mcp/__main__.py +20 -0
  10. aseprite_mcp-0.4.1/aseprite_mcp/backends/__init__.py +1 -0
  11. aseprite_mcp-0.4.1/aseprite_mcp/backends/cli.lua +119 -0
  12. aseprite_mcp-0.4.1/aseprite_mcp/backends/cli.py +95 -0
  13. aseprite_mcp-0.4.1/aseprite_mcp/backends/live.py +131 -0
  14. aseprite_mcp-0.4.1/aseprite_mcp/core/__init__.py +1 -0
  15. aseprite_mcp-0.4.1/aseprite_mcp/core/colors.py +26 -0
  16. aseprite_mcp-0.4.1/aseprite_mcp/core/commands.py +114 -0
  17. aseprite_mcp-0.4.1/aseprite_mcp/core/config.py +36 -0
  18. aseprite_mcp-0.4.1/aseprite_mcp/core/execution.py +153 -0
  19. aseprite_mcp-0.4.1/aseprite_mcp/core/files.py +39 -0
  20. aseprite_mcp-0.4.1/aseprite_mcp/core/fonts.py +449 -0
  21. aseprite_mcp-0.4.1/aseprite_mcp/core/legacy.py +35 -0
  22. aseprite_mcp-0.4.1/aseprite_mcp/core/lua.py +132 -0
  23. aseprite_mcp-0.4.1/aseprite_mcp/core/native.py +55 -0
  24. aseprite_mcp-0.4.1/aseprite_mcp/core/protocol.py +365 -0
  25. aseprite_mcp-0.4.1/aseprite_mcp/server.py +178 -0
  26. aseprite_mcp-0.4.1/aseprite_mcp/tools/__init__.py +20 -0
  27. aseprite_mcp-0.4.1/aseprite_mcp/tools/analysis.py +309 -0
  28. aseprite_mcp-0.4.1/aseprite_mcp/tools/animation.py +1434 -0
  29. aseprite_mcp-0.4.1/aseprite_mcp/tools/canvas.py +272 -0
  30. aseprite_mcp-0.4.1/aseprite_mcp/tools/drawing.py +1121 -0
  31. aseprite_mcp-0.4.1/aseprite_mcp/tools/export.py +394 -0
  32. aseprite_mcp-0.4.1/aseprite_mcp/tools/fx.py +462 -0
  33. aseprite_mcp-0.4.1/aseprite_mcp/tools/guide.py +40 -0
  34. aseprite_mcp-0.4.1/aseprite_mcp/tools/layers.py +310 -0
  35. aseprite_mcp-0.4.1/aseprite_mcp/tools/native_fx.py +274 -0
  36. aseprite_mcp-0.4.1/aseprite_mcp/tools/palette.py +455 -0
  37. aseprite_mcp-0.4.1/aseprite_mcp/tools/pixel_read.py +299 -0
  38. aseprite_mcp-0.4.1/aseprite_mcp/tools/preview.py +82 -0
  39. aseprite_mcp-0.4.1/aseprite_mcp/tools/quality.py +861 -0
  40. aseprite_mcp-0.4.1/aseprite_mcp/tools/scene.py +118 -0
  41. aseprite_mcp-0.4.1/aseprite_mcp/tools/script.py +39 -0
  42. aseprite_mcp-0.4.1/aseprite_mcp/tools/selection.py +348 -0
  43. aseprite_mcp-0.4.1/aseprite_mcp/tools/slices.py +228 -0
  44. aseprite_mcp-0.4.1/aseprite_mcp/tools/text.py +294 -0
  45. aseprite_mcp-0.4.1/aseprite_mcp/tools/tilemap.py +372 -0
  46. aseprite_mcp-0.4.1/aseprite_mcp/tools/transform.py +241 -0
  47. aseprite_mcp-0.4.1/extension/NOTICE.md +7 -0
  48. aseprite_mcp-0.4.1/extension/animation.lua +116 -0
  49. aseprite_mcp-0.4.1/extension/bridge.lua +197 -0
  50. aseprite_mcp-0.4.1/extension/editor.lua +316 -0
  51. aseprite_mcp-0.4.1/extension/main.lua +17 -0
  52. aseprite_mcp-0.4.1/extension/package.json +11 -0
  53. aseprite_mcp-0.4.1/extension/preview.lua +78 -0
  54. aseprite_mcp-0.4.1/pyproject.toml +50 -0
  55. aseprite_mcp-0.4.1/scripts/build_release.py +124 -0
  56. aseprite_mcp-0.4.1/uv.lock +926 -0
@@ -0,0 +1,20 @@
1
+ # 使用者自行安装的 Aseprite;环境变量优先于 .env。
2
+ ASEPRITE_PATH=C:/path/to/Aseprite.exe
3
+ # core(默认):9 个实时核心入口,无连接时返回明确错误。
4
+ # cli:115 个上游兼容工具 + cli_execute;all:二者合并。
5
+ ASEPRITE_MCP_TOOL_PROFILE=core
6
+ # 可选基础动画能力集;留空保持默认9项,animation增加apply_animation。
7
+ ASEPRITE_MCP_CAPABILITY_SETS=
8
+ # 原始 Lua 仅在显式启用 CLI 时额外开放。
9
+ ASEPRITE_MCP_ENABLE_RAW_LUA=0
10
+ # 实时监听默认固定端口;命令行 --host/--port 优先于环境变量。
11
+ ASEPRITE_MCP_HOST=127.0.0.1
12
+ ASEPRITE_MCP_PORT=8765
13
+ ASEPRITE_MCP_MAX_MESSAGE_BYTES=8388608
14
+ ASEPRITE_MCP_MAX_OPERATIONS=256
15
+ ASEPRITE_MCP_MAX_PIXELS=262144
16
+ ASEPRITE_MCP_MAX_PNG_BYTES=4194304
17
+ ASEPRITE_MCP_TIMEOUT_SECONDS=30
18
+ ASEPRITE_MCP_MAX_BATCH_SECONDS=0.25
19
+ ASEPRITE_MCP_DEDUP_ENTRIES=256
20
+ ASEPRITE_MCP_DEDUP_TTL_SECONDS=120
@@ -0,0 +1,26 @@
1
+ # Local software and personal state
2
+ /Aseprite/
3
+ /.work/
4
+ /.env
5
+ /.env.*
6
+ /.pypirc
7
+ !/.env.example
8
+ /.mcp.json
9
+ /.codex/
10
+ /.agents/
11
+ # Python, test and build outputs
12
+ /.venv/
13
+ __pycache__/
14
+ *.py[cod]
15
+ .pytest_cache/
16
+ /build/
17
+ /dist/
18
+ *.egg-info/
19
+ /coverage.xml
20
+ /.coverage
21
+ # Legacy test outputs left at the project root; keep licensed test assets trackable.
22
+ # OS and editor state
23
+ .DS_Store
24
+ Thumbs.db
25
+ .vscode/
26
+ .idea/
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Divyansh Singh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,180 @@
1
+ Metadata-Version: 2.5
2
+ Name: aseprite-mcp
3
+ Version: 0.4.1
4
+ Summary: Aseprite MCP with explicit CLI and live backend contracts
5
+ Author-email: greenlogs <tryz189853302550@gmail.com>
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.13
9
+ Requires-Dist: httpx>=0.28.1
10
+ Requires-Dist: mcp[cli]>=1.6.0
11
+ Requires-Dist: pillow>=10.0.0
12
+ Requires-Dist: pydantic<3,>=2.11
13
+ Requires-Dist: python-dotenv>=1.0.1
14
+ Requires-Dist: twine>=7.0.0
15
+ Requires-Dist: websockets<16,>=15
16
+ Description-Content-Type: text/markdown
17
+
18
+ <div align="center">
19
+
20
+ # Aseprite MCP
21
+
22
+ **让 AI 成为你的像素画创作搭档**
23
+
24
+ 通过 Model Context Protocol,在 Aseprite 中与 AI 一起绘制、修改和预览像素画。
25
+
26
+ **中文** · [English](README.en.md)
27
+
28
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
29
+ [![Python: 3.13+](https://img.shields.io/badge/Python-3.13%2B-blue.svg)](pyproject.toml)
30
+
31
+ </div>
32
+
33
+ ---
34
+
35
+ Aseprite MCP 将支持 MCP 的 AI 客户端与 Aseprite 连接起来。你可以用自然语言描述修改,让 AI 直接编辑当前文档并查看图片反馈,再接着手动创作——包括尚未保存的画布。
36
+
37
+ 基于 [diivi/aseprite-mcp](https://github.com/diivi/aseprite-mcp) 改造,新增 Lua 实时扩展,同时保留上游 CLI 文件工具。
38
+
39
+ > 当前版本为 **0.4.1 TestPyPI 测试版**。已在 Windows + Aseprite 1.3.7 / API 28 完成真实验证,[最近一次完整回归](docs/progress/P3-M2.md)为 208 项通过。macOS、Linux 和其他 Aseprite 版本尚待验证。
40
+
41
+ ## 快速开始
42
+
43
+ ### 1. 准备服务与扩展
44
+
45
+ 需要自行安装的 **Aseprite 1.3.7 / API 28**、**Python 3.13+**、[uv](https://docs.astral.sh/uv/getting-started/installation/) 和支持 stdio 的 MCP 客户端。
46
+
47
+ 获取本项目源码后,在项目根目录运行:
48
+
49
+ ```powershell
50
+ uv sync --locked --python 3.13
51
+ uv run --locked python scripts/build_release.py --out-dir dist
52
+ ```
53
+
54
+ ### 2. 安装 Aseprite 扩展
55
+
56
+ 在 **Edit → Preferences → Extensions → Add Extension** 中选择生成的 `dist/aseprite-mcp-live-0.4.1.aseprite-extension`,安装并启用,然后重启 Aseprite。
57
+
58
+ ### 3. 配置 MCP 客户端
59
+
60
+ 下面是采用 `mcpServers` 格式的客户端配置示例。将 `C:/path/to/aseprite-mcp` 替换为项目的绝对路径;其他客户端使用对应的 stdio 配置格式。
61
+
62
+ ```json
63
+ {
64
+ "mcpServers": {
65
+ "aseprite": {
66
+ "command": "uv",
67
+ "args": [
68
+ "--directory", "C:/path/to/aseprite-mcp",
69
+ "run", "--locked", "aseprite-mcp"
70
+ ],
71
+ "env": {
72
+ "ASEPRITE_MCP_TOOL_PROFILE": "core"
73
+ }
74
+ }
75
+ }
76
+ }
77
+ ```
78
+
79
+ 重启客户端,打开 Aseprite,按首次权限提示允许扩展使用本机 WebSocket。默认自动连接 `127.0.0.1:8765`,无需选择连接文件。
80
+
81
+ 试着对 AI 说:**“查看当前打开的画布,告诉我有哪些图层,并显示预览。”**
82
+
83
+ <details>
84
+ <summary><b>独立安装、端口设置与连接诊断</b></summary>
85
+
86
+ - 不依赖源码目录的 wheel 安装、`ASEPRITE_PATH` 配置和手动扩展安装见 [Windows 安装说明](docs/INSTALL.md)。
87
+ - 服务由 MCP 客户端启动;同一端口只运行一份服务。客户端找不到 `uv` 时,用 `Get-Command uv` 查询其绝对路径。
88
+ - 在 **File → Scripts → MCP: Connect / Settings** 查看连接状态或修改端口。服务参数 `--port` 必须与扩展设置一致。
89
+ - 升级时同时更新服务和扩展;详细步骤见[安装与升级](docs/INSTALL.md)。
90
+
91
+ </details>
92
+
93
+ ## 功能
94
+
95
+ | 功能 | 你可以做什么 |
96
+ |---|---|
97
+ | **实时协作** | 读取、编辑已经打开的文档,包括未保存画布,继续与 AI 交替创作 |
98
+ | **像素与图层** | 新建 RGB 画布、添加普通图层、调整不透明度、批量绘制像素和矩形 |
99
+ | **图片反馈** | 将画布预览作为 PNG 图片直接返回给支持图片内容的 MCP 客户端 |
100
+ | **撤销与重做** | 一个编辑批次对应一次撤销,可使用 Aseprite 原生历史继续调整 |
101
+ | **基础动画(可选)** | 追加或删除帧、设置帧时长、创建和管理动画标签 |
102
+ | **CLI 文件工具** | 单独启用磁盘文件处理,使用已保留的上游工具进行批处理 |
103
+ | **自动连接** | 扩展在软件启动后等待服务,服务重启后自动重新连接 |
104
+
105
+ ## 工作方式
106
+
107
+ 系统由两个组件组成:
108
+
109
+ 1. **Python MCP 服务**:与 AI 客户端通过 stdio 通信,处理工具调用并返回文字或图片。
110
+ 2. **Aseprite Lua 扩展**:通过本机 WebSocket 连接服务,读取和修改编辑器中的内存文档。
111
+
112
+ 实时编辑绑定明确的文档和修订;切换活动窗口不会把修改转移到其他画布。CLI 工具操作磁盘文件,实时连接失败会返回错误,不会自动改用 CLI。
113
+
114
+ ## 使用示例
115
+
116
+ 先在 Aseprite 中打开或新建画布,然后描述目标:
117
+
118
+ | 示例指令 | 用途 |
119
+ |---|---|
120
+ | “读取当前文档的尺寸、图层和帧信息,先给我预览。” | 了解画布 |
121
+ | “创建一个 32×32 的 RGB 画布,用像素和矩形画一把小剑。” | 从空白开始绘制 |
122
+ | “在这个文档中新建高光图层,添加几处浅色像素,完成后预览。” | 分层修改 |
123
+ | “撤销刚才那一批修改,再显示结果。” | 检查与调整 |
124
+ | “追加两帧,将前三帧设为 180 毫秒,并创建 walk 标签。” | 基础动画,需先启用 |
125
+
126
+ 编辑不会自动保存。需要落盘时,明确要求保存为 `.aseprite` 或 `.ase` 文件;覆盖已有文件需要显式设置覆盖参数。撤销和重做针对文档最新历史,也可能涉及你手动完成的编辑。
127
+
128
+ ### 启用基础动画
129
+
130
+ 在 MCP 客户端的 `env` 中增加以下配置,并重启服务:
131
+
132
+ ```json
133
+ {
134
+ "ASEPRITE_MCP_CAPABILITY_SETS": "animation"
135
+ }
136
+ ```
137
+
138
+ 配套 0.4.1 服务和扩展会额外提供 `apply_animation`。追加帧复制末帧,帧号从 1 开始;详细范围与参数见[能力清单](docs/development/CAPABILITIES.md)。
139
+
140
+ ### 工具配置
141
+
142
+ 通过客户端环境变量 `ASEPRITE_MCP_TOOL_PROFILE` 选择:
143
+
144
+ | 值 | 工具范围 |
145
+ |---|---|
146
+ | `core`(默认) | 9 个实时核心入口;启用动画后为 10 个 |
147
+ | `cli` | 116 个磁盘文件工具;通过 `ASEPRITE_PATH` 配置 Aseprite,不建立实时连接 |
148
+ | `all` | 实时与 CLI 合计 125 个;启用动画后为 126 个 |
149
+
150
+ CLI 工具的数量不代表实时功能数量。完整配置见[安装说明](docs/INSTALL.md),参数上限见 [.env.example](.env.example)。
151
+
152
+ ## 当前边界
153
+
154
+ - 实时绘制以普通可编辑 RGB 图层为范围;非 RGB、锁定层、背景层、参考层和 Tilemap 等不支持的编辑会明确拒绝。
155
+ - 调色板、特效、补间和 Tilemap 尚未迁移为实时能力。
156
+ - 较大的操作可能触发像素、复制或执行时间预算,需缩小批次;不能确定写入结果时,先重新读取状态再操作。
157
+ - 服务仅监听本机回环地址。CLI 修改文件与编辑器内存修改分开使用,避免同时写入同一磁盘文件。
158
+
159
+ ## 故障排查
160
+
161
+ | 问题 | 建议 |
162
+ |---|---|
163
+ | 扩展未连接 | 确认 MCP 服务已由客户端启动、扩展已启用,双方端口一致 |
164
+ | 端口被占用 | 结束重复服务,或同时修改服务 `--port` 与扩展端口 |
165
+ | 找不到文档或修订冲突 | 重新读取文档列表与文档信息;重连后旧会话和文档 ID 失效 |
166
+ | 没有显示预览图片 | 确认客户端支持 MCP 图片内容,并缩小预览区域或缩放倍数 |
167
+
168
+ 更多错误与恢复步骤见[故障排查](docs/TROUBLESHOOTING.md)。
169
+
170
+ ## 文档与贡献
171
+
172
+ [安装与使用](docs/INSTALL.md) · [兼容能力](docs/development/CAPABILITIES.md) · [测试说明](docs/TESTING.md) · [构建与发布](docs/RELEASING.md) · [参与贡献](CONTRIBUTING.md)
173
+
174
+ 开发维护入口:[执行计划](EXECUTION_PLAN.md)、[项目结构](docs/PROJECT_STRUCTURE.md)和[架构说明](docs/development/ARCHITECTURE.md)。详细文档目前以中文提供。
175
+
176
+ ## 致谢与许可
177
+
178
+ 感谢 [diivi/aseprite-mcp](https://github.com/diivi/aseprite-mcp) 提供的上游工具与测试基础;实际导入版本和改造记录见[第三方来源](docs/THIRD_PARTY.md)。
179
+
180
+ 本项目采用 [MIT 许可](LICENSE),保留上游版权。Aseprite 需自行准备,不随项目分发。本项目为第三方集成,与 Aseprite 官方无隶属关系。
@@ -0,0 +1,163 @@
1
+ <div align="center">
2
+
3
+ # Aseprite MCP
4
+
5
+ **Make AI your pixel art collaborator**
6
+
7
+ Draw, edit, and preview pixel art together in Aseprite through the Model Context Protocol.
8
+
9
+ [中文](README.md) · **English**
10
+
11
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
12
+ [![Python: 3.13+](https://img.shields.io/badge/Python-3.13%2B-blue.svg)](pyproject.toml)
13
+
14
+ </div>
15
+
16
+ ---
17
+
18
+ Aseprite MCP connects an MCP-compatible AI client to Aseprite. Describe a change in natural language, let AI edit your document and inspect the image preview, then continue drawing yourself—even on an unsaved canvas.
19
+
20
+ Built on [diivi/aseprite-mcp](https://github.com/diivi/aseprite-mcp), this project adds a live Lua extension while retaining the upstream CLI file tools.
21
+
22
+ > The current version is a **0.4.1 TestPyPI test release**. Real integration testing covers Windows + Aseprite 1.3.7 / API 28, with 208 tests passing in the [latest full regression run](docs/progress/P3-M2.md). macOS, Linux, and other Aseprite versions have not been validated.
23
+
24
+ ## Quickstart
25
+
26
+ ### 1. Prepare the server and extension
27
+
28
+ You need your own installation of **Aseprite 1.3.7 / API 28**, **Python 3.13+**, [uv](https://docs.astral.sh/uv/getting-started/installation/), and an MCP client that supports stdio.
29
+
30
+ After obtaining this project's source, run these commands from the repository root:
31
+
32
+ ```powershell
33
+ uv sync --locked --python 3.13
34
+ uv run --locked python scripts/build_release.py --out-dir dist
35
+ ```
36
+
37
+ ### 2. Install the Aseprite extension
38
+
39
+ In **Edit → Preferences → Extensions → Add Extension**, select the generated `dist/aseprite-mcp-live-0.4.1.aseprite-extension`. Install and enable it, then restart Aseprite.
40
+
41
+ ### 3. Configure your MCP client
42
+
43
+ This example uses the `mcpServers` configuration format. Replace `C:/path/to/aseprite-mcp` with the absolute path to your checkout. For other clients, use their equivalent stdio configuration.
44
+
45
+ ```json
46
+ {
47
+ "mcpServers": {
48
+ "aseprite": {
49
+ "command": "uv",
50
+ "args": [
51
+ "--directory", "C:/path/to/aseprite-mcp",
52
+ "run", "--locked", "aseprite-mcp"
53
+ ],
54
+ "env": {
55
+ "ASEPRITE_MCP_TOOL_PROFILE": "core"
56
+ }
57
+ }
58
+ }
59
+ }
60
+ ```
61
+
62
+ Restart your client and open Aseprite. Allow the extension's local WebSocket access when prompted. It connects automatically to `127.0.0.1:8765`; no connection file is needed.
63
+
64
+ Try asking: **“Inspect the open canvas, tell me which layers it has, and show me a preview.”**
65
+
66
+ <details>
67
+ <summary><b>Standalone installation, ports, and connection diagnostics</b></summary>
68
+
69
+ - For wheel installation without a source checkout, `ASEPRITE_PATH` configuration, and manual extension installation, see the [Windows installation guide](docs/INSTALL.md) (Chinese).
70
+ - Your MCP client starts the server. Run one server per port. If the client cannot find `uv`, use `Get-Command uv` to find its absolute path.
71
+ - Open **File → Scripts → MCP: Connect / Settings** to check the connection or change the port. The server's `--port` argument must match the extension setting.
72
+ - Upgrade the server and extension together; see the [installation and upgrade guide](docs/INSTALL.md).
73
+
74
+ </details>
75
+
76
+ ## Features
77
+
78
+ | Feature | What you can do |
79
+ |---|---|
80
+ | **Live collaboration** | Read and edit open documents, including unsaved canvases, while taking turns with AI |
81
+ | **Pixels and layers** | Create RGB canvases, add regular layers, adjust opacity, and draw pixels and rectangles in batches |
82
+ | **Visual feedback** | Return canvas previews as PNG images directly to MCP clients that support image content |
83
+ | **Undo and redo** | Undo an editing batch in one step and continue using Aseprite's native history |
84
+ | **Basic animation (optional)** | Append or delete frames, set frame durations, and create or manage animation tags |
85
+ | **CLI file tools** | Enable disk-based processing separately for batch workflows using retained upstream tools |
86
+ | **Automatic connection** | Let the extension wait for the server and reconnect after a server restart |
87
+
88
+ ## Components
89
+
90
+ The system consists of two components:
91
+
92
+ 1. **Python MCP server**: communicates with your AI client over stdio, handles tool calls, and returns text or images.
93
+ 2. **Aseprite Lua extension**: connects to the server over a local WebSocket and reads or modifies documents in the editor's memory.
94
+
95
+ Live edits target an explicit document and revision. Switching the active window does not redirect an edit to another canvas. CLI tools operate on disk files; a failed live connection returns an error rather than falling back to CLI.
96
+
97
+ ## Usage
98
+
99
+ Open or create a canvas in Aseprite, then describe your goal:
100
+
101
+ | Example prompt | Purpose |
102
+ |---|---|
103
+ | “Read this document's dimensions, layers, and frames, and show me a preview first.” | Inspect your canvas |
104
+ | “Create a 32×32 RGB canvas and draw a small sword using pixels and rectangles.” | Start from scratch |
105
+ | “Add a highlights layer to this document, place a few light pixels, and preview the result.” | Edit in layers |
106
+ | “Undo the last batch of changes and show me the result.” | Review and adjust |
107
+ | “Append two frames, set the first three frames to 180 milliseconds, and create a walk tag.” | Basic animation; enable it first |
108
+
109
+ Edits do not save automatically. Explicitly request saving to an `.aseprite` or `.ase` file when ready; replacing an existing file requires an explicit overwrite parameter. Undo and redo act on the document's latest history, which may include your manual edits.
110
+
111
+ ### Enable basic animation
112
+
113
+ Add this setting to your MCP client's `env` configuration and restart the server:
114
+
115
+ ```json
116
+ {
117
+ "ASEPRITE_MCP_CAPABILITY_SETS": "animation"
118
+ }
119
+ ```
120
+
121
+ The matching 0.4.1 server and extension expose the additional `apply_animation` tool. Appended frames copy the last frame, and frame numbers start at 1. See the [capability guide](docs/development/CAPABILITIES.md) for scope and parameters.
122
+
123
+ ### Tool profiles
124
+
125
+ Set `ASEPRITE_MCP_TOOL_PROFILE` in your client environment:
126
+
127
+ | Value | Available tools |
128
+ |---|---|
129
+ | `core` (default) | 9 live core tools, or 10 with animation enabled |
130
+ | `cli` | 116 disk-based tools; configure Aseprite with `ASEPRITE_PATH`; no live connection |
131
+ | `all` | 125 live and CLI tools combined, or 126 with animation enabled |
132
+
133
+ The CLI tool count does not describe live feature coverage. See the [installation guide](docs/INSTALL.md) for configuration and [.env.example](.env.example) for operation limits.
134
+
135
+ ## Current limitations
136
+
137
+ - Live drawing targets regular editable RGB layers. Unsupported edits involving non-RGB documents, locked layers, background layers, reference layers, or Tilemaps are explicitly rejected.
138
+ - Palettes, effects, tweening, and Tilemaps have not been migrated to live tools.
139
+ - Large operations may exceed pixel, image-copy, or execution-time budgets. Use smaller batches; if a write's outcome is unknown, read the current state before proceeding.
140
+ - The server listens only on local loopback addresses. Keep CLI file edits separate from editor-memory edits and avoid concurrent writes to the same disk file.
141
+
142
+ ## Troubleshooting
143
+
144
+ | Problem | Suggested fix |
145
+ |---|---|
146
+ | Extension is disconnected | Check that the MCP client started the server, the extension is enabled, and the ports match |
147
+ | Port is already in use | Stop the duplicate server, or change both the server's `--port` and the extension's port |
148
+ | Document is missing or revision conflicts | Read the document list and information again; old session and document IDs expire after reconnecting |
149
+ | Preview image is not displayed | Check that your client supports MCP image content, and reduce the preview region or scale |
150
+
151
+ See the [troubleshooting guide](docs/TROUBLESHOOTING.md) for error details and recovery steps.
152
+
153
+ ## Documentation and contributing
154
+
155
+ [Installation](docs/INSTALL.md) · [Capabilities](docs/development/CAPABILITIES.md) · [Testing](docs/TESTING.md) · [Building and releasing](docs/RELEASING.md) · [Contributing](CONTRIBUTING.md)
156
+
157
+ For maintenance, start with the [execution plan](EXECUTION_PLAN.md), [project structure](docs/PROJECT_STRUCTURE.md), and [architecture](docs/development/ARCHITECTURE.md). Detailed documentation is currently in Chinese.
158
+
159
+ ## Acknowledgments and license
160
+
161
+ Thanks to [diivi/aseprite-mcp](https://github.com/diivi/aseprite-mcp) for the upstream tools and tests. The imported revision and adaptation history are documented in [third-party sources](docs/THIRD_PARTY.md).
162
+
163
+ This project uses the [MIT license](LICENSE) and preserves upstream copyright. Aseprite is installed separately and is not distributed with this project. This is a third-party integration and is not affiliated with the Aseprite team.
@@ -0,0 +1,163 @@
1
+ <div align="center">
2
+
3
+ # Aseprite MCP
4
+
5
+ **让 AI 成为你的像素画创作搭档**
6
+
7
+ 通过 Model Context Protocol,在 Aseprite 中与 AI 一起绘制、修改和预览像素画。
8
+
9
+ **中文** · [English](README.en.md)
10
+
11
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
12
+ [![Python: 3.13+](https://img.shields.io/badge/Python-3.13%2B-blue.svg)](pyproject.toml)
13
+
14
+ </div>
15
+
16
+ ---
17
+
18
+ Aseprite MCP 将支持 MCP 的 AI 客户端与 Aseprite 连接起来。你可以用自然语言描述修改,让 AI 直接编辑当前文档并查看图片反馈,再接着手动创作——包括尚未保存的画布。
19
+
20
+ 基于 [diivi/aseprite-mcp](https://github.com/diivi/aseprite-mcp) 改造,新增 Lua 实时扩展,同时保留上游 CLI 文件工具。
21
+
22
+ > 当前版本为 **0.4.1 TestPyPI 测试版**。已在 Windows + Aseprite 1.3.7 / API 28 完成真实验证,[最近一次完整回归](docs/progress/P3-M2.md)为 208 项通过。macOS、Linux 和其他 Aseprite 版本尚待验证。
23
+
24
+ ## 快速开始
25
+
26
+ ### 1. 准备服务与扩展
27
+
28
+ 需要自行安装的 **Aseprite 1.3.7 / API 28**、**Python 3.13+**、[uv](https://docs.astral.sh/uv/getting-started/installation/) 和支持 stdio 的 MCP 客户端。
29
+
30
+ 获取本项目源码后,在项目根目录运行:
31
+
32
+ ```powershell
33
+ uv sync --locked --python 3.13
34
+ uv run --locked python scripts/build_release.py --out-dir dist
35
+ ```
36
+
37
+ ### 2. 安装 Aseprite 扩展
38
+
39
+ 在 **Edit → Preferences → Extensions → Add Extension** 中选择生成的 `dist/aseprite-mcp-live-0.4.1.aseprite-extension`,安装并启用,然后重启 Aseprite。
40
+
41
+ ### 3. 配置 MCP 客户端
42
+
43
+ 下面是采用 `mcpServers` 格式的客户端配置示例。将 `C:/path/to/aseprite-mcp` 替换为项目的绝对路径;其他客户端使用对应的 stdio 配置格式。
44
+
45
+ ```json
46
+ {
47
+ "mcpServers": {
48
+ "aseprite": {
49
+ "command": "uv",
50
+ "args": [
51
+ "--directory", "C:/path/to/aseprite-mcp",
52
+ "run", "--locked", "aseprite-mcp"
53
+ ],
54
+ "env": {
55
+ "ASEPRITE_MCP_TOOL_PROFILE": "core"
56
+ }
57
+ }
58
+ }
59
+ }
60
+ ```
61
+
62
+ 重启客户端,打开 Aseprite,按首次权限提示允许扩展使用本机 WebSocket。默认自动连接 `127.0.0.1:8765`,无需选择连接文件。
63
+
64
+ 试着对 AI 说:**“查看当前打开的画布,告诉我有哪些图层,并显示预览。”**
65
+
66
+ <details>
67
+ <summary><b>独立安装、端口设置与连接诊断</b></summary>
68
+
69
+ - 不依赖源码目录的 wheel 安装、`ASEPRITE_PATH` 配置和手动扩展安装见 [Windows 安装说明](docs/INSTALL.md)。
70
+ - 服务由 MCP 客户端启动;同一端口只运行一份服务。客户端找不到 `uv` 时,用 `Get-Command uv` 查询其绝对路径。
71
+ - 在 **File → Scripts → MCP: Connect / Settings** 查看连接状态或修改端口。服务参数 `--port` 必须与扩展设置一致。
72
+ - 升级时同时更新服务和扩展;详细步骤见[安装与升级](docs/INSTALL.md)。
73
+
74
+ </details>
75
+
76
+ ## 功能
77
+
78
+ | 功能 | 你可以做什么 |
79
+ |---|---|
80
+ | **实时协作** | 读取、编辑已经打开的文档,包括未保存画布,继续与 AI 交替创作 |
81
+ | **像素与图层** | 新建 RGB 画布、添加普通图层、调整不透明度、批量绘制像素和矩形 |
82
+ | **图片反馈** | 将画布预览作为 PNG 图片直接返回给支持图片内容的 MCP 客户端 |
83
+ | **撤销与重做** | 一个编辑批次对应一次撤销,可使用 Aseprite 原生历史继续调整 |
84
+ | **基础动画(可选)** | 追加或删除帧、设置帧时长、创建和管理动画标签 |
85
+ | **CLI 文件工具** | 单独启用磁盘文件处理,使用已保留的上游工具进行批处理 |
86
+ | **自动连接** | 扩展在软件启动后等待服务,服务重启后自动重新连接 |
87
+
88
+ ## 工作方式
89
+
90
+ 系统由两个组件组成:
91
+
92
+ 1. **Python MCP 服务**:与 AI 客户端通过 stdio 通信,处理工具调用并返回文字或图片。
93
+ 2. **Aseprite Lua 扩展**:通过本机 WebSocket 连接服务,读取和修改编辑器中的内存文档。
94
+
95
+ 实时编辑绑定明确的文档和修订;切换活动窗口不会把修改转移到其他画布。CLI 工具操作磁盘文件,实时连接失败会返回错误,不会自动改用 CLI。
96
+
97
+ ## 使用示例
98
+
99
+ 先在 Aseprite 中打开或新建画布,然后描述目标:
100
+
101
+ | 示例指令 | 用途 |
102
+ |---|---|
103
+ | “读取当前文档的尺寸、图层和帧信息,先给我预览。” | 了解画布 |
104
+ | “创建一个 32×32 的 RGB 画布,用像素和矩形画一把小剑。” | 从空白开始绘制 |
105
+ | “在这个文档中新建高光图层,添加几处浅色像素,完成后预览。” | 分层修改 |
106
+ | “撤销刚才那一批修改,再显示结果。” | 检查与调整 |
107
+ | “追加两帧,将前三帧设为 180 毫秒,并创建 walk 标签。” | 基础动画,需先启用 |
108
+
109
+ 编辑不会自动保存。需要落盘时,明确要求保存为 `.aseprite` 或 `.ase` 文件;覆盖已有文件需要显式设置覆盖参数。撤销和重做针对文档最新历史,也可能涉及你手动完成的编辑。
110
+
111
+ ### 启用基础动画
112
+
113
+ 在 MCP 客户端的 `env` 中增加以下配置,并重启服务:
114
+
115
+ ```json
116
+ {
117
+ "ASEPRITE_MCP_CAPABILITY_SETS": "animation"
118
+ }
119
+ ```
120
+
121
+ 配套 0.4.1 服务和扩展会额外提供 `apply_animation`。追加帧复制末帧,帧号从 1 开始;详细范围与参数见[能力清单](docs/development/CAPABILITIES.md)。
122
+
123
+ ### 工具配置
124
+
125
+ 通过客户端环境变量 `ASEPRITE_MCP_TOOL_PROFILE` 选择:
126
+
127
+ | 值 | 工具范围 |
128
+ |---|---|
129
+ | `core`(默认) | 9 个实时核心入口;启用动画后为 10 个 |
130
+ | `cli` | 116 个磁盘文件工具;通过 `ASEPRITE_PATH` 配置 Aseprite,不建立实时连接 |
131
+ | `all` | 实时与 CLI 合计 125 个;启用动画后为 126 个 |
132
+
133
+ CLI 工具的数量不代表实时功能数量。完整配置见[安装说明](docs/INSTALL.md),参数上限见 [.env.example](.env.example)。
134
+
135
+ ## 当前边界
136
+
137
+ - 实时绘制以普通可编辑 RGB 图层为范围;非 RGB、锁定层、背景层、参考层和 Tilemap 等不支持的编辑会明确拒绝。
138
+ - 调色板、特效、补间和 Tilemap 尚未迁移为实时能力。
139
+ - 较大的操作可能触发像素、复制或执行时间预算,需缩小批次;不能确定写入结果时,先重新读取状态再操作。
140
+ - 服务仅监听本机回环地址。CLI 修改文件与编辑器内存修改分开使用,避免同时写入同一磁盘文件。
141
+
142
+ ## 故障排查
143
+
144
+ | 问题 | 建议 |
145
+ |---|---|
146
+ | 扩展未连接 | 确认 MCP 服务已由客户端启动、扩展已启用,双方端口一致 |
147
+ | 端口被占用 | 结束重复服务,或同时修改服务 `--port` 与扩展端口 |
148
+ | 找不到文档或修订冲突 | 重新读取文档列表与文档信息;重连后旧会话和文档 ID 失效 |
149
+ | 没有显示预览图片 | 确认客户端支持 MCP 图片内容,并缩小预览区域或缩放倍数 |
150
+
151
+ 更多错误与恢复步骤见[故障排查](docs/TROUBLESHOOTING.md)。
152
+
153
+ ## 文档与贡献
154
+
155
+ [安装与使用](docs/INSTALL.md) · [兼容能力](docs/development/CAPABILITIES.md) · [测试说明](docs/TESTING.md) · [构建与发布](docs/RELEASING.md) · [参与贡献](CONTRIBUTING.md)
156
+
157
+ 开发维护入口:[执行计划](EXECUTION_PLAN.md)、[项目结构](docs/PROJECT_STRUCTURE.md)和[架构说明](docs/development/ARCHITECTURE.md)。详细文档目前以中文提供。
158
+
159
+ ## 致谢与许可
160
+
161
+ 感谢 [diivi/aseprite-mcp](https://github.com/diivi/aseprite-mcp) 提供的上游工具与测试基础;实际导入版本和改造记录见[第三方来源](docs/THIRD_PARTY.md)。
162
+
163
+ 本项目采用 [MIT 许可](LICENSE),保留上游版权。Aseprite 需自行准备,不随项目分发。本项目为第三方集成,与 Aseprite 官方无隶属关系。
@@ -0,0 +1,8 @@
1
+ """Aseprite MCP - Model Context Protocol implementation for Aseprite."""
2
+
3
+ from mcp.server.fastmcp import FastMCP
4
+
5
+ mcp = FastMCP("aseprite")
6
+
7
+ __version__ = "0.4.1"
8
+ __author__ = "Divyansh Singh"
@@ -0,0 +1,20 @@
1
+ import argparse
2
+
3
+ from .core.config import RuntimeConfig
4
+ from .server import create_server
5
+
6
+
7
+ def main(argv=None):
8
+ parser = argparse.ArgumentParser(description="Aseprite MCP stdio server with automatic local editor connection")
9
+ parser.add_argument("--host", help="Loopback listener (default: 127.0.0.1; overrides ASEPRITE_MCP_HOST)")
10
+ parser.add_argument("--port", type=int, help="Listener port (default: 8765; overrides ASEPRITE_MCP_PORT)")
11
+ args = parser.parse_args(argv)
12
+ try:
13
+ config = RuntimeConfig.from_env(host=args.host, port=args.port)
14
+ except ValueError as exc:
15
+ parser.error(str(exc))
16
+ create_server(config=config).run(transport="stdio")
17
+
18
+
19
+ if __name__ == "__main__":
20
+ main()
@@ -0,0 +1 @@
1
+ """Explicit backends; a live failure never falls back to disk."""