tokenhub-aigc-model
TokenHub AIGC Model — MCP Server
El MCP Server invoca la capacidad de generación de imágenes de la plataforma de grandes modelos de TokenHub mediante MCP (Model Context Protocol). El cliente puede configurar su TokenHub API Key en cualquier cliente compatible con MCP (WorkBuddy / Claude Desktop / Cursor / diferentes IDEs de IA) y así llamar directamente en lenguaje natural a las interfaces de texto a imagen, y de imagen a imagen/edición de imágenes.
Modelo actual incorporado como muestra: custom-model-og-v2 (modelo de generación de imágenes de la familia GPT, respuesta síncrona).
Características
Dos herramientas
tokenhub_generate_image: texto a imagen (POST /v1/wand/og-image/generation, respuesta síncrona)tokenhub_edit_image: imagen a imagen/edición de imágenes (POST /v1/wand/og-image/edits, respuesta síncrona, admite 1 a 16 imágenes de entrada y redibujado local conmask)
Doble transporte
stdio(por defecto): conexión directa desde el cliente local, sin desplieguestreamable-http: se despliega como endpoint remoto para clientes/equipos externos
Configuración flexible: API Key, dominio del sitio y nombre del modelo se pueden configurar mediante variables de entorno; cada llamada admite la sobreescritura del dominio/modelo (cambiar de sitio o modelo sin modificar la configuración)
Related MCP server: Vertex AI Imagen MCP Server
Inicio rápido
Método 1: stdio (integración local, recomendado para empezar)
Agrega un MCP Server de tipo comando en la configuración del cliente MCP:
Cliente | Ubicación de configuración |
WorkBuddy |
|
Cliente de escritorio de Claude |
|
Cursor | Settings → MCP → Add new MCP server |
{
"mcpServers": {
"tokenhub": {
"type": "stdio",
"command": "npx",
"args": ["-y", "tokenhub-aigc-model"],
"env": {
"TOKENHUB_API_KEY": "你的 TokenHub API Key",
"TOKENHUB_BASE_URL": "https://tokenhub.tencentmaas.com",
"TOKENHUB_MODEL": "custom-model-og-v2"
},
"description": "TokenHub 生图 MCP"
}
}
}Después de la configuración, puedes conversar directamente: «Dibuja un gatito bailando en un bosque de bambú, 2048x2048».
Método 2: Streamable HTTP (despliegue remoto)
{
"mcpServers": {
"tokenhub": {
"url": "https://你的服务域名/mcp",
"headers": { "x-mcp-auth-token": "部署时设置的 MCP_AUTH_TOKEN" }
}
}
}Variables de entorno
Variable | Obligatoria | Valor por defecto | Descripción |
| Sí (para poder invocaciones) | - | API Key obtenida en la consola TokenHub; Header |
| No |
| Dominio del sitio (ver la sección de sitios), sin la barra final |
| No |
| Modelo predeterminado; podrá sobrescribirse en cada llamada |
| No (recomendado en modo HTTP) |
| Autenticación opcional en modo HTTP; una vez establecido, |
Dominios del sitio
TokenHub implementa diferentes sitios por región; los clientes de distintos sitios deben completar el dominio correspondiente. El predeterminado es el sitio local de Guangzhou:
Sitio | Dominio (ejemplo) |
Sitio local · Guangzhou |
|
Otros sitios (local · Singapur / internacionales · Guangzhou, Singapur, oeste de EE.UU., etc.) | Contacta con el equipo de negocio/soporte técnico de TokenHub para obtener el dominio correspondiente, rellénalo en |
Descripción de parámetros de las herramientas
tokenhub_generate_image (texto a imagen)
Parámetro | Obligatorio | Descripción |
| Sí | Descripción de la imagen, máximo 32000 caracteres |
| No | Sobreescribe el dominio del sitio / nombre del modelo para esa llamada |
| No | Tamaño de generación |
| No |
|
| No | Cantidad de imágenes 1-10 (por defecto 1) |
| No |
|
| No |
|
| No | Nivel de compresión JPEG 0-100 (solo jpeg) |
| No |
|
tokenhub_edit_image (imagen a imagen/edición)
Comparte la mayoría de los parámetros anteriores; y añade:
Parámetro | Obligatorio | Descripción |
| Sí | 1 a 16 imágenes de entrada, |
| No | Redibujado de máscara local, las dimensiones deben coincidir con la imagen de entrada |
| No | Admite además |
Resultado: lista de URLs de imágenes, req_id (para rastrear problemas), total_tokens (para facturación); con response_format=b64_json se incluye el bloque de imagen en base64 para mostrar directamente.
Manejo de errores
Si la llamada a la herramienta falla, se devuelve
isError: true; el mensaje de error contienestat, código de error de la fuente ascendente yrequest_id.Cuando aparezcan errores de permiso / límite de velocidad / parámetro, no olvides conservar el
request_idy reportarlo al soporte técnico de TokenHub para localizar el problema.Si
TOKENHUB_API_KEYno está configurada, la invocación de la herramienta devuelve directamente una respuesta clara (el server puede arrancar sin problema).
Modo HTTP (remoto)
# 本地启动(默认 stdio)
npx -y tokenhub-aigc-model
# HTTP 模式
TOKENHUB_API_KEY=xxx MCP_AUTH_TOKEN=部署密钥 \
npx -y tokenhub-aigc-model --transport=http --port=3000 --host=127.0.0.1Endpoints:
POST /mcp,GET/mcp`: entrada del protocolo MCPGET /health: comprobación de salud
Al desplegar en la red pública, asegúrate de lo siguiente:
Establecer
MCP_AUTH_TOKEN, o realizar la autentificación en una pasarela previa/proxy inverso (por ejemplo, EdgeOne, CLB, Nginx);Usar HTTPS;
base_urladmite sobreescritura por llamada; se recomienda abrirse en entornos confiable.
Desarrollo y publicación
npm install # 安装依赖
npm run build # TypeScript 构建到 dist/
npm test # 单元测试 + stdio/HTTP 冒烟测试(共 20 个用例)
npm pack --dry-run # 查看发布内容Publicar en npmjs (si el registry actual es un espejo de Tencent, debe especificarse explícitamente):
npm run build
npm version patch
npm publish --access public --registry=https://registry.npmjs.org
git tag v0.1.0 && git push --tags⚠️ Recordatorios importantes
Lista blanca:
custom-model-og-v2es un modelo de prueba; debes contactar con el equipo de producto/layout de TokenHub para presentar un UIN y AppID para lista blanca antes que puede utilizar lo; si no se usa, la llamada devuelve error de permisos.API Key: por favor, crea una clave exclusiva para el modelo correspondiente en la consola de TokenHub; la key solo se muestra una vez al crearla, guárala correctamente.
Facturación: TokenHub se factura según el token (approx 10 yuanes por cada millón de tokens), con liquidación por hora.
n>1o múltiples imágenes de entrada aumentarán significativamente el consumo; pide al departamento comercial que solicite un descuento para el cliente cuanto antes.Fórmula de coste (en RMB): entrada de texto
token×3.35 + entrada de texto en caché×0.8375 + entrada de imagen×5.36 + entrada de imagen en caché×1.34 + salida de imagen×20.1 = consumo de token de una sola tarea (el coeficiente está relacionado con el tipo de cambio; el actual es 6.7).
Licencia
Available Tools
2 toolstokenhub_edit_imageTokenHub 图生图/图片编辑A
调用 TokenHub 接口,基于 1-16 张输入图 + 文本描述同步生成图片(模型默认 custom-model-og-v2,需开白)。支持局部重绘(mask)。输入图支持 URL 或 base64。返回图片 URL 列表、request_id 与 token 用量。
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | 生成图片数量 1-10,默认 1 | |
| mask | No | 局部重绘蒙版图,尺寸需与输入图一致 | |
| size | No | 生成尺寸 "宽x高",如 2048x2048。约束:单边≤3840px、宽高为 16 的倍数、长短边比≤3:1、总像素 655360~8294400 | |
| model | No | 单次覆盖模型名。不传时用环境变量 TOKENHUB_MODEL(默认 custom-model-og-v2) | |
| images | Yes | 输入图 1-16 张,支持 URL 或 base64 | |
| prompt | Yes | 文本描述,最大 32000 字符 | |
| quality | No | 画质,默认 auto | |
| base_url | No | 单次覆盖站点域名(如 https://tokenhub.tencentmaas.com)。不传时用环境变量 TOKENHUB_BASE_URL | |
| background | No | 图像背景透明度:transparent 透明 / opaque 不透明 / auto 自动判断,默认 auto | |
| output_format | No | 输出格式,默认 png | |
| response_format | No | 返回格式:url(图片地址)或 b64_json(base64 数据),默认 url | |
| output_compression | No | JPEG 压缩级别 0-100,仅 output_format=jpeg 时生效 |
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. It discloses the model default, whitelist requirement, mask support, URL/base64 input acceptance, and return fields. It does not mention error behavior, rate limits, or auth mechanics, but it covers the main operational characteristics well.
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, informative, and well-front-loaded. It covers the core operation, constraints, input formats, mask feature, and return payload in four sentences with no fluff or redundancy.
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 12-parameter schema and absence of an output schema, the description provides enough operational context: input requirements, image count range, model default and whitelist, mask support, and response contents. It falls short of 5 only because of missing explicit alternative-tool routing and access/auth context.
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 100%, so the baseline is 3. The description mentions mask, input images, model default, and input formats, but most of these details are already documented in the schema. It adds only high-level context like whitelist and return metadata, not substantial new parameter-level semantics.
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 operation: calling TokenHub to generate an image from 1-16 input images plus a text prompt, with support for mask-based local repainting. It also specifies the output contents (image URL list, request_id, token usage), making the tool's purpose and scope 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 gives clear contextual signals for when to use this tool: when existing images are provided as input and editing/repainting is needed. It doesn't explicitly exclude or name the alternative tokenhub_generate_image, so the routing guidance is 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.
tokenhub_generate_imageTokenHub 文生图A
调用 TokenHub 接口,根据文本描述同步生成图片(模型默认 custom-model-og-v2,需在 TokenHub 控制台开白并配置专属 API Key)。返回图片 URL 列表、request_id 与 token 用量。
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | 生成图片数量 1-10,默认 1 | |
| size | No | 生成尺寸 "宽x高",如 2048x2048。约束:单边≤3840px、宽高为 16 的倍数、长短边比≤3:1、总像素 655360~8294400 | |
| model | No | 单次覆盖模型名。不传时用环境变量 TOKENHUB_MODEL(默认 custom-model-og-v2) | |
| prompt | Yes | 文本描述,最大 32000 字符 | |
| quality | No | 画质,默认 auto | |
| base_url | No | 单次覆盖站点域名(如 https://tokenhub.tencentmaas.com)。不传时用环境变量 TOKENHUB_BASE_URL | |
| background | No | 图像背景透明度:opaque 不透明 / auto 自动判断,默认 auto | |
| output_format | No | 输出格式,默认 png | |
| response_format | No | 返回格式:url(图片地址)或 b64_json(base64 数据),默认 url | |
| output_compression | No | JPEG 压缩级别 0-100,仅 output_format=jpeg 时生效 |
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. It discloses that the call is synchronous, requires the user to have whitelisted the model and configured a dedicated API key, and that the response includes image URLs, request_id, and token usage. It does not cover error behavior or rate limits, but the key behavioral constraints are present.
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 short, information-dense sentences with no redundancy. It ends with the action and auth prerequisite, then return values. Every word contributes to the agent's understanding.
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 tool with 10 parameters and no output schema, the description covers the important context: synchronous, auth required, default model, return shape. The schema covers parameter details, and what is missing (timeouts, error behavior) is minor for most use cases.
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 documents all 10 parameters with detailed per-parameter descriptions, so the description adds very little for parameters. Mentioning the default model is useful but overlaps with the schema's model field. This is the expected baseline since schema coverage is 100%.
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 action: calling TokenHub to synchronously generate an image from a text description, and identifies the resource (image). It does not explicitly contrast with tokenhub_edit_image, but the 'generate from text' wording is distinct enough.
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 the appropriate scenario (generate an image from a prompt) and provides essential prerequisites (whitelist + dedicated API key). However, it gives no explicit guidance on when to prefer this over tokenhub_edit_image or 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.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
2 tool updates
v0.1.0- First observed
tokenhub_edit_image - First observed
tokenhub_generate_image
TDQS
Scored across 2 tools
The two tools have clearly distinct purposes: one generates an image purely from text, while the other edits/generates from 1-16 input images with optional masking. There is no realistic confusion between them.
Both tools follow the same tokenhub_<verb>_image pattern with static verb prefixes: edit and generate. The naming convention is consistent and predictable.
With only two tools, the server is slightly thin, but each tool covers a distinct core task in the image-generation domain. The focused scope makes the small count reasonable.
The two primary workflows—text-to-image generation and image editing/reinpainting—are covered, and the synchronous design avoids needing result-status tools. A minor gap is the lack of model-list or capability-discovery tooling, but agents can still complete the core tasks.
Maintenance
Related MCP Connectors
Generate AI images and videos from any compatible MCP client.
Generate images with any major model — one API key, one prepaid balance, one MCP.
Multi-model AI image and video generator. 14 models behind one OAuth-secured MCP endpoint.
Generate images from Claude, ChatGPT, Cursor and Codex with 12 top AI image models. Up to 4 images per call, SVG vectorization, background removal, upscaling and image-to-video. Remote MCP with OAuth, no API keys.
Related MCP Servers
- 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 gradedqualityCmaintenanceEnables image generation and editing using Google Vertex AI's Imagen API through natural language commands in MCP clients like Claude Desktop.40 npm1MIT
- AlicenseAqualityDmaintenanceEnables image generation, editing, and composition using any OpenAI-compatible Images API within MCP clients, Dify, and n8n, delivering results as image blocks, structured fields, or resource links.4MIT
- AlicenseAqualityBmaintenanceEnables generating, editing, remixing, upscaling, and describing images through the Ideogram V3 API from any MCP client.7360 npmMIT