返回市场
一起-MCP服务器

一起-MCP服务器

作者:manascb13449 星标更新:2025-05-23

项目介绍

图像生成MCP服务器

这是一个使用Flux.1 Schnell模型通过Together AI无缝生成高质量图像的Model Context Protocol (MCP)服务器。该服务器提供了一个标准化接口来指定图像生成参数。

<div align="center">

Ask DeepWiki

</div> <div align="center"> <a href="https://glama.ai/mcp/servers/y6qfizhsja"> <img width="380" height="200" src="https://gips3.baidu.com/it/u=1307155663,373769729&fm=3081&app=3081&f=PNG?w=760&h=400" alt="图像生成服务器MCP服务器" /> </a> </div>

特性

  • 使用Flux.1 Schnell模型生成高质量图像
  • 支持自定义尺寸(宽度和高度)
  • 清晰的错误处理,包括提示验证和API问题
  • 易于与兼容MCP的客户端集成
  • 可选地将生成的图像以PNG格式保存到磁盘

安装

npm install together-mcp

或者直接运行:

npx together-mcp@latest

配置

在您的MCP服务器配置中添加以下内容:

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

使用方法

服务器提供一个工具:generate_image

使用generate_image

此工具只有一个必需参数 - 提示。所有其他参数都是可选的,并且如果没有提供,则使用合理的默认值。

参数

{
  // 必需
  prompt: string;          // 要生成的图像的文字描述

  // 可选,默认值
  model?: string;          // 默认:"black-forest-labs/FLUX.1-schnell-Free"
  width?: number;          // 默认:1024(最小:128,最大:2048)
  height?: number;         // 默认:768(最小:128,最大:2048)
  steps?: number;          // 默认:1(最小:1,最大:100)
  n?: number;             // 默认:1(最大:4)
  response_format?: string; // 默认:"b64_json"(选项:["b64_json", "url"])
  image_path?: string;     // 可选:保存生成图像的路径,格式为PNG
}

最小请求示例

只需提供提示:

{
  "name": "generate_image",
  "arguments": {
    "prompt": "日落时宁静的山景"
  }
}

包含图像保存的完整请求示例

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

{
  "name": "generate_image",
  "arguments": {
    "prompt": "日落时宁静的山景",
    "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,        // 生成ID
  "model": string,     // 使用的模型
  "object": "list",
  "data": [
    {
      "timings": {
        "inference": number  // 推理所用时间
      },
      "index": number,      // 图像索引
      "b64_json": string    // Base64编码的图像数据(如果response_format是"b64_json")
      // 或者
      "url": string        // 生成图像的URL(如果response_format是"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. 点击“创建”以生成新的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. 打开Pull Request

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

对于重大变更,请先打开一个问题以讨论您提议的变更。

许可证

该项目根据MIT许可证发布。详情见LICENSE文件。