mcpField
I
Image Generation MCP Server

Image Generation MCP Server

本地服务
pulsemcp.com媒体与设计1077 周前更新

关于 Image Generation MCP Server

Image Generation MCP Server 将 Together AI 的 Flux.1 Schnell 图像生成功能提供给 MCP 客户端。它接收文本提示词,支持调整图像尺寸,并可选择将 PNG 文件保存到磁盘。

主要功能

  1. 01根据提示词生成图像
  2. 02设置图像宽度和高度
  3. 03将图像保存为 PNG
  4. 04验证提示词并报告 API 错误

适用场景

  1. 01根据文本描述生成图像
  2. 02为请求调整输出尺寸
  3. 03将生成的图像保存到磁盘

MCP 相关

它向 MCP 客户端提供 `generate_image` 工具,支持提示词、模型、尺寸及其他可选参数。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"together": {
"command": "npx",
"args": [
"-y",
"together-mcp"
]
}
}
}
启动命令npx -y together-mcp

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npmtogether-mcp

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

图像生成 MCP 服务

一个模型上下文协议(MCP)服务,可通过 Together AI 使用 Flux.1 Schnell 模型,无缝生成高质量图像。此服务提供了一个标准化接口,用于指定图像生成参数。

Ask DeepWiki

功能

  • 由 Flux.1 Schnell 模型驱动的高质量图像生成
  • 支持自定义尺寸(宽度和高度)
  • 清晰处理提示词验证和 API 问题相关错误
  • 轻松集成兼容 MCP 的客户端
  • 可选将图像以 PNG 格式保存到磁盘

安装

npm install together-mcp

或直接运行:

npx together-mcp@latest
配置

添加到 MCP 服务配置中:

配置示例
{
  "mcpServers": {
    "together-image-gen": {
      "command": "npx",
      "args": ["together-mcp@latest -y"],
      "env": {
        "TOGETHER_API_KEY": "<API KEY>"
      }
    }
  }
}

用法

此服务提供一个工具:generate_image

使用 generate_image

此工具只有一个必需参数——提示词。其他所有参数均为可选参数;如果未提供,则使用合理的默认值。

参数
{
  // Required
  prompt: string;          // Text description of the image to generate

  // Optional with defaults
  model?: string;          // Default: "black-forest-labs/FLUX.1-schnell-Free"
  width?: number;          // Default: 1024 (min: 128, max: 2048)
  height?: number;         // Default: 768 (min: 128, max: 2048)
  steps?: number;          // Default: 1 (min: 1, max: 100)
  n?: number;             // Default: 1 (max: 4)
  response_format?: string; // Default: "b64_json" (options: ["b64_json", "url"])
  image_path?: string;     // Optional: Path to save the generated image as PNG
}
最简请求示例

只需提供提示词:

{
  "name": "generate_image",
  "arguments": {
    "prompt": "A serene mountain landscape at sunset"
  }
}
保存图像的完整请求示例

覆盖任意默认值,并指定保存图像的路径:

{
  "name": "generate_image",
  "arguments": {
    "prompt": "A serene mountain landscape at sunset",
    "width": 1024,
    "height": 768,
    "steps": 20,
    "n": 1,
    "response_format": "b64_json",
    "model": "black-forest-labs/FLUX.1-schnell-Free",
    "image_path": "/path/to/save/image.png"
  }
}
响应格式

响应将是一个 JSON 对象,包含:

{
  "id": string,        // Generation ID
  "model": string,     // Model used
  "object": "list",
  "data": [
    {
      "timings": {
        "inference": number  // Time taken for inference
      },
      "index": number,      // Image index
      "b64_json": string    // Base64 encoded image data (if response_format is "b64_json")
      // OR
      "url": string        // URL to generated image (if response_format is "url")
    }
  ]
}

如果提供了 image_path 且保存成功,响应将包含保存位置的确认信息。

默认值

如果请求中未指定,则使用以下默认值:

  • model: "black-forest-labs/FLUX.1-schnell-Free"
  • width: 1024
  • height: 768
  • steps: 1
  • n: 1
  • response_format: "b64_json"
重要说明
  1. 只有 prompt 参数是必需的
  2. 如果未提供所有可选参数,则使用默认值
  3. 提供参数时,必须符合相应限制(例如,宽度/高度范围)
  4. Base64 响应可能很大;对于较大的图像,请使用 URL 格式
  5. 保存图像时,请确保指定目录存在且可写

前提条件

  • Node.js >= 16
  • Together AI API 密钥
    1. 在 api.together.xyz 注册
    2. 前往 API 密钥设置
    3. 点击“Create”生成新的 API 密钥
    4. 复制生成的密钥,以便在 MCP 配置中使用

依赖项

{
  "@modelcontextprotocol/sdk": "0.6.0",
  "axios": "^1.6.7"
}

开发

克隆并构建项目:

git clone https://github.com/manascb1344/together-mcp-server
cd together-mcp-server
npm install
npm run build
可用脚本
  • npm run build - 构建 TypeScript 项目
  • npm run watch - 监视更改并重新构建
  • npm run inspector - 运行 MCP 检查器

贡献

欢迎贡献!请按以下步骤操作:

  1. Fork 此仓库
  2. 创建新分支(feature/my-new-feature)
  3. 提交更改
  4. 将分支推送到你的 Fork
  5. 创建 Pull Request

可以通过 GitHub Issues 提交功能请求和错误报告。创建新问题前,请先检查现有问题。

对于重大更改,请先创建一个 Issue,讨论你计划进行的更改。

许可证

本项目采用 MIT 许可证。详情请参阅 LICENSE 文件。

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。