Back to MCP directory
publicPublicdnsLocal runtime

mcp-imagegen

MCP图像生成器是一个基于Together AI或Replicate的图像生成服务,支持通过SSE端点或本地运行,提供根据文本提示生成图像的功能。

article

README

🚀 MCP 图像生成器

MCP 图像生成器是一个模型上下文协议(MCP)服务器,可借助 Together AI 的图像生成模型来生成图像。该服务器既支持在本地运行,也能通过 SSE 端点运行,为用户提供了灵活的使用方式。

🚀 快速开始

SSE 端点(Docker 环境)

克隆仓库

git clone https://github.com/gmkr/mcp-imagegen.git
cd mcp-imagegen

构建并运行 Docker 容器

docker build -f Dockerfile.server -t mcp-imagegen .
docker run -p 3000:3000 mcp-imagegen

使用 MCP 客户端配置

{
  "mcpServers": {
    "imagegenerator": {
      "url": "http://localhost:3000/sse",
      "env": {
        "PROVIDER": "replicate",
        "REPLICATE_API_TOKEN": "your-replicate-api-token"
      }
    }
  }
}

请将 url 调整为你实际使用的 MCP 服务器端点。提供商可选择“replicate”或“together”。

使用本地环境(基于标准输入输出)

先决条件

  • Node.js
  • Together AI API 密钥或 Replicate API 访问令牌

安装依赖项

git clone https://github.com/gmkr/mcp-imagegen.git
cd mcp-imagegen
pnpm install

配置

创建一个用于你的 MCP 客户端的配置文件,示例如下:

{
  "mcpServers": {
    "imagegenerator": {
      "command": "pnpx",
      "args": [
        "-y",
        "tsx",
        "/path/to/mcp-imagegen/src/index.ts"
      ],
      "env": {
        "PROVIDER": "replicate",
        "REPLICATE_API_TOKEN": "your-replicate-api-token"
      }
    }
  }
}

请将 /path/to/mcp-imagegen 替换为你克隆仓库的实际路径,并将 your-replicate-api-token 替换为你的实际 Replicate API 访问令牌。

✨ 主要特性

  • 支持本地和 SSE 端点两种运行方式,使用灵活。
  • 提供 generate_image 工具,方便根据文本提示生成图像。

💻 使用示例

工具:generate_image

此工具可根据提供的提示生成图像。

参数:

  • prompt (字符串):用于生成图像的文本提示
  • width (数字,可选):生成图像的宽度(默认:512)
  • height (数字,可选):生成图像的高度(默认:512)
  • numberOfImages (数字,可选):要生成的图像数量(默认:1)

📦 安装指南

MCP 图像生成器需要指定一个提供商,当前仅支持“Replicate”和“Together”。你需要设置 TOGETHER_API_KEYREPLICATE_API_TOKEN 环境变量,并将 PROVIDER 环境变量设为“replicate”或“together”。

📚 详细文档

环境变量

| 属性 | 详情 | |------|------| | PROVIDER | 用于图像生成的提供商(默认:“replicate”) | | REPLICATE_API_TOKEN | 你的 Replicate API 访问令牌 | | TOGETHER_API_KEY | 你的 Together AI API 密钥 | | MODEL_NAME | 用于图像生成的模型名称(默认:“black-forest-labs/flux-schnell”) |

📄 许可证

本项目采用 MIT 授权协议。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client