返回市场
图像生成MCP服务器

图像生成MCP服务器

作者:GongRzhe45 星标更新:2025-04-16

项目介绍

图像生成MCP服务器

smithery徽章

此MCP服务器使用Replicate Flux模型提供图像生成功能。

安装

通过Smithery安装

要通过Smithery自动安装Image Generation MCP Server到Claude Desktop:

npx -y @smithery/cli install @GongRzhe/Image-Generation-MCP-Server --client claude

方法1:NPX方法(无需本地设置)

您可以直接从npm使用该包,而无需本地安装:

# 不需要安装 - npx会处理它

方法2:本地安装

如果您希望进行本地安装:

# 全局安装
npm install -g @gongrzhe/image-gen-server

# 或者本地安装
npm install @gongrzhe/image-gen-server

配置

配置Claude Desktop

编辑您的Claude Desktop配置文件:

  • 在MacOS上:~/Library/Application Support/Claude/claude_desktop_config.json
  • 在Windows上:%APPDATA%/Claude/claude_desktop_config.json

方法1:NPX配置(推荐)

此方法直接从npm运行服务器,无需本地文件:

{
  "mcpServers": {
    "image-gen": {
      "command": "npx",
      "args": ["@gongrzhe/image-gen-server"],
      "env": {
        "REPLICATE_API_TOKEN": "your-replicate-api-token",
        "MODEL": "alternative-model-name"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

方法2:本地安装配置

如果您已进行了本地安装:

{
  "mcpServers": {
    "image-gen": {
      "command": "node",
      "args": ["/path/to/image-gen-server/build/index.js"],
      "env": {
        "REPLICATE_API_TOKEN": "your-replicate-api-token",
        "MODEL": "alternative-model-name"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

获取您的Replicate API令牌

  1. 登录或注册 https://replicate.com
  2. 转到 https://replicate.com/account/api-tokens
  3. 创建一个新的API令牌
  4. 复制令牌并替换MCP设置中的your-replicate-api-token

image

环境变量

  • REPLICATE_API_TOKEN(必需):用于身份验证的Replicate API令牌
  • MODEL(可选):用于图像生成的Replicate模型。默认为"black-forest-labs/flux-schnell"

配置参数

  • disabled:控制服务器是否启用(false)或禁用(true
  • autoApprove:可以无用户确认执行的工具名称数组。空数组意味着所有工具调用都需要确认。

可用工具

generate_image

基于文本提示使用Flux模型生成图像。

image

out-0 (1)

参数

  • prompt(必需):要生成的图像的文字描述
  • seed(可选):用于可重复生成的随机种子
  • aspect_ratio(可选):图像宽高比(默认:"1:1")
  • output_format(可选):输出格式 - "webp"、"jpg"或"png"(默认:"webp")
  • num_outputs(可选):要生成的图像数量(1-4,默认:1)

示例用法

const result = await use_mcp_tool({
  server_name: "image-gen",
  tool_name: "generate_image",
  arguments: {
    prompt: "一座美丽的落日山脉",
    aspect_ratio: "16:9",
    output_format: "png",
    num_outputs: 1
  }
});

该工具返回一个包含生成图像URL的数组。

📜 许可证

本项目采用MIT许可证。