一起AI图像服务添加福利群:解决AI开发者的「MCP实战痛点」English | 简体中文
这是一个基于 TypeScript 的 MCP(Model Context Protocol)服务器,用于通过 Together AI API 生成图像。
该服务器通过 MCP 协议提供了一个简单的接口,使用 Together AI 的图像生成模型来生成图像。它允许 Claude 和其他兼容 MCP 的助手根据文本提示生成图像。
generate_image - 根据文本提示生成图像
# Clone the repository
git clone https://github.com/zym9863/together-ai-image-server.git
cd together-ai-image-server
# Install dependencies
npm install

将你的 Together AI API 密钥设置为环境变量:
# On Linux/macOS
export TOGETHER_API_KEY="your-api-key-here"
# On Windows (Command Prompt)
set TOGETHER_API_KEY=your-api-key-here
# On Windows (PowerShell)
$env:TOGETHER_API_KEY="your-api-key-here"

或者,你可以在项目根目录中创建一个 .env 文件:
TOGETHER_API_KEY=your-api-key-here
构建服务器:
npm run build
对于带有自动重建功能的开发:
npm run watch
要与 Claude Desktop 一起使用,请添加服务器配置:
在 macOS 上: ~/Library/Application Support/Claude/claude_desktop_config.json
在 Windows 上: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"Together AI Image Server": {
"command": "/path/to/together-ai-image-server/build/index.js"
}
}
}

将 /path/to/together-ai-image-server 替换为你实际的安装路径。
由于 MCP 服务器通过 stdio 进行通信,调试可能会比较困难。我们建议使用 MCP Inspector,它作为一个包脚本提供:
npm run inspector
Inspector 将提供一个 URL,以便你在浏览器中访问调试工具。
使用 Together AI 的图像生成 API 根据文本提示生成图像。
参数:
prompt (字符串, 必需): 用于图像生成的文本提示steps (数字, 可选, 默认值: 4): 扩散步骤数 (1-4)n (数字, 可选, 默认值: 1): 生成的图像数量 (1-4)返回:
包含以下内容的 JSON 对象:
image_urls: 生成图像的 URL 数组local_paths: 本地缓存图像的路径数组MIT
欢迎贡献!请随时提交 Pull Request。