MetaRouter Image MCP
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MetaRouter Image MCPGenerate a photorealistic image of a futuristic silver router levitating in a white studio"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MetaRouter Media MCP
把 MetaRouter 的生图接口和 HappyHorse 视频接口接入 Codex 或其他支持 MCP 的客户端。安装后,你可以直接用自然语言让 Codex 生成、编辑图片,也可以提交文生视频、图生视频、参考图生视频和视频编辑任务。
这个项目从零实现,服务地址固定为 https://metarouters.org,不会把 API Key 发送到用户指定的第三方地址。
支持的工具
MCP 工具 | 用途 |
| 文生图,一次生成 1–4 张图片 |
| 根据提示词编辑一张本地图片 |
| 对多张本地图片逐张执行同一种编辑 |
| 以 2–10 张图片作为同一次生成的参考图 |
| 提交 HappyHorse 文生视频、图生视频、参考图生视频或视频编辑任务 |
| 查询任务;可轮询等待完成并安全下载 MP4 |
| 下载已完成任务返回的受信任 HTTPS 视频 URL |
| 查看当前模型、保存目录和安全设置,不返回密钥 |
默认模型是 gpt-image-2。当尺寸达到约 4K 时会自动选择 gpt-image-2-pro,也可以在调用时显式指定模型。
HappyHorse 支持 happyhorse-1.0-t2v、happyhorse-1.0-i2v、happyhorse-1.0-r2v 和 happyhorse-1.0-video-edit。除纯文生视频外,上游当前要求素材使用公网 HTTPS URL,不接受本地路径或 Base64。
Related MCP server: imagegen-mcp
快速安装到 Codex
要求:
Python 3.10 或更高版本
已安装 Codex 桌面端或 Codex CLI
一个可用的 MetaRouter API Key
克隆仓库并运行安装器:
git clone https://github.com/cimicimi9090/mcp-pic-metarouters.git
cd mcp-pic-metarouters
python install.py安装器会:
隐藏输入 API Key;
调用
https://metarouters.org/v1/models验证密钥及图片/视频模型;安装 Python 依赖;
备份并更新
~/.codex/config.toml;将图片和视频默认保存到
~/Pictures/MetaRouter。
安装完成后重启 Codex。先尝试:
调用 metarouter-image 的 server_info然后可以直接说:
调用 image_generate,生成一张 1536x1024 的写实产品图:
白色摄影棚里悬浮着一台银色未来主义路由器,柔和轮廓光,高级商业摄影。也可以直接说:
调用 video_generate,使用 happyhorse-1.0-t2v 生成 5 秒、720P、16:9 的视频:
澳门雨夜,一辆未来主义电动跑车驶过霓虹街道,电影级运镜。
提交后继续调用 video_status,wait=true,等待完成。Codex 手动配置
不使用安装器时,可以先安装当前项目:
python -m pip install -e .然后在 ~/.codex/config.toml 中添加以下配置。请把路径和密钥替换为你自己的值:
[mcp_servers.metarouter-image]
command = "C:/Path/To/python.exe"
args = ["D:/Path/To/mcp-pic-metarouters/server.py"]
startup_timeout_sec = 30
tool_timeout_sec = 900
[mcp_servers.metarouter-image.env]
METAROUTER_API_KEY = "sk-your-metarouter-key"
METAROUTER_IMAGE_MODEL = "gpt-image-2"
METAROUTER_IMAGE_PRO_MODEL = "gpt-image-2-pro"
METAROUTER_VIDEO_MODEL = "happyhorse-1.0-t2v"
METAROUTER_SAVE_DIR = "C:/Users/you/Pictures/MetaRouter"
METAROUTER_SAVE_DIR_ROOT = "C:/Users/you/Pictures/MetaRouter"
METAROUTER_TRUSTED_VIDEO_HOSTS = "metarouters.org"使用示例
文生图:
调用 image_generate:
- prompt:一张极简蓝紫渐变的 SaaS 产品封面,中心是抽象字母 M,干净留白
- size:1024x1024
- n:1编辑本地图片:
调用 image_edit:
- image_path:C:/Users/you/Pictures/source.png
- prompt:保留主体构图,把背景改成夜晚的东京街头,增加自然霓虹反光
- size:1536x1024多参考图:
调用 image_multi_reference:
- image_paths:两到十张本地 PNG、JPEG 或 WebP 文件
- prompt:使用第一张的构图、第二张的配色和第三张的材质,生成统一的新设计
- size:2048x2048工具返回生成文件的绝对路径,Codex 可以继续读取、展示或交给后续流程处理。
文生视频:
调用 video_generate:
- model:happyhorse-1.0-t2v
- prompt:无人机穿越未来城市峡谷,日落金色逆光,连续电影镜头
- duration:5
- resolution:720P
- ratio:16:9提交后把返回的 task_id 交给 video_status。设置 wait=true 可持续轮询,设置 download=true 可在完成后下载。图生视频使用 happyhorse-1.0-i2v 并传入一个 image_url;参考图生视频使用 happyhorse-1.0-r2v 并传入 1–9 个 reference_image_urls;视频编辑使用 happyhorse-1.0-video-edit 并传入 video_url。
若结果视频的域名不在信任列表中,先确认它确实属于 MetaRouter/上游视频 CDN,再把该域名加入 METAROUTER_TRUSTED_VIDEO_HOSTS 并重启 Codex。不要使用通配符。
环境变量
变量 | 默认值 | 说明 |
| 无 | 必填,MetaRouter API Key |
|
| 常规生图模型 |
|
| 大尺寸自动使用的模型 |
|
| 默认 HappyHorse 视频模型 |
|
| 请求超时秒数,最小 30 秒 |
|
| MCP 允许写入的根目录 |
| 与根目录相同 | 默认输出目录,必须位于根目录内 |
| 不限制 | 可选;设置后只允许读取该目录内的参考图片 |
|
| 单张本地输入图片的大小上限 |
|
| 单个视频的本地下载大小上限 |
|
| 允许下载结果图片的 HTTPS 域名,逗号分隔 |
|
| 允许下载结果视频的 HTTPS 域名,逗号分隔 |
尺寸与计费提醒
尺寸格式是
宽x高,范围为 256–4096,宽和高都必须是 8 的倍数。image_batch_edit会为每张输入图片分别发起一次接口调用,因此每张都会独立计费。image_multi_reference会把多张参考图放进同一次编辑请求,是否支持以及具体限制取决于所选上游模型。HappyHorse 是异步任务:
video_generate只提交任务,实际完成情况使用video_status查询。video_status(wait=true)最长等待 900 秒;超时不会取消任务,可稍后继续查询同一个task_id。视频时长目前为 3–15 秒,分辨率为 720P 或 1080P;具体可用组合以控制台为准。
最终可用模型、质量参数、速率限制和计费以 MetaRouter 控制台为准。
安全设计
API 网关在代码中固定为
https://metarouters.org,MCP 参数不能覆盖它。只接受 PNG、JPEG 和 WebP 本地输入,并限制单文件大小。
默认只能把生成结果写入
METAROUTER_SAVE_DIR_ROOT内部。远程结果只允许从 HTTPS 及受信任域名下载,减少 SSRF 风险。
视频 CDN 下载使用独立、无 Authorization 的客户端,不会把 MetaRouter API Key 发给结果域名。
API 错误会截断和清理后再返回,不会主动输出 Authorization 请求头。
API Key 保存在本机 Codex 配置中。不要把真实密钥写进仓库、截图、Issue 或日志;如已公开,请立即在控制台撤销并重新生成。
卸载由安装器写入的 Codex 配置:
python install.py --reset开发与测试
python -m pip install -e ".[dev]"
python -m pytest测试不需要真实 API Key,也不会发起计费请求。
License
Available Tools
5 toolsimage_batch_editA
对多张本地图片逐张执行同一编辑指令,适合批量换背景或统一风格。
image_paths 最多 20 张;每张图片会产生一次独立的计费请求。
| Name | Required | Description | Default |
|---|---|---|---|
| size | No | 1024x1024 | |
| model | No | ||
| prompt | Yes | ||
| quality | No | ||
| output_dir | No | ||
| image_paths | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of disclosure. It discloses the 20-image limit and independent billing per image, which are important operational traits. However, it does not describe output behavior, whether input files are modified, or any permission requirements.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, front-loaded with purpose and then constraints. Every sentence earns its place, with no redundancy or fluff.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With no annotations and low schema coverage, the description should cover more ground. It includes key batch limits but omits explanations for most parameters and output handling, making it incomplete for a complex batch operation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It adds meaning to image_paths (max 20, per-image billing) but leaves prompt, size, model, quality, and output_dir unexplained. This is insufficient for a 6-parameter tool.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it executes the same edit instruction on multiple local images one by one, suitable for batch background replacement or uniform style. This specific verb+resource+scope distinguishes it from sibling tools like image_edit (single image) and image_generate.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It mentions suitability for batch background replacement or uniform style, providing clear context for when to use the tool. However, it does not explicitly name alternatives or state when not to use it.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
image_editA
使用一张本地参考图,通过 MetaRouter 改图或图生图。
Args: image_path: 本地 PNG、JPEG 或 WebP 文件的绝对路径。 prompt: 编辑要求,应明确哪些内容保留、删除或修改。 size: 输出尺寸 WxH,宽高须为 8 的倍数。 model: 可选模型;留空自动选择。 quality: 可选质量参数。 output_dir: 可选保存目录,必须位于安全输出根目录下。
| Name | Required | Description | Default |
|---|---|---|---|
| size | No | 1024x1024 | |
| model | No | ||
| prompt | Yes | ||
| quality | No | ||
| image_path | Yes | ||
| output_dir | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden of behavioral disclosure. It explains the purpose and parameters but does not mention side effects, permissions, whether the original file is modified, or how the output is delivered (e.g., saved to output_dir, returned as a URL, etc.). This is a significant gap for a mutation-like tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise: a one-sentence purpose followed by a structured Args list. Each parameter entry is necessary and informative, with no redundancy or filler. The format is front-loaded and easy to scan.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (6 parameters, no annotations), the description covers parameters well, but it omits behavioral details such as default output location, whether output_dir is required to save results, and error handling. The presence of an output schema partially mitigates the lack of return-value documentation, but overall completeness is only adequate.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, but the description compensates fully by explaining every parameter with specific constraints: absolute paths for image_path, prompt semantics for what to preserve/remove/modify, size must be multiples of 8, and output_dir must be within the safe root. This adds substantial meaning beyond the bare schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states that the tool uses a local reference image via MetaRouter to edit or perform image-to-image, specifying both the action and resource. This distinguishes it from siblings like image_generate (which likely generates from text) and image_batch_edit (which implies batch processing).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies that the tool should be used when a local reference image is available for editing, but it does not explicitly state when to use this tool versus alternatives or provide any exclusion criteria. No alternatives are named, leaving usage guidance mostly implicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
image_generateA
通过 MetaRouter 文生图。
Args: prompt: 图片描述,建议包含主体、构图、风格、光线以及禁止内容。 size: WxH,例如 1024x1024、1536x1024、2048x2048。宽高须为 8 的倍数。 model: 可选模型;留空默认 gpt-image-2,超大尺寸自动使用 gpt-image-2-pro。 n: 生成数量,1 到 4;高分辨率建议使用 1。 quality: 可选质量参数,留空使用后端默认。 output_dir: 可选保存目录,必须位于配置的安全输出根目录下。
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | ||
| size | No | 1024x1024 | |
| model | No | ||
| prompt | Yes | ||
| quality | No | ||
| output_dir | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden of behavioral disclosure. It explains defaults (gpt-image-2, quality), constraints (size multiples of 8, n 1-4), and automatic model switching for ultra-large sizes. However, it does not disclose whether the tool saves files, what the return value looks like, or potential side effects, leaving some behavioral transparency gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise and well-structured, with a one-sentence purpose followed by a bulleted list of argument explanations. Every sentence provides useful information without redundancy or waste.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (6 parameters, 1 required) and lack of annotations, the description covers all parameters, defaults, constraints, and usage recommendations. It also notes output safety. It does not mention explicit error conditions or prerequisites, but the output schema likely covers return values. Overall, it is quite complete for a generation tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has zero description coverage, so the description fully compensates by documenting all 6 parameters with detailed semantics: prompt (subject, composition, style, lighting, prohibited content), size (format and multiple-of-8 constraint), model (default and auto-upgrade), n (range and recommendation), quality (default), and output_dir (safety constraint). This is significantly more informative than the schema alone.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states '通过 MetaRouter 文生图' (generate images from text via MetaRouter), which is a specific verb+resource. It distinguishes from sibling tools like image_edit, image_batch_edit, and image_multi_reference by focusing on generation rather than editing or reference-based tasks.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context for when to use this tool: it is for text-to-image generation. It includes usage tips such as '高分辨率建议使用 1' and '超大尺寸自动使用 gpt-image-2-pro', which help with parameter choices. However, it does not explicitly mention alternatives or exclusions, such as when to use image_edit instead.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
image_multi_referenceA
融合 2 到 10 张本地参考图,生成一张新图。
prompt 中应写明每张参考图分别提供哪些构图、配色、人物或产品特征。
| Name | Required | Description | Default |
|---|---|---|---|
| size | No | 1024x1024 | |
| model | No | ||
| prompt | Yes | ||
| quality | No | ||
| output_dir | No | ||
| image_paths | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the transparency burden. It discloses the input limit (2-10) and that images are local, but does not mention output file handling, side effects, or any prerequisites. The prompt guidance implies behavioral expectations of the model, but important operational details are absent.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two concise sentences, front-loaded with the core function and followed by a focused prompt guidance tip. No redundant or filler content; every sentence adds value.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has 6 parameters and no annotations, the description is not fully complete. It covers the core behavior and offers prompt guidance, and the presence of an output schema reduces the need to explain return values. However, optional parameters and explicit usage exclusions are missing, leaving moderate gaps for an agent to invoke the tool optimally.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It partially explains the prompt parameter (must specify each reference image's contribution) and implies image_paths are local file paths. However, it ignores size, model, quality, and output_dir entirely, leaving these parameters undocumented and under-specified.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states a specific verb+resource: 'fuses 2 to 10 local reference images to generate a new image.' This explicitly differentiates it from sibling tools like image_generate (likely text-to-image) and image_edit (single-image editing), establishing a distinct multi-reference generation purpose.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It provides clear context: use when you have 2-10 local reference images to synthesize. It also gives explicit prompt-writing guidance ('describe which composition, color scheme, character, or product features each reference image provides'), which aids correct usage. However, it does not explicitly contrast with alternatives or state when not to use it.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
server_infoA
返回当前 MetaRouter MCP 的安全运行配置,不返回完整 API Key。
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the burden of behavioral disclosure. It adds an important safety-related trait: it does not return the full API key, which is a key transparency point. However, it does not explicitly state whether the operation is read-only or mention other behavioral traits like authentication requirements.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, front-loaded sentence that is concise and to the point. It conveys the core purpose and a key safety exclusion without any redundant content.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter tool with an output schema present, the description addresses the primary need (what is returned and what is not) and is complete for its simple scope. The presence of an output schema covers detailed return fields, so further description is unnecessary.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters, so the input schema fully covers them. The description adds no parameter specifics, which is unnecessary here. The baseline of 4 for no parameters is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's function: it returns the current MetaRouter MCP security runtime configuration, and explicitly notes what it does not return (full API key). This distinguishes it from the image-related sibling tools and provides a specific verb-resource pair.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no explicit statement about when to use this tool or when to avoid it. The sibling tools are all image-generation/edit tools, which implies server_info is for server-level queries, but the description does not say 'use when you need server configuration' or provide any exclusions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
5 tool updates
v0.1.0- First observed
image_batch_edit - First observed
image_edit - First observed
image_generate - First observed
image_multi_reference - First observed
server_info
TDQS
Scored across 5 tools
Each image tool has a distinct purpose: generation, single edit, batch edit, and multi-reference fusion. server_info is clearly separate as configuration info. No two tools are easily confused.
The image_ prefix unifies the image tools, but the suffixes mix verb forms (generate, edit) with noun phrases (multi_reference). server_info deviates from the prefix but is a typical meta-tool.
With five tools, the server is well-scoped, covering the essential image generation and editing workflows without redundancy. Each tool has a clear role.
The toolset covers text-to-image, single-image editing, batch editing, and multi-reference fusion, which are the major image operations. server_info provides configuration context, leaving no obvious gaps.
Maintenance
Related MCP Connectors
Focused MCP server for OpenAI image/audio generation (v2.0.0). Wraps endpoints via HAPI CLI.
MCP server for Qwen Image 3 AI image generation
MCP server for Flux AI image generation
MCP server for Wan AI video generation
Related MCP Servers
- AlicenseBqualityDmaintenanceMCP server for generating and editing images using EFLOWCODE's Responses API. Supports text-to-image, image editing, batch editing, and multi-reference synthesis for MCP clients like Codex and Claude.56MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that wraps OpenAI's image generation and editing APIs, enabling text-to-image and image-to-image operations via tools.139 npm37ISC
- AlicenseNot gradedqualityBmaintenanceMCP server for generating, editing, and processing images via multiple providers including Kilo, OpenRouter, OpenAI, and Gemini, with local tools for background removal, resizing, and cropping.18 npm2MIT
- AlicenseAqualityDmaintenanceMCP server for AI image generation supporting multiple providers (OpenRouter, Together AI, Replicate, fal.ai) and compatible with various MCP agents.231 npm1MIT