Skip to main content
Glama

TokenHub AIGC Model — MCP Server

MCP(Model Context Protocol) を利用して TokenHub 大モデルサービスの画像生成機能を呼び出す MCP Server です。お客様は MCP に対応した任意のクライアント(WorkBuddy / Claude Desktop / Cursor / 各種 AI IDE)で TokenHub API Key を設定するだけで、自然言語でテキストからの画像生成、画像からの画像生成/画像編集インターフェースを直接呼び出すことができます。

現在組み込みのサンプルモデル:custom-model-og-v2(GPT 系の画像生成モデル、同期返却)。


機能特性

  • 2つのツール

    • tokenhub_generate_image:テキストから画像生成(POST /v1/wand/og-image/generation、同期返却)

    • tokenhub_edit_image:画像から画像生成/画像編集(POST /v1/wand/og-image/edits、同期返却、1〜16枚の入力画像、マスクによる部分再描画に対応)

  • 2つの転送方式

    • stdio(デフォルト):ローカルクライアントに直接接続、デプロイ不要

    • streamable-http:リモートエンドポイントとしてデプロイし、外部クライアント/チームのリモート接続に対応

  • 柔軟な設定:API Key、サイトドメイン、モデル名はいずれも環境変数で設定可能。1回の呼び出しでドメイン/モデルを上書きできます(サイトやモデルの切り替えに設定変更は不要)


Related MCP server: ideogram-mcp

クイックスタート

方式1:stdio(ローカル接続、まずはこちらを推奨)

MCP クライアントの設定に、コマンドタイプの MCP Server を追加します。

客户端

設定場所

WorkBuddy

~/.workbuddy/mcp.json、その後「コネクタ管理 → カスタムコネクタ → 信頼」

Claude Desktop

claude_desktop_config.json

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"
    }
  }
}

設定後はすぐに会話できます:「竹林の中で踊る子猫を描いて、2048x2048」。

方法二:Streamable HTTP(リモートデプロイ)

{
  "mcpServers": {
    "tokenhub": {
      "url": "https://你的服务域名/mcp",
      "headers": { "x-mcp-auth-token": "部署时设置的 MCP_AUTH_TOKEN" }
    }
  }
}

環境変数

変数

必須

デフォルト値

説明

TOKENHUB_API_KEY

必須(未設定の場合は呼び出し時にエラー)

-

TokenHub コンソールで取得する API Key。リクエストヘッダー Authorization: Bearer <key>

TOKENHUB_BASE_URL

任意

https://tokenhub.tencentmaas.com

サイトドメイン(下のサイト説明を参照)。末尾のスラッシュ不要

TOKENHUB_MODEL

任意

custom-model-og-v2

デフォルトのモデル名。1回の呼び出しで上書き可能

MCP_AUTH_TOKEN

任意(HTTP モードでは推奨)

-

HTTP モードでの任意の認証。設定後、/mcp リクエストには x-mcp-auth-token リクエストヘッダー必須

サイトドメイン

TokenHub は地域ごとに分散デプロイされています。各サイトのお客様は対応するドメインを入力する必要があります。デフォルトは国内サイトの広州です:

サイト

ドメイン(例)

国内サイト・広州

https://tokenhub.tencentmaas.com(デフォルト)

その他のサイト(国内シンガポール / 国際サイト広州、シンガポール、米国西部など)

TokenHub 営業/技術サポートに連絡して対応ドメインを取得し、TOKENHUB_BASE_URL に入力するか、1回の呼び出しで base_url を渡してください


ツールパラメータの説明

tokenhub_generate_image(テキストから画像生成)

パラメータ

必須

説明

prompt

必須

テキストの説明。最大 32000 文字

base_url / model

任意

1回の呼び出しでサイトドメイン / モデル名を上書き

size

任意

生成サイズ 幅x高さ(例:2048x2048)。制約:片側≤3840px、幅・高さは16の倍数、長辺/短辺比≤3:1、総画素数 655360〜8294400

quality

任意

auto / high / medium / low

n

任意

生成枚数 1〜10、デフォルト 1

background

任意

opaque / auto

output_format

任意

png / jpeg

output_compression

任意

JPEG 圧縮レベル 0〜100(jpeg のみ)

response_format

任意

url(デフォルト)/ b64_json

tokenhub_edit_image(画像から画像生成/編集)

上記の大部分のパラメータを共有します。追加パラメータは次のとおりです:

パラメータ

必須

説明

images

必須

入力画像 1〜16 枚。[{ "image_url": "https://... 或 data:image/png;base64,..." }]、png/jpg

mask

任意

部分再描画用マスク。サイズは入力画像と一致させる必要があります

background

任意

追加で transparent に対応

戻り値:画像 URL リスト、request_id(問題調査用)、total_tokens(課金用)。response_format=b64_json の場合は base64 の画像ブロックが含まれ、直接表示できます。


エラー処理

  • ツール呼び出しに失敗すると isError: true を返します。エラー情報には status、上流エラーの code、request_id が含まれます。

  • 権限/レート制限/パラメータエラーが発生した場合は、request_id を保存したうえで TokenHub 技術サポートに送信し、特定してもらってください。

  • TOKENHUB_API_KEY が未設定の場合、ツール呼び出しは明確なメッセージを直接返します(サーバーは正常に起動できます)。


HTTP モードでのデプロイ(リモート)

# 本地启动(默认 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.1

エンドポイント:

  • POST /mcp、GET /mcp:MCP プロトコルの入口

  • GET /health:ヘルスチェック

公網にデプロイする場合は必ず:

  1. MCP_AUTH_TOKEN を設定するか、前置ゲートウェイ/リバースプロキシ(例:EdgeOne、CLB、Nginx)で認証を行う;

  2. HTTPS を使用する;

  3. base_url は1回の呼び出しで上書き可能なため、信頼できる環境でのみ開放することを推奨します。


開発とリリース

npm install        # 安装依赖
npm run build      # TypeScript 构建到 dist/
npm test           # 单元测试 + stdio/HTTP 冒烟测试(共 20 个用例)
npm pack --dry-run # 查看发布内容

npmjs に公開する場合(現在の registry が Tencent ミラーの場合は、明示的に指定する必要があります):

npm run build
npm version patch
npm publish --access public --registry=https://registry.npmjs.org
git tag v0.1.0 && git push --tags

⚠️ 重要な注意事項

  1. ホワイトリスト登録:custom-model-og-v2 はテストモデルのため、TokenHub のプロダクト/バックエンド担当者に連絡し、UIN と Appid を提出してホワイトリスト登録を行ったうえで使用できます。未登録で呼び出すと権限エラーが返ります。

  2. API Key:TokenHub コンソール で対応するモデル専用の Key を作成してください。Key は作成時に一度しか表示されないため、確実に保管してください。

  3. 課金:TokenHub は Token 単位の課金(約 10 元/百万トークン)で、時間ごとに精算されます。n>1 や複数枚の入力画像では消費が大幅に増えるため、営業担当者はお客様に早めに割引申請を行ってください。

  4. 費用計算式(人民元):テキスト入力 token×3.35 + テキストキャッシュ入力×0.8375 + 画像入力×5.36 + 画像キャッシュ入力×1.34 + 出力画像×20.1 = 1回のタスクの token 消費量(換算係数は為替レートに関係します。現在の係数は 6.7)。


License

Apache-2.0

Available Tools

2 tools
tokenhub_edit_imageTokenHub 图生图/图片编辑A

调用 TokenHub 接口,基于 1-16 张输入图 + 文本描述同步生成图片(模型默认 custom-model-og-v2,需开白)。支持局部重绘(mask)。输入图支持 URL 或 base64。返回图片 URL 列表、request_id 与 token 用量。

Inputs: images (required), prompt (required), n, mask, +8 more.

tokenhub_generate_imageTokenHub 文生图A

调用 TokenHub 接口,根据文本描述同步生成图片(模型默认 custom-model-og-v2,需在 TokenHub 控制台开白并配置专属 API Key)。返回图片 URL 列表、request_id 与 token 用量。

Inputs: prompt (required), n, size, model, +6 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 2 tools

    Disambiguation5/5

    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.

    Naming Consistency5/5

    Both tools follow the same tokenhub_<verb>_image pattern with static verb prefixes: edit and generate. The naming convention is consistent and predictable.

    Tool Count4/5

    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.

    Completeness4/5

    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.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables any MCP client to create and edit images from natural-language requests, automatically enriching short prompts with composition, lighting, and camera details while supporting Gemini, OpenAI, and BytePlus Seedream with fast, balanced, or quality presets.
      1,038 npm
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables coding agents and other MCP clients to generate images from text prompts and edit, restyle, or extend existing images through an OpenAI-compatible /v1/images API. Results are returned both inline as image content blocks and as files saved to disk, so agents can view and reuse them within a normal task.
      2
      MIT