
Jimeng AI
STDIOTypeScript MCP server for Jimeng AI image generation with direct API integration.
TypeScript MCP server for Jimeng AI image generation with direct API integration.
使用TypeScript实现的Model Context Protocol (MCP) 服务器项目,集成了即梦AI图像生成服务,通过逆向工程直接调用即梦官方API。
要通过 Smithery 自动为Claude Desktop安装jimeng-mcp,请执行以下命令:
npx -y @smithery/cli install @c-rick/jimeng-mcp --client claude
# 使用yarn安装依赖 yarn install # 或使用npm安装依赖 npm install
在MCP客户端配置(如Claude Desktop)中设置以下环境变量:
进入Smithery托管项目,点击json, 填入JIMENG_API_TOKEN, 点击connect, 生成下面mcpServers config json
{ "mcpServers": { "jimeng-mcp": { "command": "npx", "args": [ "-y", "@smithery/cli@latest", "run", "@c-rick/jimeng-mcp", "--key", "[Smithery生成]", "--profile", "[Smithery生成]" ] } } }
sessionid
的值# 开发模式运行 yarn dev # 使用nodemon开发并自动重启 yarn start:dev
# 构建项目 yarn build
# 启动服务器 yarn start # 测试MCP服务器 yarn test
以下是在Claude Desktop中配置此MCP服务器的完整示例:
{ "mcpServers": { "jimeng": { "command": "node", "args": ["/path/to/jimeng-mcp/lib/index.js"], "env": { "JIMENG_API_TOKEN": "your_jimeng_session_id_here" } } } }
本MCP服务器直接调用即梦AI图像生成API,提供图像生成工具:
generateImage
- 提交图像生成请求并返回图像URL列表
prompt
:生成图像的文本描述(必填)filePath
:本地图片路径或图片URL(可选,若填写则为图片混合/参考图生成功能)model
:模型名称,可选值: jimeng-3.0, jimeng-2.1, jimeng-2.0-pro, jimeng-2.0, jimeng-1.4, jimeng-xl-pro(可选,默认为jimeng-2.1,图片混合时自动切换为jimeng-2.0-pro)width
:图像宽度,默认值:1024(可选)height
:图像高度,默认值:1024(可选)sample_strength
:精细度,默认值:0.5,范围0-1(可选)negative_prompt
:反向提示词,告诉模型不要生成什么内容(可选)注意:
filePath
支持本地绝对/相对路径和图片URL。- 若指定
filePath
,将自动进入图片混合/参考图生成模式,底层模型自动切换为jimeng-2.0-pro
。- 网络图片需保证可公开访问。
如需基于图片进行混合生成,只需传入filePath
参数(支持本地路径或图片URL),即可实现图片风格融合、参考图生成等高级玩法。
// 参考图片混合生成 client.callTool({ name: "generateImage", arguments: { prompt: "梵高风格的猫", filePath: "./test.png", // 本地图片路径 sample_strength: 0.6 } });
或
// 使用网络图片作为参考 client.callTool({ name: "generateImage", arguments: { prompt: "未来城市", filePath: "https://example.com/your-image.png" } });
服务器支持以下即梦AI模型:
jimeng-3.0
:即梦第三代模型,效果更好,支持更强的图像生成能力jimeng-2.1
:即梦2.1版本模型,默认模型jimeng-2.0-pro
:即梦2.0 Pro版本jimeng-2.0
:即梦2.0标准版本jimeng-1.4
:即梦1.4版本jimeng-xl-pro
:即梦XL Pro特殊版本通过MCP协议调用图像生成功能:
// 生成图像(文本生成) client.callTool({ name: "generateImage", arguments: { prompt: "一只可爱的猫咪在草地上", model: "jimeng-3.0", width: 1024, height: 1024, sample_strength: 0.7, negative_prompt: "模糊,扭曲,低质量" } }); // 生成图像(图片混合/参考图生成) client.callTool({ name: "generateImage", arguments: { prompt: "未来城市", filePath: "https://example.com/your-image.png" } });
API将返回生成的图像URL数组,可以直接在各类客户端中显示:
[ "https://example.com/generated-image-1.jpg", "https://example.com/generated-image-2.jpg", "https://example.com/generated-image-3.jpg", "https://example.com/generated-image-4.jpg" ]
服务器还提供了以下信息资源:
greeting://{name}
- 提供个性化问候info://server
- 提供服务器基本信息jimeng-ai://info
- 提供即梦AI图像生成服务的使用说明在Cursor或Claude中,你可以这样使用Jimeng图像生成服务:
请生成一张写实风格的日落下的山脉图片
图像生成失败
服务器无法启动
MIT