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 🙏

© 2026 – Pkg Stats / Ryan Hefner

jimeng-image-mcp

v0.3.4

Published

MCP service for Jimeng Image Generation API

Readme

即梦 MCP 服务器

一个基于 Model Context Protocol (MCP) 的即梦图像生成 API 服务器,使用官方 TypeScript SDK 构建。

功能特性

🎨 图像生成工具

  • text_to_image - 提交图像生成任务
  • image_to_image - 提交图生图任务(支持绝对路径、文件协议和远程URL,不支持相对路径)
  • query_task - 查询任务状态和结果

🔧 辅助功能

  • 推荐尺寸配置 - 提供文生图和图生图的推荐尺寸选项
  • 水印配置选项 - 支持多种水印位置和语言设置
  • 参数验证 - 自动验证图像尺寸、提示词长度等参数
  • 并发控制 - 防止API调用冲突
  • 集中化日志 - 支持Elasticsearch日志收集和分析

📚 信息资源

  • config://jimeng - 即梦API配置信息
  • task://{taskId}/status - 任务状态信息

安装

npm install jimeng-image-mcp

环境配置

创建 .env 文件:

JIMENG_ACCESS_KEY=your_access_key_here
JIMENG_SECRET_KEY=your_secret_key_here

# 可选配置
JIMENG_ENDPOINT=https://visual.volcengineapi.com
JIMENG_REGION=cn-north-1
JIMENG_SERVICE=cv
# 日志配置
ES_ENDPOINT=https://your-es-cluster:9200/logs/_doc

配置说明

  • 必需配置

    • JIMENG_ACCESS_KEY: 火山引擎访问密钥ID
    • JIMENG_SECRET_KEY: 火山引擎访问密钥密码
  • 可选配置

    • JIMENG_ENDPOINT: API端点,默认使用官方端点
    • JIMENG_REGION: 区域,默认cn-north-1
    • JIMENG_SERVICE: 服务名,默认cv
    • ES_ENDPOINT: Elasticsearch日志端点,用于集中化日志管理

使用方法

🖼️ 本地文件支持

图生图工具现在支持多种图片输入方式:

本地文件路径:

  • 相对路径:./image.jpg, ../images/photo.png
  • 绝对路径:/Users/username/Pictures/image.jpg
  • 文件协议:file:///path/to/image.jpg

远程URL:

  • HTTP/HTTPS链接:https://example.com/image.jpg

自动处理:

  • 本地文件会自动读取并转换为base64编码
  • 远程URL会直接传递给API
  • 支持混合输入(同时使用本地文件和远程URL)

在 Cursor 中配置

在 Cursor 的设置中添加以下 MCP 服务器配置:

{
  "mcpServers": {
    "jimeng": {
      "command": "npx",
      "args": ["jimeng-image-mcp@latest", "serve"],
      "env": {
        "JIMENG_ACCESS_KEY": "your_access_key_here",
        "JIMENG_SECRET_KEY": "your_secret_key_here"
      }
    }
  }
}

作为 MCP 服务器运行

# 构建项目
npm run build

# 运行 MCP 服务器
npm start

在代码中使用

import { JimengMCPServer } from 'jimeng-image-mcp';

const server = new JimengMCPServer({
  accessKey: process.env.JIMENG_ACCESS_KEY!,
  secretKey: process.env.JIMENG_SECRET_KEY!,
  endpoint: process.env.JIMENG_ENDPOINT,
  esEndpoint: process.env.ES_ENDPOINT, // 可选:Elasticsearch日志端点
});

// 启动服务器
await server.run();

CLI 工具

# 安装 CLI 工具
npm install -g jimeng-image-mcp

# 使用 CLI
jimeng-image-mcp --help
jimeng-image-mcp serve  # 启动MCP服务器
jimeng-image-mcp serve --es-endpoint https://your-es:9200/logs/_doc  # 指定ES端点
jimeng-image-mcp test   # 测试配置

MCP 协议支持

本服务器完全支持 MCP 协议规范,包括:

  • ✅ 工具调用 (Tools) - 支持所有即梦API功能
  • ✅ 资源管理 (Resources) - 配置信息和任务状态
  • ✅ 并发控制 - 防止API调用冲突
  • ✅ 错误处理 - 完整的错误捕获和报告
  • ✅ 类型安全 - TypeScript + Zod 验证
  • ✅ 标准传输 - 支持 stdio 和 HTTP 传输

支持的传输方式

  • stdio - 命令行工具和本地集成
  • HTTP - 远程服务器部署(需要额外配置)

工具调用示例

// 生成图像
const result = await client.callTool({
  name: 'text_to_image',
  arguments: {
    prompt: '一只可爱的小猫',
    width: 1024,
    height: 1024,
    use_pre_llm: true,
  },
});

// 图生图(支持绝对路径、文件协议和远程URL,不支持相对路径)
const i2iResult = await client.callTool({
  name: 'image_to_image',
  arguments: {
    prompt: '将小猫变成小狗',
    image_urls: [
      '/path/to/local-cat.jpg', // 绝对路径
      'file:///path/to/another-cat.png', // 文件协议
      'https://example.com/cat.jpg', // 远程URL
    ],
    scale: 0.8,
  },
});

// 查询任务状态
const status = await client.callTool({
  name: 'query_task',
  arguments: {
    task_id: 'task_123',
  },
});

资源访问示例

// 获取配置信息
const config = await client.readResource({
  uri: 'config://jimeng',
});

// 获取任务状态
const taskStatus = await client.readResource({
  uri: 'task://task_123/status',
});

开发

构建

npm run build

开发模式

npm run dev

代码质量

# 检查代码格式
npm run lint:check
npm run format:check

# 自动修复代码格式
npm run lint:fix

# 单独运行
npm run lint        # ESLint 检查并修复
npm run format      # Prettier 格式化

测试

# 运行所有测试
npm test

# 运行特定测试
npm run test:api
npm run test:local
npm run test:cli

技术架构

  • MCP SDK: @modelcontextprotocol/sdk v1.17.3+
  • 类型安全: TypeScript + Zod 验证
  • 并发控制: 队列式任务处理
  • 错误处理: 完整的错误捕获和报告

依赖要求

  • Node.js >= 20.0.0
  • TypeScript >= 5.0.0

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

相关链接