npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tony_iron_man/jimeng-mcp-server

v1.0.1

Published

即梦4.0 AI图像生成 MCP服务器 - Jimeng 4.0 AI Image Generation MCP Server

Readme

即梦4.0 AI图像生成 MCP服务器

这是一个MCP(Model Context Protocol)服务器,提供即梦4.0 AI图像生成功能。

功能特性

  • ✅ 文本生成图像(Text-to-Image)
  • ✅ 支持自定义分辨率(1K/2K/4K)
  • ✅ 可调节文本影响程度
  • ✅ 支持参考图片(图像编辑)
  • ✅ 返回Base64编码的图片数据
  • ✅ 自动签名认证

安装

方式1: 从npm安装(推荐)

npm install -g @tony_iron_man/jimeng-mcp-server

方式2: 从源码安装

git clone https://github.com/yourusername/jimeng-mcp-server.git
cd jimeng-mcp-server
npm install

配置

方法1: 使用环境变量(推荐)

export JIMENG_ACCESS_KEY_ID="你的AccessKeyID"
export JIMENG_SECRET_ACCESS_KEY="你的SecretAccessKey"

方法2: 修改代码中的默认值

编辑 index.js 文件中的 CONFIG 对象。

在Claude Desktop中使用

1. 配置Claude Desktop

编辑配置文件:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

使用npm全局安装后的配置:

{
  "mcpServers": {
    "jimeng": {
      "command": "jimeng-mcp-server",
      "env": {
        "JIMENG_ACCESS_KEY_ID": "你的AccessKeyID",
        "JIMENG_SECRET_ACCESS_KEY": "你的SecretAccessKey"
      }
    }
  }
}

注意: 包名为 @tony_iron_man/jimeng-mcp-server,但命令仍然是 jimeng-mcp-server

使用源码安装后的配置:

{
  "mcpServers": {
    "jimeng": {
      "command": "node",
      "args": [
        "/path/to/jimeng-mcp-server/index.js"
      ],
      "env": {
        "JIMENG_ACCESS_KEY_ID": "你的AccessKeyID",
        "JIMENG_SECRET_ACCESS_KEY": "你的SecretAccessKey"
      }
    }
  }
}

注意: 使用源码安装时,请将路径替换为实际的绝对路径。

2. 重启Claude Desktop

配置完成后,重启Claude Desktop应用。

3. 使用工具

在Claude Desktop中,你可以这样使用:

请使用即梦AI生成一张图片:一只可爱的小猫在花园里玩耍

Claude会自动调用 generate_image 工具。

MCP工具说明

generate_image

生成AI图像的工具。

参数:

  • prompt (必需, string): 图像描述文本
    • 示例: "一只可爱的小猫在花园里玩耍,高清摄影"
  • size (可选, number): 图像面积
    • 1048576 = 1K (1024×1024)
    • 4194304 = 2K (2048×2048) [默认]
    • 16777216 = 4K (4096×4096)
  • scale (可选, number): 文本影响程度 (0-1)
    • 0.3 = 更接近参考图
    • 0.5 = 平衡 [默认]
    • 0.7 = 更接近文本描述
  • forceSingle (可选, boolean): 是否强制单图
    • false = 可能生成多张 [默认]
    • true = 只生成一张
  • imageUrls (可选, array): 参考图片URL数组
    • 用于图像编辑或风格迁移

返回值:

{
  "success": true,
  "taskId": "任务ID",
  "imageFormat": "base64",
  "base64Images": ["BASE64_STRING_1", "BASE64_STRING_2"],
  "imageCount": 2
}

使用示例

示例1: 基础文生图

生成一张图片:春天的樱花树,阳光明媚,高清摄影

示例2: 高分辨率图片

生成一张4K分辨率的图片:未来科技城市,赛博朋克风格

示例3: 艺术风格

生成一张水彩画风格的图片:小桥流水,中国风

保存生成的图片

MCP返回的是Base64编码的图片数据。你可以:

方法1: 在Claude Desktop中查看

Claude会自动处理Base64数据并显示图片。

方法2: 手动保存

如果需要保存到本地,可以使用以下Node.js代码:

import fs from 'fs';

const base64String = "返回的Base64字符串";
const buffer = Buffer.from(base64String, 'base64');
fs.writeFileSync('output.jpg', buffer);

方法3: 在HTML中使用

<img src="data:image/jpeg;base64,BASE64_STRING" alt="AI生成图片" />

测试

直接测试(不通过MCP)

创建测试文件 test.js:

import { generateImage } from './index.js';

const result = await generateImage('一只可爱的小猫');
console.log(result);

运行:

node test.js

故障排除

问题1: 签名错误

原因: AccessKeyID或SecretAccessKey不正确

解决: 检查环境变量或配置文件中的密钥

问题2: 连接超时

原因: 网络问题或API服务不可用

解决: 检查网络连接,确认可以访问火山引擎API

问题3: Claude Desktop无法识别工具

原因: 配置文件路径错误或格式不正确

解决:

  1. 检查配置文件路径是否正确
  2. 确认JSON格式正确
  3. 重启Claude Desktop

问题4: 图片生成失败

原因: 提示词不合适或参数错误

解决:

  1. 使用更详细的提示词
  2. 检查参数是否在有效范围内
  3. 查看错误信息

技术细节

  • 协议: Model Context Protocol (MCP)
  • 传输: stdio
  • 认证: HMAC-SHA256签名
  • API: 火山引擎视觉AI服务
  • 模型: jimeng_t2i_v40

安全建议

  1. 不要提交密钥到Git

    # 添加到 .gitignore
    echo ".env" >> .gitignore
  2. 使用环境变量

    • 在生产环境中始终使用环境变量
    • 不要在代码中硬编码密钥
  3. 定期轮换密钥

    • 建议每3-6个月更换一次密钥

许可证

MIT

支持

  • 火山引擎官方文档: https://www.volcengine.com/docs/
  • MCP协议文档: https://modelcontextprotocol.io/

版本: 1.0.0
最后更新: 2025-11-26
模型: jimeng_t2i_v40