RelayOne Image MCP
Enables image generation and editing through RelayOne API, supporting both Image2 and Gemini Banana providers with configurable models and reference images.
README
RelayOne Image MCP
这是 RelayOne Image 的 MCP 接入包,同时支持 Image2 和 Gemini Banana 两条生图路线。每个使用者只需要配置一个 RelayOne API Key。
两种生图 Provider
| Provider | 协议 | 默认模型 | 适合场景 |
|---|---|---|---|
image2 |
OpenAI Images /v1/images/generations |
gpt-image-2 |
精确像素尺寸、Image2 生图 |
banana |
Gemini v1beta generateContent |
gemini-3.1-flash-image |
Banana 文生图、最多 14 张参考图改图 |
Banana 还支持 gemini-3-pro-image。它的 imageSize 是 512、1K、2K、4K 清晰度档位,aspectRatio 控制比例;它不是 Image2 的固定 宽x高 尺寸协议。
支持的模型
Image2
| 模型 | 文生图 | 图生图 | 说明 |
|---|---|---|---|
gpt-image-2 |
支持 | 支持 | 基础模型,支持固定像素尺寸 |
gpt-image-2-low |
支持 | 支持 | low 质量档,需对应分组已启用 |
gpt-image-2-medium |
支持 | 支持 | medium 质量档,需对应分组已启用 |
gpt-image-2-high |
支持 | 支持 | high 质量档,需对应分组已启用 |
Gemini Banana
| 模型 | 文生图 | 图生图/改图 | 说明 |
|---|---|---|---|
gemini-3.1-flash-image |
支持 | 支持 | 默认,速度优先、成本较低,最多 14 张参考图 |
gemini-3-pro-image |
支持 | 支持 | 质量优先,最多 14 张参考图 |
gemini-3-pro-image-preview 会归一化为 gemini-3-pro-image,是别名而不是第三个独立模型。Banana 两个模型的文生图和图生图都调用同一个 generateContent 接口;是否携带 reference_images 决定是文生图还是图生图。
选择 Provider 后,MCP 会自动选择协议:
image2没有reference_images时调用/v1/images/generationsJSON;有参考图时调用/v1/images/editsmultipart,并以image[]上传参考图。banana始终调用/v1beta/models/{model}:generateContent;参考图会转换成contents[].parts[].inlineData,不是 multipart,也不是 OpenAI Images JSON。
站点需要填写的内容
config/providers.json已配置 RelayOne 地址、模型和 Images 路径;如需切换站点再修改它。- 每个 agent 将
.env.example复制为.env,并只填写SITE_IMAGE_API_KEY;不要把 Key 写入工具参数。 - 如需代理,在运行 MCP 的机器上额外设置
SITE_IMAGE_PROXY_URL,这是可选项。 - 如果站点不是 Bearer 鉴权或不是 OpenAI-compatible 请求格式,在
src/index.ts的callProvider和请求 schema 中改适配逻辑。 - 执行
npm install、npm run build,再将dist/index.js注册到 MCP 客户端。
.env 会在 MCP 启动时自动读取,因此 agent 不需要改启动命令。
MCP 注册示例
把 mcp-server.example.json 中的 PACKAGE_DIRECTORY 替换为当前包目录,再按所用 MCP 客户端的配置格式注册。.env 和 dist/index.js 必须与该目录保持同级。
工具
list_image_providers:显示本地配置的渠道,不显示密钥。list_remote_image_models:读取实时模型清单,不生图。get_image_capabilities:查看站长填写的参数能力。get_image_usage:读取可选的用量接口,不生图。prepare_image_request:预览实际 JSON,不联网。generate_image:调用前必须提供本地绝对路径save_directory。工具会保留完整原始响应 JSON(包括url和b64_json),并将图片保存到该目录,同时返回 MCPimage内容。
每次调用自定义参数
标准字段直接传入,站点专属字段放入 custom_parameters。例如:
{
"prompt": "一座雨夜城市",
"size": "1024x1024",
"custom_parameters": {
"steps": 30,
"guidance_scale": 7,
"seed": 12345,
"negative_prompt": "模糊、低清晰度"
}
}
custom_parameters 会合并到本次请求 JSON;provider、model、prompt、custom_parameters 以及已传入的标准字段不能被覆盖。
安全约束
- 真实密钥只放进启动环境,不写入
providers.json、代码、日志或 MCP 工具参数。 save_directory必须由用户在每次生图前明确选择,MCP 不自行决定保存位置。- 保存目录中会生成一个
.response.json原始响应文件,以及按序号命名的图片文件。 - URL 图片下载仅允许 HTTP(S),并限制为 25 MB;下载失败时原始 URL 仍保留在
.response.json。 - 请求和响应不会打印 Authorization 头。
advanced任意透传没有加入模板;站长应根据自己的接口逐项加入白名单字段。
Codex 注册
在 Codex 的 MCP 配置中注册 node dist/index.js,并通过配置的环境变量传入 RelayOne Key。不要把真实值放进示例文件或发给第三方。
项目地址:https://github.com/linshiqiyyds/relayone-image-mcp
生图调用示例
调用 generate_image 时必须先选择保存目录,例如:
{
"prompt": "一只橘猫坐在窗边,电影感,自然光",
"size": "1024x1024",
"response_format": "b64_json",
"save_directory": "D:\\RelayOne-MCP\\generated"
}
如果选择 response_format: "url",MCP 会下载 URL 对应图片;如果选择 b64_json,MCP 会解码 Base64。两种原始字段都会原样保存在 .response.json 文件中。
Image2 示例
{
"provider": "image2",
"model": "gpt-image-2",
"prompt": "一张产品摄影图",
"size": "2048x1152",
"response_format": "url",
"save_directory": "D:\\RelayOne-MCP\\generated"
}
Image2 图生图只需增加本地参考图路径,MCP 会自动切换到 /v1/images/edits:
{
"provider": "image2",
"model": "gpt-image-2",
"prompt": "保留主体,把背景改成夜晚城市",
"reference_images": ["D:\\References\\product.png"],
"size": "2048x1152",
"save_directory": "D:\\RelayOne-MCP\\generated"
}
Banana 示例
{
"provider": "banana",
"model": "gemini-3.1-flash-image",
"prompt": "把产品放在夜晚城市街道中",
"aspectRatio": "16:9",
"imageSize": "2K",
"reference_images": [
"D:\\References\\product.png"
],
"save_directory": "D:\\RelayOne-MCP\\generated"
}
Banana 的参考图会读取为纯 Base64,并按 Gemini 原生协议放入 contents[].parts[].inlineData。最多 14 张,每张最大 20 MB,支持 PNG、JPEG、WebP。Banana 的模型不使用 gpt-image-2,也不使用 Image2 的固定像素 size 字段。
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.