imgenx-mcp 0.4.0__py3-none-any.whl

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.
@@ -0,0 +1,392 @@
1
+ Metadata-Version: 2.4
2
+ Name: imgenx-mcp
3
+ Version: 0.4.0
4
+ Summary: AI Image/Video Generation MCP Server with OSS Upload - Powered by Doubao API
5
+ Project-URL: Homepage, https://github.com/helios123/imgenx-mcp
6
+ Project-URL: Repository, https://github.com/helios123/imgenx-mcp
7
+ Project-URL: Issues, https://github.com/helios123/imgenx-mcp/issues
8
+ Project-URL: Documentation, https://github.com/helios123/imgenx-mcp/blob/main/README.md
9
+ Author-email: helios123 <your-email@example.com>
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Keywords: ai,aliyun,doubao,image-generation,mcp,oss,video-generation
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Requires-Python: >=3.10
21
+ Requires-Dist: fastmcp>=2.12.4
22
+ Requires-Dist: oss2>=2.19.1
23
+ Requires-Dist: pillow>=12.0.0
24
+ Requires-Dist: python-dotenv>=1.1.1
25
+ Requires-Dist: requests>=2.25.0
26
+ Requires-Dist: volcengine-python-sdk[ark]>=4.0.22
27
+ Description-Content-Type: text/markdown
28
+
29
+ <div align="center">
30
+ <img src="logo.jpg" alt="ImgenX MCP Server Logo" width="800" height="400">
31
+
32
+ [![Version](https://img.shields.io/badge/Version-0.4.0-brightgreen.svg)](https://github.com/helios123/imgenx-mcp/releases)
33
+ [![Python](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://www.python.org/downloads/)
34
+ [![MCP](https://img.shields.io/badge/MCP-Compatible-green.svg)](https://modelcontextprotocol.io/)
35
+ [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](#许可证)
36
+
37
+ **一站式 AI 图片/视频生成与处理套件,支持文本/图生图、文本/图生视频、图片分析与常用编辑(裁剪、缩放、转换、调参),自动上传到阿里云 OSS 并返回永久 CDN URL。可作为命令行工具或 MCP Server 使用**
38
+ </div>
39
+
40
+ https://github.com/user-attachments/assets/92749d6f-727e-4874-a008-6ded8b4d9e7b
41
+
42
+ ## 功能特性
43
+
44
+ - **文本生成图片**: 根据文本描述生成图片,自动上传到 OSS 并返回永久 CDN URL ⭐
45
+ - **图片生成图片**: 基于输入图片和文本描述生成新图片,自动上传到 OSS ⭐
46
+ - **文本/图片生成视频**: 支持提示词生成视频,或基于首尾帧生成视频,自动上传到 OSS ⭐
47
+ - **图片处理工具**: 提供完整的图片处理功能
48
+ - **图片信息获取**: 查看图片格式、尺寸、模式等信息
49
+ - **图片裁剪**: 按指定区域裁剪图片(支持小数比例坐标)
50
+ - **尺寸调整**: 调整图片大小,支持保持宽高比
51
+ - **格式转换**: 支持 PNG、JPEG、JPG、WEBP 格式转换
52
+ - **图像调整**: 调整亮度、对比度、饱和度
53
+ - **图片粘贴**: 将图片粘贴到背景图片的指定位置
54
+ - **图片理解与分析**: 基于视觉模型分析图片内容,输出结构化或文本结果
55
+ - **☁️ 自动 OSS 上传**: 生成图片/视频后自动上传到阿里云 OSS,无需手动操作 ⭐新增
56
+ - 永久有效的 CDN URL
57
+ - 无需本地下载和手动上传
58
+ - 支持自定义业务目录(images、videos 等)
59
+ - **多种分辨率支持**: 支持 1K、2K、4K 分辨率以及多种自定义像素尺寸
60
+ - **插件化架构**: 基于工厂模式设计,支持扩展新的图片生成服务提供商
61
+ - **MCP 协议支持**: 兼容 Model Context Protocol 标准
62
+
63
+ ## 当前支持的服务提供商
64
+
65
+ - **豆包 (Doubao)**: 基于火山引擎的图片生成服务
66
+
67
+ ## 安装
68
+
69
+ ### 配置环境变量
70
+
71
+ ```bash
72
+ # 图片视频生成模型配置
73
+ export IMGENX_IMAGE_MODEL="doubao:doubao-seedream-4-0-250828" # 图片生成模型
74
+ export IMGENX_VIDEO_MODEL="doubao:doubao-seedance-1-0-pro-fast-251015" # 视频生成模型(可选)
75
+ export IMGENX_ANALYZER_MODEL="doubao:doubao-seed-1-6-vision-250815" # 图片分析模型(可选)
76
+ export IMGENX_API_KEY="your_api_key"
77
+
78
+ # 阿里云 OSS 配置(可选,用于文件上传)
79
+ export OSS_ACCESS_KEY_ID="your_oss_access_key_id"
80
+ export OSS_ACCESS_KEY_SECRET="your_oss_access_key_secret"
81
+ export OSS_BUCKET="your_bucket_name"
82
+ export OSS_ENDPOINT="oss-cn-shanghai.aliyuncs.com"
83
+ export OSS_CDN_URL="https://your-cdn-domain.com/"
84
+ ```
85
+ 或写入 .env 文件中
86
+
87
+ ### 安装步骤
88
+
89
+ #### 方式一:pip 安装(推荐)
90
+
91
+ ```bash
92
+ pip install imgenx-mcp
93
+ ```
94
+
95
+ #### 方式二:从源码安装
96
+ ```bash
97
+ git clone https://github.com/helios123/imgenx-mcp.git
98
+ cd imgenx-mcp
99
+ pip install -e .
100
+ ```
101
+
102
+ ## 使用方法
103
+
104
+ ### 作为命令行运行
105
+
106
+ ```
107
+ # 生成图片(文本或图生图)
108
+ imgenx image "一只在云上飞翔的猫"
109
+ imgenx image "一只在云上飞翔的猫" --size 2K
110
+ imgenx image "一只在云上飞翔的猫" --size 2048x2048 --output test.jpg
111
+ imgenx image "一只在云上飞翔的猫" --images test.jpg --size 2048x2048 --output out_dir/
112
+
113
+ # 生成视频(文本或基于首尾帧)
114
+ imgenx video "一个人在运动" --resolution 720p --ratio 16:9 --duration 5 --output video.mp4
115
+ imgenx video "一个人在运动" --first_frame logo.jpg --resolution 720p --ratio 16:9 --duration 5 --output video.mp4
116
+ ```
117
+
118
+ ### 作为 MCP 服务器运行
119
+
120
+ #### 标准输入输出模式 (stdio) - 推荐
121
+
122
+ **配置文件位置:**
123
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
124
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
125
+ - **Linux**: `~/.config/Claude/claude_desktop_config.json`
126
+
127
+ **配置示例(使用 uvx,无需安装):**
128
+ ```json
129
+ {
130
+ "mcpServers": {
131
+ "imgenx": {
132
+ "command": "uvx",
133
+ "args": ["imgenx-mcp"],
134
+ "env": {
135
+ "IMGENX_IMAGE_MODEL": "doubao:doubao-seedream-4-0-250828",
136
+ "IMGENX_VIDEO_MODEL": "doubao:doubao-seedance-1-0-pro-fast-251015",
137
+ "IMGENX_ANALYZER_MODEL": "doubao:doubao-seed-1-6-vision-250815",
138
+ "IMGENX_API_KEY": "your_api_key_here",
139
+ "OSS_ACCESS_KEY_ID": "your_oss_key",
140
+ "OSS_ACCESS_KEY_SECRET": "your_oss_secret",
141
+ "OSS_BUCKET": "your_bucket",
142
+ "OSS_ENDPOINT": "oss-cn-shanghai.aliyuncs.com",
143
+ "OSS_CDN_URL": "https://your-cdn.com/"
144
+ },
145
+ "timeout": 600
146
+ }
147
+ }
148
+ }
149
+ ```
150
+
151
+ **配置示例(使用已安装的包):**
152
+ ```json
153
+ {
154
+ "mcpServers": {
155
+ "imgenx": {
156
+ "command": "python",
157
+ "args": ["-m", "imgenx.main"],
158
+ "env": {
159
+ "IMGENX_IMAGE_MODEL": "doubao:doubao-seedream-4-0-250828",
160
+ "IMGENX_API_KEY": "your_api_key_here"
161
+ },
162
+ "timeout": 600
163
+ }
164
+ }
165
+ }
166
+ ```
167
+
168
+ **配置后重启 Claude Desktop 即可使用。**
169
+
170
+ #### HTTP 服务器模式
171
+ ```bash
172
+ imgenx server --transport streamable-http --host 0.0.0.0 --port 8000
173
+ imgenx server --transport streamable-http --no_tools text_to_video image_to_video # 禁用视频生成工具
174
+ ```
175
+
176
+ ```json
177
+ {
178
+ "mcpServers": {
179
+ "imgenx-mcp": {
180
+ "url": "http://127.0.0.1:8000/mcp",
181
+ "headers": {
182
+ "IMGENX_IMAGE_MODEL": "doubao:doubao-seedream-4-0-250828",
183
+ "IMGENX_VIDEO_MODEL": "doubao:doubao-seedance-1-0-pro-fast-251015",
184
+ "IMGENX_ANALYZER_MODEL": "doubao:doubao-seed-1-6-vision-250815",
185
+ "IMGENX_API_KEY": "api-key"
186
+ },
187
+ "timeout": 600
188
+ }
189
+ }
190
+ }
191
+ ```
192
+
193
+ ### 可用工具
194
+
195
+ #### 1. text_to_image
196
+ 根据文本描述生成图片。
197
+
198
+ #### 2. image_to_image
199
+ 基于输入图片和文本描述生成新图片。
200
+
201
+ #### 3. download
202
+ 下载图片或视频到本地。
203
+
204
+ #### 4. get_image_info
205
+ 获取图片信息。
206
+
207
+ #### 5. crop_image
208
+ 裁剪图片。
209
+
210
+ #### 6. resize_image
211
+ 调整图片尺寸。
212
+
213
+ #### 7. convert_image
214
+ 转换图片格式。
215
+
216
+ #### 8. adjust_image
217
+ 调整图片的亮度、对比度和饱和度。
218
+
219
+ #### 9. text_to_video
220
+ 根据文本提示生成视频。
221
+
222
+ #### 10. image_to_video
223
+ 基于首帧与可选尾帧生成视频。
224
+
225
+ #### 11. analyze_image
226
+ 分析图片内容,返回结构化或文本结果。
227
+
228
+ #### 12. paste_image
229
+ 将图片粘贴到背景图片的指定位置。
230
+
231
+ #### 13. upload_to_oss (新增)
232
+ 上传本地文件到阿里云 OSS。
233
+
234
+ #### 14. download_and_upload_to_oss (新增)
235
+ 下载 URL 并直接上传到阿里云 OSS(无需本地保存)。
236
+
237
+ ## 项目结构
238
+
239
+ ```
240
+ imgenx-mcp-server/
241
+ ├── imgenx/
242
+ │ ├── server.py # MCP 服务器主文件(工具定义与运行)
243
+ │ ├── factory.py # 预测器工厂(图片/视频/分析)
244
+ │ ├── operator.py # 图片处理操作模块
245
+ │ ├── main.py # CLI 入口(imgenx)
246
+ │ ├── script.py # 命令行生成图片/视频脚本
247
+ │ └── predictor/
248
+ │ ├── base/
249
+ │ │ ├── base_image_generator.py # 基础图片生成器接口
250
+ │ │ ├── base_video_generator.py # 基础视频生成器接口
251
+ │ │ └── base_image_analyzer.py # 基础图片分析器接口
252
+ │ └── generators/
253
+ │ ├── doubao_image_generator.py # 豆包图片生成器实现
254
+ │ ├── doubao_video_generator.py # 豆包视频生成器实现
255
+ │ └── doubao_image_analyzer.py # 豆包图片分析器实现
256
+ ├── pyproject.toml # 项目配置(入口脚本等)
257
+ ├── uv.lock # 依赖锁(可选)
258
+ └── README.md # 项目说明
259
+ ```
260
+
261
+ ## 扩展新的服务提供商
262
+
263
+ 要扩展新的服务提供商:
264
+
265
+ 1. 在 `imgenx/predictor/generators/` 目录下创建实现文件,命名规范:
266
+ - 图片生成器:`{provider}_image_generator.py`
267
+ - 视频生成器(可选):`{provider}_video_generator.py`
268
+ - 图片分析器(可选):`{provider}_image_analyzer.py`
269
+
270
+ 2. 实现 `BaseImageGenerator` 接口:
271
+ ```python
272
+ from typing import List, Dict
273
+ from imgenx.predictor.base.base_image_generator import BaseImageGenerator
274
+
275
+ class ProviderImageGenerator(BaseImageGenerator):
276
+ def __init__(self, model: str, api_key: str):
277
+ self.model = model
278
+ self.api_key = api_key
279
+ # 其他初始化代码
280
+
281
+ def text_to_image(self, prompt: str, size: str) -> List[Dict[str, str]]:
282
+ # 实现文本生成图片逻辑
283
+ # 返回格式: [{"url": "图片URL"}]
284
+ pass
285
+
286
+ def image_to_image(self, prompt: str, images: List[str], size: str) -> List[Dict[str, str]]:
287
+ # 实现图片生成图片逻辑(可选)
288
+ # 返回格式: [{"url": "图片URL"}]
289
+ pass
290
+ ```
291
+
292
+ 3. 工厂类会自动发现并加载新的实现(基于文件名),模型字符串需为 `provider:model` 格式,例如:`doubao:doubao-seedream-4-0-250828`
293
+
294
+ ## 依赖项
295
+
296
+ - `fastmcp>=2.12.4`: MCP 协议实现
297
+ - `python-dotenv>=1.1.1`: 环境变量加载
298
+ - `volcengine-python-sdk[ark]>=4.0.22`: 火山引擎 SDK(豆包服务)
299
+ - `requests>=2.25.0`: HTTP 请求库(用于图片下载)
300
+ - `pillow>=12.0.0`: 图片处理库(用于图片编辑操作)
301
+ - `oss2>=2.19.1`: 阿里云 OSS SDK(用于文件上传)
302
+
303
+ ## 使用示例
304
+
305
+ ### 在 Claude Desktop 中使用
306
+
307
+ 配置完成后,在 Claude 中可以直接使用自然语言:
308
+
309
+ ```
310
+ 生成一只小猫在天上飞的图片
311
+ ```
312
+
313
+ ```
314
+ 生成一个日落海滩的视频,5秒,1080p
315
+ ```
316
+
317
+ ```
318
+ 把刚生成的图片上传到 OSS
319
+ ```
320
+
321
+ ### 完整工作流示例
322
+
323
+ 1. **生成图片**
324
+ ```
325
+ 生成一只可爱的小猫在蓝天白云中飞翔的图片
326
+ ```
327
+
328
+ 2. **上传到 OSS**
329
+ ```
330
+ 把这张图片上传到 OSS
331
+ ```
332
+
333
+ 返回 CDN 地址,可直接访问和分享。
334
+
335
+ ## 相关文档
336
+
337
+ - [OSS 上传使用说明](./OSS_USAGE.md)
338
+ - [性能优化说明](./PERFORMANCE_OPTIMIZATION.md)
339
+
340
+ ## 更新日志
341
+
342
+ ### v0.3.0 (当前版本)
343
+
344
+ #### 新增功能
345
+ - **☁️ 阿里云 OSS 上传**: 新增 `upload_to_oss` 和 `download_and_upload_to_oss` 工具
346
+ - **CDN 加速支持**: 上传后自动返回 CDN 加速地址
347
+ - **完整工作流**: 生成图片/视频 -> 上传 OSS -> 获取 CDN URL
348
+
349
+ #### 性能优化
350
+ - 移除不必要的文件验证步骤,提升上传速度约 35%
351
+ - 优化文件上传流程,减少网络请求
352
+
353
+ #### 文档完善
354
+ - 新增 OSS 上传使用说明文档
355
+ - 新增性能优化说明文档
356
+ - 完善 Claude Desktop 配置示例
357
+
358
+ ### v0.2.3
359
+
360
+ #### 新增功能
361
+ - **图片粘贴**: 新增 `paste_image` 工具,支持将图片粘贴到背景图片的指定位置
362
+ - **工具控制**: 新增 `--no_tools` 参数,支持在运行 MCP 服务器时禁用特定工具
363
+
364
+ #### 功能优化
365
+ - 完善图片处理工具集,增强图片编辑能力
366
+
367
+ ### v0.2.0
368
+
369
+ #### 新增功能
370
+ - **视频生成**: 支持 `text_to_video` 与 `image_to_video` 两种方式
371
+ - **图片分析**: 新增 `analyze_image` 工具,支持视觉模型分析
372
+ - **图片处理工具集完善**: `get_image_info`、`crop_image`(比例坐标)、`resize_image`、`convert_image`、`adjust_image`
373
+
374
+ #### 技术改进
375
+ - 工厂模式统一图片/视频/分析三类预测器的发现与加载
376
+ - 环境变量分离为 `IMGENX_IMAGE_MODEL`、`IMGENX_VIDEO_MODEL`、`IMGENX_ANALYZER_MODEL`
377
+ - MCP 工具集扩展,HTTP 服务器提供 `/health`、`/healthy` 健康检查路由
378
+ - 支持本地文件与 URL 两种图片输入方式;下载工具统一图片/视频
379
+
380
+ ## 许可证
381
+
382
+ 本项目的许可证信息请查看项目仓库。
383
+
384
+ ## 贡献
385
+
386
+ 欢迎提交 Issue 和 Pull Request 来改进这个项目。
387
+
388
+ ## 联系方式
389
+
390
+ - GitHub: [@helios123](https://github.com/helios123)
391
+ - Issues: [提交问题](https://github.com/helios123/imgenx-mcp/issues)
392
+ - 原作者 Email: zhangslwork@yeah.net
@@ -0,0 +1,17 @@
1
+ imgenx/factory.py,sha256=SWFv8cXeh0RD9Zm6EQIicly1GEKbq_86SNb3CXQfkQk,1667
2
+ imgenx/main.py,sha256=fQ-LGtd2V31PjUopUm3uuZ9YslVhBB1i61P0oh5r5M4,2969
3
+ imgenx/operator.py,sha256=tOVDTolKxL-3BK_9Mq4DHypXzgdhyv-gKgH0hRwghRE,4270
4
+ imgenx/oss_service.py,sha256=5IM6p5DbUrWSl-IsJMrtF3CyZ4ymN37L32Qi55Uq92I,5879
5
+ imgenx/script.py,sha256=CpTPesuNdTBQttL4sZsq_eBje0jgif-EqHT_Sp0Ot18,3870
6
+ imgenx/server.py,sha256=f0AtRDq8NJ0rauxjiADSR3GtqKlpB6_FEwBReAKrK10,13195
7
+ imgenx/predictor/base/base_image_analyzer.py,sha256=6eMZwqagRtW-qBidRqt5y8DDW1NoPbz-oqSLYiq7lok,330
8
+ imgenx/predictor/base/base_image_generator.py,sha256=5lfFLU3k53X4n8Ld4Y1ex5_1PrfJrYT5UMAG-oWV2iU,488
9
+ imgenx/predictor/base/base_video_generator.py,sha256=s2MSQSjsJrvZYGfN5bmW6O4sLxU5elCcDh1GfYRI_n8,587
10
+ imgenx/predictor/generators/doubao_image_analyzer.py,sha256=Pja1N_sfMdnDhUQHFFoYpnapnd8t_nstj8g-YQ7h7wk,1942
11
+ imgenx/predictor/generators/doubao_image_generator.py,sha256=CKKqPEnzIqq7RFhJ7zchSHj-vyNSuBMPhx3KYn1YEEg,2237
12
+ imgenx/predictor/generators/doubao_video_generator.py,sha256=P0SqvWW0laB9Q0oxoITPRBxOT6_anQ6xWRZ7szk76pA,3931
13
+ imgenx_mcp-0.4.0.dist-info/METADATA,sha256=VxKS3nSAo3J9pAJBTn5gw44roikz5Ucp9f1N-7f6hW8,13435
14
+ imgenx_mcp-0.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
+ imgenx_mcp-0.4.0.dist-info/entry_points.txt,sha256=nmx0IbHTuYEWYXTv8T__X_d1JzcktNjsTSQFM98PgFU,43
16
+ imgenx_mcp-0.4.0.dist-info/licenses/LICENSE,sha256=fL49JMavx1QC0XPJ8i2RPNJQ_vmDwoiXM2jF66ytAf0,1068
17
+ imgenx_mcp-0.4.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ imgenx = imgenx.main:run
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 zhangshulin
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.