这是一个模型上下文协议(MCP)服务器,通过 Together AI 使用 Flux.1 Schnell 模型无缝生成高质量图像。此服务器提供了一个标准化的接口来指定图像生成参数。
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
此工具只有一个必需的参数 - 提示。所有其他参数都是可选的,如果未提供,则使用合理的默认值。
{
// 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 并且保存成功,响应将包括保存位置的确认。
如果请求中未指定,将使用以下默认值:
prompt
参数是必需的{
"@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 检查器欢迎贡献!请遵循以下步骤:
feature/my-new-feature
)功能请求和错误报告可以通过 GitHub Issues 提交。在创建新问题之前,请先检查是否已存在相关问题。
对于重大更改,请先打开一个问题来讨论您提议的更改。
本项目根据 MIT 许可证获得许可。详情请参阅 LICENSE 文件。