一款基于Dream AI的Model Context Protocol (MCP)服务器,通过Claude和其他LLM应用程序提供强大的图像和视频生成能力。
核心依赖:该项目基于jimeng-free-api-all构建,作为一个开源项目,该项目提供了针对Zhimeng AI的反向接口实现,支持各种AI生成能力,如文本生成图形和视频生成图形。
此MCP服务器提供四个主要工具:
根据文本描述生成高质量的图像,使用Zhimeng 4.0。
能力:
根据文本指令融合多张图像。
能力:
根据文本描述生成短视频片段,使用Instant Video 3.0。
能力:
根据文本提示为静态图像添加动画效果。
能力:
此MCP服务器的核心API能力基于jimeng-free-api-all项目实现。
┌─────────────────────────────────────────────────┐
│ Claude Desktop / MCP Client │
└────────────────────┬────────────────────────────┘
│ MCP Protocol
↓
┌─────────────────────────────────────────────────┐
│ jimengmcp (本 MCP 服务器) │
│ ┌──────────────────────────────────────┐ │
│ │ MCP Protocol Handler (stdio/sse) │ │
│ └───────────────┬──────────────────────┘ │
│ ↓ │
│ ┌──────────────────────────────────────┐ │
│ │ 工具实现 │ │
│ │ - text_to_image │ │
│ │ - image_composition │ │
│ │ - text_to_video │ │
│ │ - image_to_video │ │
│ └───────────────┬──────────────────────┘ │
└────────────────────┼────────────────────────────┘
│ HTTP API 调用
↓
┌─────────────────────────────────────────────────┐
│ jimeng-free-api-all 逆向接口服务 │
│ (https://github.com/wwwzhouhui/ │
│ jimeng-free-api-all) │
│ ┌──────────────────────────────────────┐ │
│ │ OpenAI 兼容 API 端点 │ │
│ │ - POST /v1/images/generations │ │
│ │ - POST /v1/images/compositions │ │
│ │ - POST /v1/videos/generations │ │
│ └───────────────┬──────────────────────┘ │
└────────────────────┼────────────────────────────┘
│ 逆向调用
↓
┌─────────────────────────────────────────────────┐
│ 即梦 AI 官方服务 │
│ (https://jimeng.duckcloud.fun) │
└─────────────────────────────────────────────────┘
此MCP服务器需要先部署底层API服务,请按照以下步骤进行部署:
方法1:Docker部署(推荐)
# 拉取镜像
docker pull wwwzhouhui569/jimeng-free-api-all:latest
# 运行容器
docker run -it -d --init --name jimeng-free-api-all \
-p 8001:8000 \
-e TZ=Asia/Shanghai \
wwwzhouhui569/jimeng-free-api-all:latest
方法2:源码部署
# 克隆 jimeng-free-api-all 项目
git clone https://github.com/wwwzhouhui/jimeng-free-api-all.git
cd jimeng-free-api-all
# 使用 Docker Compose 启动
docker-compose up -d
部署后,API服务将在http://localhost:8001上运行。
获取SessionID:
F12打开浏览器开发者工具Application > Cookiessessionid的值Authorization: Bearer [your_sessionid]验证部署:
# 测试 API 是否正常运行
curl http://localhost:8001/v1/models
# 应该返回可用模型列表
git clone <repository-url>
cd jimengmcp
基本安装(STDIO模式)
pip install -e .
SSE模式
pip install -e ".[sse]"
HTTP模式
pip install -e ".[http]"
完整安装(所有模式)
pip install -e ".[all]"
.env文件:cp .env.example .env
.env并配置连接信息:# 必需: 您的即梦 SessionID (从浏览器 Cookie 中获取)
JIMENG_API_KEY=your_sessionid_here
# 必需: jimeng-free-api-all 服务地址
JIMENG_API_URL=http://localhost:8001
# 可选: 默认使用的模型
JIMENG_MODEL=jimeng-4.0
重要提示:
JIMENG_API_KEY:填写从Zhimeng官方网站获取的会话IDJIMENG_API_URL:填写第一步部署的Jimeng free API all服务地址此MCP服务器支持三种通信模式:
STDIO模式通过标准输入/输出进行通信,适合与Claude Desktop等MCP客户端集成。
启动命令:
python -m jimeng_mcp.server
# 或
python -m jimeng_mcp.server --mode stdio
SSE模式提供基于HTTP的事件流,适合与Web应用集成。
启动命令:
python -m jimeng_mcp.server --mode sse --host 0.0.0.0 --port 8000
连接端点:
http://localhost:8000/sse
HTTP模式提供标准RESTful API接口,适合各种编程语言调用。
启动命令:
python -m jimeng_mcp.server --mode http --host 0.0.0.0 --port 8000
可用端点:
GET /health -健康检查GET /tools -获取可用工具列表POST /text-to-image -文本生成图像POST /image-composition -图像合成POST /text-to-video -文本生成视频POST /image-to-video -图像生成视频在项目的根目录下创建.env文件,包含以下变量:
# 必需: 您的即梦API密钥
JIMENG_API_KEY=您的API密钥
# 可选: API基础URL(默认为 https://jimeng.duckcloud.fun)
JIMENG_API_URL=https://jimeng.duckcloud.fun
# 可选: 图像生成的默认模型(默认为 jimeng-4.0)
JIMENG_MODEL=jimeng-4.0
将此服务器添加到Cherry Studio配置文件中:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"jimeng": {
"command": "python",
"args": ["-m", "jimeng_mcp.server"],
"env": {
"JIMENG_API_KEY": "您的API密钥"
}
}
}
}
或者,如果您有.env文件:
{
"mcpServers": {
"jimeng": {
"command": "python",
"args": ["-m", "jimeng_mcp.server"]
}
}
}
SSE配置
安装和配置完成后,您可以在Cherry Studio中直接使用即时梦想工具:
生成一张图像:小猪和小狗踢球
将这两张图像合成在一起:
- 图像1: https://p3-dreamina-sign.byteimg.com/tos-cn-i-tb4s082cfz/bab623359bd9410da0c1f07897b16fec~tplv-tb4s082cfz-resize:0:0.image?lk3s=8e790bc3&x-expires=1788961069&x-signature=cbtnyeSIcqWpngHdoYWFkCra3cA%3D
- 图像2: https://p3-dreamina-sign.byteimg.com/tos-cn-i-tb4s082cfz/6acf16d07c47413898aea2bdd1ad339e~tplv-tb4s082cfz-resize:0:0.image?lk3s=8e790bc3&x-expires=1788961069&x-signature=30S2i%2FvCH0eRR32CehcEaK8t5ns%3D
创建一个艺术风格的无缝融合
创建一个视频:小猫在钓鱼
为这张图像添加动画效果:
https://p3-dreamina-sign.byteimg.com/tos-cn-i-tb4s082cfz/bab623359bd9410da0c1f07897b16fec~tplv-tb4s082cfz-resize:0:0.image?lk3s=8e790bc3&x-expires=1788961069&x-signature=cbtnyeSIcqWpngHdoYWFkCra3cA%3D
添加轻柔的运动和自然的镜头缩放
当服务器运行在HTTP模式时,可以通过REST API调用:
curl http://localhost:8000/health
响应:
{
"status": "healthy",
"server": "jimeng-mcp",
"version": "0.1.0",
"mode": "http"
}
curl http://localhost:8000/tools
curl -X POST http://localhost:8000/text-to-image \
-H "Content-Type: application/json" \
-d '{
"prompt": "可爱的卡通小斑马在花园里玩耍",
"width": 1536,
"height": 864,
"sample_strength": 0.6
}'
curl -X POST http://localhost:8000/image-composition \
-H "Content-Type: application/json" \
-d '{
"prompt": "将两张图像艺术风格地融合",
"images": [
"https://example.com/image1.jpg",
"https://example.com/image2.jpg"
]
}'
curl -X POST http://localhost:8000/text-to-video \
-H "Content-Type: application/json" \
-d '{
"prompt": "一个人在森林中缓慢向前走",
"resolution": "720p"
}'
curl -X POST http://localhost:8000/image-to-video \
-H "Content-Type: application/json" \
-d '{
"prompt": "添加轻柔的运动效果",
"file_paths": ["https://example.com/image.jpg"]
}'
import requests
# 文本生成图像
response = requests.post(
"http://localhost:8000/text-to-image",
json={
"prompt": "可爱的卡通小斑马在花园里玩耍",
"width": 1536,
"height": 864,
"sample_strength": 0.6
}
)
result = response.json()
if result["success"]:
print(result["result"])
else:
print(f"Error: {result['error']}")
// 文本生成图像
fetch('http://localhost:8000/text-to-image', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
prompt: '可爱的卡通小斑马在花园里玩耍',
width: 1536,
height: 864,
sample_strength: 0.6
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
console.log(data.result);
} else {
console.error('Error:', data.error);
}
});
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| Prompt | string | 是 | - | 图像的详细描述 |
| Negative_compt | string | 否 | "" | 图像中需要避免的内容 |
| Width | integer | 否 | 1536 | 图像宽度(512, 768, 1024, 1536, 2048) |
| Height | integer | 否 | 864 | 图像高度(512, 768, 864, 1024, 2048) |
| Sample_strend | float | 否 | 0.5 | 创意水平(0.0-1.0) |
| Model | string | 否 | Jimeng-4.0 | 使用的模型 |
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| Prompt | string | 是 | - | 如何合成图像 |
| Images | array | 是 | - | 图像URL数组(至少2张图像) |
| Width | integer | 否 | 1536 | 输出宽度 |
| Height | integer | 否 | 864 | 输出高度 |
| Sample_strend | float | 否 | 0.5 | 复合强度(0.0-1.0) |
| Model | string | 否 | Jimeng-4.0 | 使用的模型 |
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| Prompt | string | 是 | - | 视频描述 |
| Width | integer | 否 | 720 | 视频宽度(480, 720, 1280, 1920) |
| Height | integer | 否 | 480 | 视频高度(480, 720, |