Skip to main content
Glama
manascb1344

Image Generation MCP Server

by manascb1344

图像生成 MCP 服务器

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

询问 DeepWiki

特征

  • 由 Flux.1 Schnell 模型提供支持的高质量图像生成

  • 支持自定义尺寸(宽度和高度)

  • 清除提示验证和 API 问题的错误处理

  • 轻松与 MCP 兼容客户端集成

  • 可选将图像以 PNG 格式保存到磁盘

Related MCP server: Image Generation MCP Server

安装

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 并且保存成功,则响应将包括保存位置的确认。

默认值

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

  • 型号:“black-forest-labs/FLUX.1-schnell-Free”

  • 宽度:1024

  • 高度:768

  • 步骤:1

  • n:1

  • 响应格式:“b64_json”

重要说明

  1. 仅需要prompt参数

  2. 如果未提供,所有可选参数均使用默认值

  3. 提供时,参数必须满足其约束(例如宽度/高度范围)

  4. Base64 响应可能很大 - 对于较大的图像请使用 URL 格式

  5. 保存图像时,确保指定的目录存在且可写

先决条件

  • Node.js >= 16

  • Together AI API 密钥

    1. 登录api.together.xyz

    2. 导航至API 密钥设置

    3. 点击“创建”生成新的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. 分叉存储库

  2. 创建新分支 ( feature/my-new-feature )

  3. 提交你的更改

  4. 将树枝推到你的叉子上

  5. 打开拉取请求

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

对于重大更改,请先打开问题来讨论您提议的更改。

执照

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

Install Server
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/manascb1344/together-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server