tai-mcp
Provides tools for generating and editing images using OpenAI-compatible APIs, including image generation, image editing, model capabilities listing, and model listing.
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., "@tai-mcpGenerate an image of a futuristic city skyline at sunset"
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.
tai-mcp
tai-mcp 是一个可独立部署的 MCP 服务,把 tai-openapi 的 OpenAI 兼容图片生成和编辑接口
封装为 MCP 工具。MCP 客户端调用 generate_image 或 edit_image 后会直接收到标准 MCP
ImageContent,不依赖 tai-openapi 返回的本地图片 URL。
功能
generate_image:调用POST /v1/images/generations,返回一张可直接显示的图片及元数据。edit_image:调用POST /v1/images/edits,支持多张输入图、mask、size 和模型专属参数。get_image_model_capabilities:调用GET /v1/image-models/{model}/capabilities,查询 edit 模型实际接受的输入。list_image_models:调用GET /v1/models,查看当前上游启用的模型。Streamable HTTP:MCP 地址为
http(s)://<host>:8001/mcp。无状态 JSON 响应,适合反向代理和横向扩容。
MCP 入口支持独立 Bearer Token;上游 API Key 不暴露给 MCP 客户端。
/healthz检查本服务,/readyz同时检查tai-openapi。
Related MCP server: MCP OpenAI Image Generation Server
与 tai-openapi 的接口契约
本项目使用官方 OpenAI Python SDK 的
AsyncOpenAI 与上游通信。图片生成、图片编辑和模型列表分别直接使用
client.images.generate()、client.images.edit() 和 client.models.list();
get_image_model_capabilities 与 /readyz 所需的 capabilities、health 接口属于
tai-openapi 扩展,通过同一个官方客户端的底层 get() 方法访问。
seed 和 parameters 不是 OpenAI Image API 的标准字段,分别通过 SDK 的
extra_body 合并到 generation JSON 和 edits multipart 请求中。多图编辑采用官方 SDK
生成的 image[] 字段,tai-openapi 会将其规范化为内部的 image 输入。
generate_image 固定向上游发送:
{
"model": "tai-text-to-image",
"prompt": "A quiet library at night",
"size": "1024x1024",
"seed": 42,
"response_format": "b64_json"
}size 和 seed 未传时不会出现在请求中。固定使用 b64_json 是为了让远程 MCP
客户端直接获得图片,并避免公网部署时误返回仅服务器本机可访问的图片 URL。
一次 MCP 调用只发起一次上游生图请求;超时或网络中断不会自动重试,以免重复生成。
编辑前应先调用 get_image_model_capabilities(model)。返回结果会明确说明:
input.min_images/input.max_images:images所需的图片数量。input.mask:forbidden、optional或required。input.size:是否允许传size。input.prompt_required:是否需要 prompt 字段。parameters_schema:parameters必须满足的 JSON Schema。parameters_example:该模型扩展参数的可用示例。
edit_image.images 和 mask 接受 PNG、JPEG、WebP 的纯 base64 字符串或
data:image/png;base64,... 形式的 Data URL。MCP 服务把它们解码后作为文件上传给上游;
response_format 固定为 b64_json。例如 tai-image-to-image 的典型参数为:
{
"prompt": "Make the bodywork brighter",
"images": ["data:image/png;base64,<base64-data>"],
"model": "tai-image-to-image",
"parameters": {"denoise": 0.55}
}图片顺序会原样保留,具体每个位置代表原图还是参考图由所选模型的 capabilities 决定。
seed 等 edit 专属字段放在 parameters 中,不能作为顶层参数传入。
本地运行
要求 Python 3.12+ 和 uv。
Copy-Item .env.example .env
# 编辑 .env,至少填写 TAI_OPENAPI_API_KEY
uv sync --extra dev
uv run python -m tai_mcp默认监听 0.0.0.0:8001:
MCP:
http://127.0.0.1:8001/mcp存活检查:
http://127.0.0.1:8001/healthz就绪检查:
http://127.0.0.1:8001/readyz
stdio 模式
本地 Codex 可以通过 stdio 按需启动 MCP,无需监听端口:
uv run python -m tai_mcp --transport stdiostdio 模式会继续从项目目录的 .env 读取上游地址、API Key 和默认模型;
MCP_HOST、MCP_PORT、MCP_API_KEY 和 CORS 配置在该模式下不生效。
注册到 Codex 时使用项目启动脚本。脚本会先切换到项目目录,确保 .env 能被读取:
codex mcp add tai-images -- `
powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass `
-File C:\Users\xiuzhenpeng\Desktop\vscode-dev\tai-mcp\run-stdio.ps1不要在 codex mcp add --env 中直接写 API Key;该值会进入 Codex 配置。启动脚本让密钥
继续只保存在项目的 .env 中。
用 MCP Inspector 验证:
npx -y @modelcontextprotocol/inspector在 Inspector 中把地址设为 http://127.0.0.1:8001/mcp。如果配置了
MCP_API_KEY,添加请求头:
Authorization: Bearer <MCP_API_KEY>配置
环境变量 | 默认值 | 说明 |
|
| 上游地址,必须以 |
| 无 | 上游 |
|
|
|
|
|
|
| 空 | MCP 客户端 Bearer Token;公网部署必须设置 |
|
| 监听地址 |
|
| 监听端口 |
|
| 包含生图时间的上游总超时 |
|
| 上游连接超时 |
|
| 允许回传的最大解码图片大小 |
| 空 | 浏览器客户端的精确 Origin,逗号分隔 |
工具的 model 参数可以覆盖默认模型,但仍受上游 API Key 权限和模型配置约束。
生成 MCP_API_KEY
MCP_API_KEY 是客户端访问 /mcp 时使用的 Bearer Token。公网部署必须使用独立的
强随机值,不要复用 TAI_OPENAPI_API_KEY。
在项目目录中运行以下命令,生成一个基于 48 字节随机数据的 URL 安全密钥:
uv run python -c "import secrets; print(secrets.token_urlsafe(48))"如果系统已经安装 OpenSSL,也可以生成 32 字节随机值并输出为 64 位十六进制:
openssl rand -hex 32复制命令输出的完整一行,写入 .env:
MCP_API_KEY=这里替换为刚生成的随机密钥不要把真实密钥写入 .env.example、提交到 Git 或粘贴到公开日志。修改密钥后需要重启
容器:
docker compose up -d --force-recreateMCP 客户端访问 https://<你的域名>/mcp 时需要发送:
Authorization: Bearer <MCP_API_KEY>Docker
先创建配置:
Copy-Item .env.example .env如果 tai-openapi 跑在 Docker 宿主机的 8000 端口,把 .env 改为:
TAI_OPENAPI_BASE_URL=http://host.docker.internal:8000/v1然后启动:
docker compose up -d --build
docker compose ps如果两个服务位于同一个 Compose 网络,建议直接使用服务名,例如
TAI_OPENAPI_BASE_URL=http://tai-openapi:8000/v1。
公网发布检查清单
为
MCP_API_KEY生成至少 32 字节的随机值,不要和上游 API Key 共用。只通过 HTTPS 暴露 MCP;可参考
deploy/nginx.conf.example。防火墙只开放 80/443,不直接暴露 8001;上游 8000 更不应直接暴露。
Nginx 的读写超时要大于
tai-openapi的最大生图时间。将
.env保留在服务器,不提交到 Git。若启用 CORS,只配置实际 MCP Web 客户端的 Origin,不要在公网使用
*。发布后验证
/healthz、/readyz、工具列表以及一次真实生图。
静态 Bearer Token 适合私有客户端或能够配置自定义请求头的 MCP Host。如果需要面向 不受控第三方用户开放,应在反向代理或独立授权服务中实现 MCP OAuth 2.1,而不是共享 同一个静态 Token。
测试与质量检查
uv run --extra dev pytest
uv run --extra dev ruff check .
uv run --extra dev ruff format --check .Available Tools
4 toolsedit_imageEdit imageA
Edit an image through a tai-openapi edit model.
Args: prompt: Edit instruction. The field is required; models that ignore it accept "". images: Ordered PNG, JPEG, or WebP inputs as base64 strings or data URLs. size: Optional WIDTHxHEIGHT; only pass it when capabilities input.size is true. model: Optional edit model alias; defaults to TAI_IMAGE_EDIT_MODEL. mask: Optional PNG, JPEG, or WebP mask as base64 or a data URL. Follow the capabilities input.mask policy. response_format: Image response format: "url" or "b64_json". parameters: Model-specific JSON values matching capabilities.parameters_schema.
| Name | Required | Description | Default |
|---|---|---|---|
| mask | No | Optional PNG, JPEG, or WebP mask encoded as base64 or a data URL. Follow the capabilities input.mask policy. | |
| size | No | Optional WIDTHxHEIGHT. Pass only when capabilities input.size is true. | |
| model | No | Edit model alias; defaults to TAI_IMAGE_EDIT_MODEL. | |
| images | Yes | Ordered PNG, JPEG, or WebP inputs encoded as base64 strings or data URLs. Use get_image_model_capabilities to determine the exact image count. | |
| prompt | Yes | Edit instruction. This field is required; pass "" only for a model whose workflow ignores prompt. | |
| parameters | No | Model-specific JSON values. Must satisfy capabilities.parameters_schema. | |
| response_format | No | url |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It discloses input formats, conditional parameters, and reference to model capabilities, but it does not mention potential side effects, authentication requirements, rate limits, or response structure beyond the response_format choices. This is moderate transparency but leaves 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 well-structured with a one-line purpose followed by a clear 'Args' list. All 7 parameters are covered in a readable format. It is somewhat lengthy and redundant with the schema, but every line provides useful operational guidance, making it efficient for its scope.
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?
The tool is complex (7 parameters, capabilities-driven behavior) and lacks an output schema. The description explains parameter usage but does not describe the response object, error scenarios, or end-to-end behavior. It is sufficient for basic invocation but incomplete for fully informed use.
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 86%, so the schema already documents most parameters. The description largely mirrors the schema text without adding significant new meaning. It does add 'through a tai-openapi edit model' context, but the parameter descriptions themselves are nearly identical, so no extra semantic value is provided.
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 opens with 'Edit an image through a tai-openapi edit model,' using a specific verb and resource. This clearly distinguishes it from sibling tools like generate_image and get_image_model_capabilities, making the tool's purpose unambiguous.
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 includes conditional usage guidance, such as 'only pass it when capabilities input.size is true' and 'Follow the capabilities input.mask policy.' However, it does not explicitly state when to use this tool over generate_image or list_image_models, leaving the distinction implied rather than explicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
generate_imageGenerate imageA
Generate one image from a text prompt.
Args: prompt: Detailed text description of the image to create. size: Optional WIDTHxHEIGHT accepted by the selected tai-openapi model. seed: Optional deterministic seed in the range 0..4294967295. model: Optional model alias; defaults to tai-text-to-image. response_format: Image response format: "url" or "b64_json"
| Name | Required | Description | Default |
|---|---|---|---|
| seed | No | ||
| size | No | ||
| model | No | ||
| prompt | Yes | ||
| response_format | No | url |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
There are no annotations, so the description carries the burden of behavioral disclosure. It explains parameter defaults and response_format, but doesn't disclose return structure, side effects, permissions, or rate limits. For a generation tool, this is moderate transparency but not comprehensive.
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 front-loaded with the purpose, followed by a well-organized Args list. Each parameter is clearly documented without unnecessary verbosity. Every line 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?
With no output schema, the description should clarify what the tool returns. It mentions response_format but doesn't explicitly state the return structure (e.g., object containing URL or base64 data). However, for a generation tool with all parameters documented, it is nearly complete. Missing only a formal note on the return value.
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 0% description coverage, so the description fully compensates by explaining every parameter: prompt, size, seed, model, and response_format. It adds meaning beyond the schema with details like seed range, size format, and model default.
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: 'Generate one image from a text prompt.' It uses a specific verb and resource, and the scope is defined (single image). This distinguishes it from sibling tools like edit_image, which would modify an existing image.
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 gives clear context: this tool is for generating an image from a text prompt. It doesn't explicitly mention alternatives or exclusions, but the purpose is straightforward. It could mention using edit_image for editing, but the core usage is implied strongly enough to warrant a 4.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_image_model_capabilitiesGet image model capabilitiesA
Describe the exact inputs accepted by one enabled image edit model.
The result includes the required image count, mask policy, size support, prompt requirement, JSON Schema for parameters, and a parameters example.
Args: model: Enabled tai-openapi edit model alias to inspect.
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | Enabled tai-openapi image edit model alias to inspect. |
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 present. The description explicitly states the operation is to 'Describe' and enumerates the exact result fields ('required image count, mask policy, size support, prompt requirement, JSON Schema for parameters, parameters example'), which signals a read-only introspection behavior and sets expectations for what is returned. It does not discuss errors or permission requirements, but for a capability-definition query this is adequate.
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 compact: one purpose sentence, one sentence on result contents, and an Args block. The Args block is duplicative of the schema, but the overall length is appropriate and the key information is front-loaded.
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 only one required parameter and an output schema present, the description need not detail return structures. It covers the operation's intent and the key included fields, making the tool self-contained. It could mention sibling tool alternatives, but that omission affects the usage dimension more than completeness.
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 coverage is 100%; the `model` parameter is already described in the schema as 'Enabled tai-openapi image edit model alias to inspect.' The description's Args section repeats this rather than adding new semantics, so it earns the baseline 3.
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 opens with 'Describe the exact inputs accepted by one enabled image edit model,' which names a clear verb ('Describe'), resource ('image edit model capabilities'), and scope ('one enabled...'). This distinguishes it from sibling tools like list_image_models or edit_image.
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?
No explicit 'when to use' or alternative references appear. The description implies you should call this when you need a model's input contract, but it does not contrast with list_image_models or edit_image, so guidance is only implicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_image_modelsList image modelsA
List model aliases currently exposed by tai-openapi.
| 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?
No annotations are provided, so the description must carry full behavioral disclosure. It states it lists aliases but doesn't mention whether it's a read-only operation, performance characteristics, or error conditions. Minimal behavioral context beyond the action itself.
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?
Single sentence, front-loaded with 'List model aliases', no wasted words. Ideal length.
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 no parameters and an output schema exists, the description sufficiently covers the essential information. However, the mention of 'tai-openapi' may be ambiguous to unfamiliar users, and no context is given about the meaning of 'aliases'.
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 input schema has zero parameters, so the description doesn't need to elaborate on parameter details. The baseline of 4 applies, and the description adds no additional parameter semantics but none are needed.
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 uses a specific verb ('List') and identifies the exact resource ('model aliases currently exposed by tai-openapi'), clearly differentiating it from sibling tools like generate_image/edit_image which perform actions.
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?
No explicit guidance on when to choose this tool over get_image_model_capabilities or when not to use it. The description implies a use case (listing available aliases) but doesn't state exclusions or alternatives.
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.
4 tool updates
v0.1.0- First observed
edit_image - First observed
generate_image - First observed
get_image_model_capabilities - First observed
list_image_models
TDQS
Scored across 4 tools
Each tool targets a distinct operation: generate_image creates new images, edit_image modifies existing ones, list_image_models enumerates available models, and get_image_model_capabilities inspects edit-model specifics. There is no overlap or ambiguity between these actions.
All tool names follow a consistent verb_noun snake_case pattern: generate_image, edit_image, list_image_models, get_image_model_capabilities. The verb and noun are clear, and the style is uniform throughout.
Four tools is well-scoped for an image generation and editing server. Each tool serves a distinct and necessary function, with no missing or redundant entries.
The core lifecycle is covered: generate, edit, list models, and inspect model capabilities. A minor gap is that capabilities are only available for edit models, not for generation models, which could be useful when choosing sizes or parameters for generate_image.
Related MCP Connectors
Edit images over MCP with object removal, background removal, and guided generative edits.
Generate images with any major model — one API key, one prepaid balance, one MCP.
Create and manage AI image and video generations through Quriov's fixed public MCP tools.
Multi-model AI image and video generator. 14 models behind one OAuth-secured MCP endpoint.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides tools for generating and editing images using OpenAI's gpt-image-1 model via an MCP interface, enabling AI assistants to create and modify images based on text prompts.15Apache 2.0
- AlicenseNot gradedqualityNot gradedmaintenanceEnables AI assistants to generate and edit images through OpenAI's DALL-E models via MCP tools. Supports text-to-image generation and image-to-image editing with configurable parameters for size, quality, and style.-
- AlicenseNot gradedqualityCmaintenanceExposes multiple image generation backends as independent MCP tools for generating images with configurable models and parameters.MIT
- AlicenseAqualityCmaintenanceEnables LLMs to generate images via MCP by calling AI models from providers like SiliconFlow, OpenAI, or custom APIs, with tools for image generation and model listing.2MIT