comfyui-animatool 0.1.0__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.
- comfyui_animatool-0.1.0/PKG-INFO +194 -0
- comfyui_animatool-0.1.0/README.md +168 -0
- comfyui_animatool-0.1.0/pyproject.toml +56 -0
- comfyui_animatool-0.1.0/setup.cfg +4 -0
- comfyui_animatool-0.1.0/src/animatool_mcp/__init__.py +6 -0
- comfyui_animatool-0.1.0/src/animatool_mcp/cli.py +93 -0
- comfyui_animatool-0.1.0/src/animatool_mcp/client.py +406 -0
- comfyui_animatool-0.1.0/src/animatool_mcp/config.py +174 -0
- comfyui_animatool-0.1.0/src/animatool_mcp/mcp_server.py +97 -0
- comfyui_animatool-0.1.0/src/animatool_mcp/resources/__init__.py +49 -0
- comfyui_animatool-0.1.0/src/animatool_mcp/resources/knowledge/anima_expert.md +74 -0
- comfyui_animatool-0.1.0/src/animatool_mcp/resources/knowledge/artist_list.md +25 -0
- comfyui_animatool-0.1.0/src/animatool_mcp/resources/knowledge/prompt_examples.md +58 -0
- comfyui_animatool-0.1.0/src/animatool_mcp/resources/schemas/tool_schema_universal.json +185 -0
- comfyui_animatool-0.1.0/src/animatool_mcp/resources/workflow/workflow_template.json +102 -0
- comfyui_animatool-0.1.0/src/comfyui_animatool.egg-info/PKG-INFO +194 -0
- comfyui_animatool-0.1.0/src/comfyui_animatool.egg-info/SOURCES.txt +19 -0
- comfyui_animatool-0.1.0/src/comfyui_animatool.egg-info/dependency_links.txt +1 -0
- comfyui_animatool-0.1.0/src/comfyui_animatool.egg-info/entry_points.txt +3 -0
- comfyui_animatool-0.1.0/src/comfyui_animatool.egg-info/requires.txt +7 -0
- comfyui_animatool-0.1.0/src/comfyui_animatool.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: comfyui-animatool
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Standalone MCP server + client for generating Anima-style images via a remote/local ComfyUI Server API.
|
|
5
|
+
Author: Moeblack
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Moeblack/ComfyUI-AnimaTool
|
|
8
|
+
Project-URL: Repository, https://github.com/Moeblack/ComfyUI-AnimaTool
|
|
9
|
+
Keywords: comfyui,anima,mcp,tool-use,ai-agent,cursor
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
Requires-Dist: mcp>=1.0.0
|
|
21
|
+
Requires-Dist: requests>=2.31
|
|
22
|
+
Provides-Extra: server
|
|
23
|
+
Requires-Dist: fastapi>=0.110; extra == "server"
|
|
24
|
+
Requires-Dist: uvicorn[standard]>=0.27; extra == "server"
|
|
25
|
+
Requires-Dist: pydantic>=2.6; extra == "server"
|
|
26
|
+
|
|
27
|
+
# animatool-mcp
|
|
28
|
+
|
|
29
|
+
一个**独立的 MCP Server + Python 客户端**:通过**标准 ComfyUI Server API**(`/prompt`、`/history/<id>`、`/view?...`)在本地或云端 ComfyUI 上执行 Anima 工作流,并把生成图片以 **base64** 形式返回给 Cursor/Claude 等 MCP 客户端原生显示。
|
|
30
|
+
|
|
31
|
+
> 重要:本项目不需要安装到 `ComfyUI/custom_nodes/`。但你仍然需要一台可访问的 ComfyUI Server(本机或云端),并且云端已经把模型权重放到 `models/` 下(按文件名加载)。
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 安装
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install comfyui-animatool
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Cursor 配置(MCP)
|
|
44
|
+
|
|
45
|
+
在你的项目中创建/编辑 `.cursor/mcp.json`:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"mcpServers": {
|
|
50
|
+
"animatool": {
|
|
51
|
+
"command": "animatool-mcp",
|
|
52
|
+
"env": {
|
|
53
|
+
"COMFYUI_URL": "http://127.0.0.1:8188"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
然后重启 Cursor,确保 MCP 状态为 Running。
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 云端/远程 ComfyUI(推荐做法)
|
|
65
|
+
|
|
66
|
+
### COMFYUI_URL 该填什么?
|
|
67
|
+
|
|
68
|
+
- **本机默认**:`http://127.0.0.1:8188`
|
|
69
|
+
- **带路径前缀的反代**:例如 `https://example.com/comfy/`(注意建议以 `/` 结尾,避免丢路径前缀)
|
|
70
|
+
|
|
71
|
+
### 1) 最佳实践:用隧道/VPN 让 ComfyUI 变成“内网可达”
|
|
72
|
+
|
|
73
|
+
ComfyUI 默认几乎没有鉴权能力,把它直接暴露到公网非常危险。建议使用:
|
|
74
|
+
|
|
75
|
+
- Tailscale / ZeroTier / Cloudflare Tunnel / 自建 VPN
|
|
76
|
+
- 或者反向代理 + HTTPS + 鉴权(Bearer / Basic / 自定义 Header)
|
|
77
|
+
|
|
78
|
+
### 2) 配置鉴权(可选)
|
|
79
|
+
|
|
80
|
+
本项目支持“有些云端需要、有些不需要”的混合场景。你可以在 `.cursor/mcp.json` 里通过 `env` 注入:
|
|
81
|
+
|
|
82
|
+
#### Bearer Token
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"mcpServers": {
|
|
87
|
+
"animatool": {
|
|
88
|
+
"command": "animatool-mcp",
|
|
89
|
+
"env": {
|
|
90
|
+
"COMFYUI_URL": "https://your-host.example.com:8188",
|
|
91
|
+
"ANIMATOOL_BEARER_TOKEN": "YOUR_TOKEN"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### Basic Auth
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"mcpServers": {
|
|
103
|
+
"animatool": {
|
|
104
|
+
"command": "animatool-mcp",
|
|
105
|
+
"env": {
|
|
106
|
+
"COMFYUI_URL": "https://your-host.example.com:8188",
|
|
107
|
+
"ANIMATOOL_BASIC_USER": "user",
|
|
108
|
+
"ANIMATOOL_BASIC_PASS": "pass"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### 自定义 Header(通用,推荐)
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"mcpServers": {
|
|
120
|
+
"animatool": {
|
|
121
|
+
"command": "animatool-mcp",
|
|
122
|
+
"env": {
|
|
123
|
+
"COMFYUI_URL": "https://your-host.example.com:8188",
|
|
124
|
+
"ANIMATOOL_HEADERS_JSON": "{\"X-API-Key\":\"xxx\",\"CF-Access-Client-Id\":\"...\",\"CF-Access-Client-Secret\":\"...\"}"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
> Windows/JSON 转义提示:`ANIMATOOL_HEADERS_JSON` 本身是一个 JSON 字符串,所以内部的双引号需要转义(如上所示)。
|
|
132
|
+
|
|
133
|
+
### 3) 自签名证书/SSL 校验
|
|
134
|
+
|
|
135
|
+
如果你的云端是自签名证书,可以临时关闭校验(不推荐长期使用):
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"mcpServers": {
|
|
140
|
+
"animatool": {
|
|
141
|
+
"command": "animatool-mcp",
|
|
142
|
+
"env": {
|
|
143
|
+
"COMFYUI_URL": "https://your-host.example.com:8188",
|
|
144
|
+
"ANIMATOOL_SSL_VERIFY": "false"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## CLI(可选)
|
|
154
|
+
|
|
155
|
+
用于本地自测(不依赖 MCP 客户端):
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
animatool-generate --comfyui-url http://127.0.0.1:8188 --json-file payload.json
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## 环境变量速查
|
|
164
|
+
|
|
165
|
+
| 环境变量 | 说明 | 默认值 |
|
|
166
|
+
|---|---|---|
|
|
167
|
+
| `COMFYUI_URL` | ComfyUI Server base URL | `http://127.0.0.1:8188` |
|
|
168
|
+
| `ANIMATOOL_TIMEOUT` | 请求超时秒 | `600` |
|
|
169
|
+
| `ANIMATOOL_POLL_INTERVAL` | 轮询间隔秒 | `1` |
|
|
170
|
+
| `ANIMATOOL_SSL_VERIFY` | SSL 校验 | `true` |
|
|
171
|
+
| `ANIMATOOL_BEARER_TOKEN` | Bearer Token | *(空)* |
|
|
172
|
+
| `ANIMATOOL_BASIC_USER` / `ANIMATOOL_BASIC_PASS` | Basic Auth | *(空)* |
|
|
173
|
+
| `ANIMATOOL_HEADERS_JSON` | 自定义 Header JSON | *(空)* |
|
|
174
|
+
| `ANIMATOOL_DOWNLOAD_IMAGES` | 是否保存图片到本地 | `false` |
|
|
175
|
+
| `ANIMATOOL_OUTPUT_DIR` | 本地保存目录 | `./animatool_outputs` |
|
|
176
|
+
| `COMFYUI_MODELS_DIR` | models 目录(用于本机预检查) | *(空)* |
|
|
177
|
+
| `ANIMATOOL_CHECK_MODELS` | 是否启用预检查 | `true` |
|
|
178
|
+
|
|
179
|
+
## 常见问题
|
|
180
|
+
|
|
181
|
+
### Q: 报错连接不上 /prompt?
|
|
182
|
+
|
|
183
|
+
- 检查 `COMFYUI_URL` 是否可达(云端建议先在浏览器访问 `COMFYUI_URL/system_stats`)
|
|
184
|
+
- 如果有鉴权,请确认 `/prompt`、`/history`、`/view` 都在同一套鉴权规则下
|
|
185
|
+
- 常见坑:反代只给 `/prompt` 放行了,但 `/view` 被 401/403 拦住,会导致“生成成功但取图失败”
|
|
186
|
+
|
|
187
|
+
### Q: 报错找不到模型?
|
|
188
|
+
|
|
189
|
+
本工具提交的是一个包含 `UNETLoader/CLIPLoader/VAELoader` 的工作流模板,加载的是云端磁盘上的文件名。请确认云端 `models/` 下至少存在:
|
|
190
|
+
|
|
191
|
+
- `models/diffusion_models/anima-preview.safetensors`
|
|
192
|
+
- `models/text_encoders/qwen_3_06b_base.safetensors`
|
|
193
|
+
- `models/vae/qwen_image_vae.safetensors`
|
|
194
|
+
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# animatool-mcp
|
|
2
|
+
|
|
3
|
+
一个**独立的 MCP Server + Python 客户端**:通过**标准 ComfyUI Server API**(`/prompt`、`/history/<id>`、`/view?...`)在本地或云端 ComfyUI 上执行 Anima 工作流,并把生成图片以 **base64** 形式返回给 Cursor/Claude 等 MCP 客户端原生显示。
|
|
4
|
+
|
|
5
|
+
> 重要:本项目不需要安装到 `ComfyUI/custom_nodes/`。但你仍然需要一台可访问的 ComfyUI Server(本机或云端),并且云端已经把模型权重放到 `models/` 下(按文件名加载)。
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install comfyui-animatool
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Cursor 配置(MCP)
|
|
18
|
+
|
|
19
|
+
在你的项目中创建/编辑 `.cursor/mcp.json`:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"mcpServers": {
|
|
24
|
+
"animatool": {
|
|
25
|
+
"command": "animatool-mcp",
|
|
26
|
+
"env": {
|
|
27
|
+
"COMFYUI_URL": "http://127.0.0.1:8188"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
然后重启 Cursor,确保 MCP 状态为 Running。
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 云端/远程 ComfyUI(推荐做法)
|
|
39
|
+
|
|
40
|
+
### COMFYUI_URL 该填什么?
|
|
41
|
+
|
|
42
|
+
- **本机默认**:`http://127.0.0.1:8188`
|
|
43
|
+
- **带路径前缀的反代**:例如 `https://example.com/comfy/`(注意建议以 `/` 结尾,避免丢路径前缀)
|
|
44
|
+
|
|
45
|
+
### 1) 最佳实践:用隧道/VPN 让 ComfyUI 变成“内网可达”
|
|
46
|
+
|
|
47
|
+
ComfyUI 默认几乎没有鉴权能力,把它直接暴露到公网非常危险。建议使用:
|
|
48
|
+
|
|
49
|
+
- Tailscale / ZeroTier / Cloudflare Tunnel / 自建 VPN
|
|
50
|
+
- 或者反向代理 + HTTPS + 鉴权(Bearer / Basic / 自定义 Header)
|
|
51
|
+
|
|
52
|
+
### 2) 配置鉴权(可选)
|
|
53
|
+
|
|
54
|
+
本项目支持“有些云端需要、有些不需要”的混合场景。你可以在 `.cursor/mcp.json` 里通过 `env` 注入:
|
|
55
|
+
|
|
56
|
+
#### Bearer Token
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"mcpServers": {
|
|
61
|
+
"animatool": {
|
|
62
|
+
"command": "animatool-mcp",
|
|
63
|
+
"env": {
|
|
64
|
+
"COMFYUI_URL": "https://your-host.example.com:8188",
|
|
65
|
+
"ANIMATOOL_BEARER_TOKEN": "YOUR_TOKEN"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### Basic Auth
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"mcpServers": {
|
|
77
|
+
"animatool": {
|
|
78
|
+
"command": "animatool-mcp",
|
|
79
|
+
"env": {
|
|
80
|
+
"COMFYUI_URL": "https://your-host.example.com:8188",
|
|
81
|
+
"ANIMATOOL_BASIC_USER": "user",
|
|
82
|
+
"ANIMATOOL_BASIC_PASS": "pass"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### 自定义 Header(通用,推荐)
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"mcpServers": {
|
|
94
|
+
"animatool": {
|
|
95
|
+
"command": "animatool-mcp",
|
|
96
|
+
"env": {
|
|
97
|
+
"COMFYUI_URL": "https://your-host.example.com:8188",
|
|
98
|
+
"ANIMATOOL_HEADERS_JSON": "{\"X-API-Key\":\"xxx\",\"CF-Access-Client-Id\":\"...\",\"CF-Access-Client-Secret\":\"...\"}"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
> Windows/JSON 转义提示:`ANIMATOOL_HEADERS_JSON` 本身是一个 JSON 字符串,所以内部的双引号需要转义(如上所示)。
|
|
106
|
+
|
|
107
|
+
### 3) 自签名证书/SSL 校验
|
|
108
|
+
|
|
109
|
+
如果你的云端是自签名证书,可以临时关闭校验(不推荐长期使用):
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"mcpServers": {
|
|
114
|
+
"animatool": {
|
|
115
|
+
"command": "animatool-mcp",
|
|
116
|
+
"env": {
|
|
117
|
+
"COMFYUI_URL": "https://your-host.example.com:8188",
|
|
118
|
+
"ANIMATOOL_SSL_VERIFY": "false"
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## CLI(可选)
|
|
128
|
+
|
|
129
|
+
用于本地自测(不依赖 MCP 客户端):
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
animatool-generate --comfyui-url http://127.0.0.1:8188 --json-file payload.json
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 环境变量速查
|
|
138
|
+
|
|
139
|
+
| 环境变量 | 说明 | 默认值 |
|
|
140
|
+
|---|---|---|
|
|
141
|
+
| `COMFYUI_URL` | ComfyUI Server base URL | `http://127.0.0.1:8188` |
|
|
142
|
+
| `ANIMATOOL_TIMEOUT` | 请求超时秒 | `600` |
|
|
143
|
+
| `ANIMATOOL_POLL_INTERVAL` | 轮询间隔秒 | `1` |
|
|
144
|
+
| `ANIMATOOL_SSL_VERIFY` | SSL 校验 | `true` |
|
|
145
|
+
| `ANIMATOOL_BEARER_TOKEN` | Bearer Token | *(空)* |
|
|
146
|
+
| `ANIMATOOL_BASIC_USER` / `ANIMATOOL_BASIC_PASS` | Basic Auth | *(空)* |
|
|
147
|
+
| `ANIMATOOL_HEADERS_JSON` | 自定义 Header JSON | *(空)* |
|
|
148
|
+
| `ANIMATOOL_DOWNLOAD_IMAGES` | 是否保存图片到本地 | `false` |
|
|
149
|
+
| `ANIMATOOL_OUTPUT_DIR` | 本地保存目录 | `./animatool_outputs` |
|
|
150
|
+
| `COMFYUI_MODELS_DIR` | models 目录(用于本机预检查) | *(空)* |
|
|
151
|
+
| `ANIMATOOL_CHECK_MODELS` | 是否启用预检查 | `true` |
|
|
152
|
+
|
|
153
|
+
## 常见问题
|
|
154
|
+
|
|
155
|
+
### Q: 报错连接不上 /prompt?
|
|
156
|
+
|
|
157
|
+
- 检查 `COMFYUI_URL` 是否可达(云端建议先在浏览器访问 `COMFYUI_URL/system_stats`)
|
|
158
|
+
- 如果有鉴权,请确认 `/prompt`、`/history`、`/view` 都在同一套鉴权规则下
|
|
159
|
+
- 常见坑:反代只给 `/prompt` 放行了,但 `/view` 被 401/403 拦住,会导致“生成成功但取图失败”
|
|
160
|
+
|
|
161
|
+
### Q: 报错找不到模型?
|
|
162
|
+
|
|
163
|
+
本工具提交的是一个包含 `UNETLoader/CLIPLoader/VAELoader` 的工作流模板,加载的是云端磁盘上的文件名。请确认云端 `models/` 下至少存在:
|
|
164
|
+
|
|
165
|
+
- `models/diffusion_models/anima-preview.safetensors`
|
|
166
|
+
- `models/text_encoders/qwen_3_06b_base.safetensors`
|
|
167
|
+
- `models/vae/qwen_image_vae.safetensors`
|
|
168
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "comfyui-animatool"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Standalone MCP server + client for generating Anima-style images via a remote/local ComfyUI Server API."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Moeblack" }]
|
|
13
|
+
keywords = ["comfyui", "anima", "mcp", "tool-use", "ai-agent", "cursor"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Topic :: Multimedia :: Graphics",
|
|
22
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"mcp>=1.0.0",
|
|
26
|
+
"requests>=2.31",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
server = [
|
|
31
|
+
"fastapi>=0.110",
|
|
32
|
+
"uvicorn[standard]>=0.27",
|
|
33
|
+
"pydantic>=2.6",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://github.com/Moeblack/ComfyUI-AnimaTool"
|
|
38
|
+
Repository = "https://github.com/Moeblack/ComfyUI-AnimaTool"
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
animatool-mcp = "animatool_mcp.mcp_server:main"
|
|
42
|
+
animatool-generate = "animatool_mcp.cli:main"
|
|
43
|
+
|
|
44
|
+
[tool.setuptools]
|
|
45
|
+
package-dir = {"" = "src"}
|
|
46
|
+
|
|
47
|
+
[tool.setuptools.packages.find]
|
|
48
|
+
where = ["src"]
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.package-data]
|
|
51
|
+
animatool_mcp = [
|
|
52
|
+
"resources/schemas/*.json",
|
|
53
|
+
"resources/workflow/*.json",
|
|
54
|
+
"resources/knowledge/*.md",
|
|
55
|
+
]
|
|
56
|
+
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any, Dict, Optional
|
|
7
|
+
|
|
8
|
+
from .client import AnimaExecutor
|
|
9
|
+
from .config import AnimaToolConfig
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _load_json_arg(s: str) -> Dict[str, Any]:
|
|
13
|
+
try:
|
|
14
|
+
obj = json.loads(s)
|
|
15
|
+
except Exception as e:
|
|
16
|
+
raise SystemExit(f"--json 解析失败:{e}") from e
|
|
17
|
+
if not isinstance(obj, dict):
|
|
18
|
+
raise SystemExit("--json 必须是一个 JSON object")
|
|
19
|
+
return obj
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _load_json_file(path: str) -> Dict[str, Any]:
|
|
23
|
+
p = Path(path)
|
|
24
|
+
if not p.exists():
|
|
25
|
+
raise SystemExit(f"找不到文件:{p}")
|
|
26
|
+
obj = json.loads(p.read_text(encoding="utf-8"))
|
|
27
|
+
if not isinstance(obj, dict):
|
|
28
|
+
raise SystemExit("--json-file 内容必须是一个 JSON object")
|
|
29
|
+
return obj
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def main(argv: Optional[list[str]] = None) -> int:
|
|
33
|
+
parser = argparse.ArgumentParser(description="animatool-mcp CLI (ComfyUI Server client)")
|
|
34
|
+
|
|
35
|
+
parser.add_argument("--comfyui-url", default=None, help="ComfyUI base URL(覆盖 COMFYUI_URL)")
|
|
36
|
+
parser.add_argument("--bearer-token", default=None, help="Bearer token(覆盖 ANIMATOOL_BEARER_TOKEN)")
|
|
37
|
+
parser.add_argument("--headers-json", default=None, help="自定义 headers JSON(覆盖 ANIMATOOL_HEADERS_JSON)")
|
|
38
|
+
parser.add_argument("--basic-user", default=None, help="Basic auth user(覆盖 ANIMATOOL_BASIC_USER)")
|
|
39
|
+
parser.add_argument("--basic-pass", default=None, help="Basic auth pass(覆盖 ANIMATOOL_BASIC_PASS)")
|
|
40
|
+
parser.add_argument(
|
|
41
|
+
"--ssl-verify",
|
|
42
|
+
action=argparse.BooleanOptionalAction,
|
|
43
|
+
default=None,
|
|
44
|
+
help="SSL 校验(覆盖 ANIMATOOL_SSL_VERIFY)",
|
|
45
|
+
)
|
|
46
|
+
parser.add_argument(
|
|
47
|
+
"--download-images",
|
|
48
|
+
action=argparse.BooleanOptionalAction,
|
|
49
|
+
default=None,
|
|
50
|
+
help="是否把图片保存到本地(覆盖 ANIMATOOL_DOWNLOAD_IMAGES)",
|
|
51
|
+
)
|
|
52
|
+
parser.add_argument("--output-dir", default=None, help="保存目录(覆盖 ANIMATOOL_OUTPUT_DIR)")
|
|
53
|
+
|
|
54
|
+
parser.add_argument("--json", default=None, help="直接传入 JSON object 字符串")
|
|
55
|
+
parser.add_argument("--json-file", default=None, help="从文件读取 JSON object")
|
|
56
|
+
|
|
57
|
+
args = parser.parse_args(argv)
|
|
58
|
+
|
|
59
|
+
if not args.json and not args.json_file:
|
|
60
|
+
raise SystemExit("必须提供 --json 或 --json-file")
|
|
61
|
+
if args.json and args.json_file:
|
|
62
|
+
raise SystemExit("只能二选一:--json 或 --json-file")
|
|
63
|
+
|
|
64
|
+
payload = _load_json_arg(args.json) if args.json else _load_json_file(args.json_file)
|
|
65
|
+
|
|
66
|
+
cfg_kwargs: Dict[str, Any] = {}
|
|
67
|
+
if args.comfyui_url:
|
|
68
|
+
cfg_kwargs["comfyui_url"] = str(args.comfyui_url)
|
|
69
|
+
if args.bearer_token:
|
|
70
|
+
cfg_kwargs["bearer_token"] = str(args.bearer_token)
|
|
71
|
+
if args.headers_json:
|
|
72
|
+
cfg_kwargs["headers_json"] = str(args.headers_json)
|
|
73
|
+
if args.basic_user is not None:
|
|
74
|
+
cfg_kwargs["basic_user"] = str(args.basic_user)
|
|
75
|
+
if args.basic_pass is not None:
|
|
76
|
+
cfg_kwargs["basic_pass"] = str(args.basic_pass)
|
|
77
|
+
if args.ssl_verify is not None:
|
|
78
|
+
cfg_kwargs["ssl_verify"] = bool(args.ssl_verify)
|
|
79
|
+
if args.download_images is not None:
|
|
80
|
+
cfg_kwargs["download_images"] = bool(args.download_images)
|
|
81
|
+
if args.output_dir:
|
|
82
|
+
cfg_kwargs["output_dir"] = Path(args.output_dir)
|
|
83
|
+
|
|
84
|
+
cfg = AnimaToolConfig(**cfg_kwargs)
|
|
85
|
+
ex = AnimaExecutor(config=cfg)
|
|
86
|
+
result = ex.generate(payload)
|
|
87
|
+
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
88
|
+
return 0
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
if __name__ == "__main__":
|
|
92
|
+
raise SystemExit(main())
|
|
93
|
+
|