Assets Generation MCP Server
An MCP server for AI image generation with dual-provider support for OpenAI-compatible models and Google Gemini. It returns standard MCP ImageContent blocks.
README
Assets Generation MCP Server
An MCP server for AI image generation with dual-provider support for OpenAI-compatible models and Google Gemini. It returns standard MCP ImageContent blocks.
Features
- Automatically selects the provider from the model name
- When both OpenAI and Gemini are configured, provider selection is still based on the requested model; if no model is provided,
DEFAULT_MODELis used - Returns images as MCP-standard
ImageContent({ type: "image", data, mimeType }) - Supports three transports: stdio (default), SSE, and HTTP
- Supports custom API proxy endpoints (
OPENAI_BASE_URL/GEMINI_BASE_URL) - Automatically loads
.env, and also supports CLI arguments for MCP clients that cannot passenv - Providers without valid API keys are disabled automatically without affecting the other provider
Quick Start
npm install
npm run build
cp .env.example .env
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
GEMINI_API_KEY |
One provider required | - | Google Gemini API key |
OPENAI_API_KEY |
One provider required | - | OpenAI-compatible API key |
DEFAULT_MODEL |
No | gemini-2.5-flash-image |
Default model when the tool call does not provide model |
GEMINI_BASE_URL |
No | - | Gemini API proxy endpoint |
OPENAI_BASE_URL |
No | - | OpenAI-compatible API proxy endpoint |
OPENAI_IMAGE_MODEL |
No | gpt-image-2 |
OpenAI-compatible image model used in integration tests |
MCP_TRANSPORT |
No | stdio |
Transport mode: stdio / sse / http |
MCP_STDIO_LOGS |
No | false |
Enable startup/runtime logs in stdio mode (set true to re-enable for debugging) |
MCP_HOST |
No | localhost |
Host for SSE/HTTP mode |
MCP_PORT |
No | 3000 |
Port for SSE/HTTP mode |
Configure at least one of
GEMINI_API_KEYorOPENAI_API_KEY.Placeholder values in
.envsuch asyour-gemini-api-keyare ignored automatically.Configuration precedence is: CLI arguments > process environment variables >
.envin the current working directory > built-in defaults.
Tool: generate_image
| Parameter | Required | Default | Description |
|---|---|---|---|
prompt |
Yes | - | Detailed image description |
model |
No | DEFAULT_MODEL |
Model name — see supported models below |
size |
No | auto / 1024x1024 |
Image dimensions for OpenAI-compatible models |
quality |
No | standard |
high/medium/low/standard (gpt-image-*) or hd/standard (dall-e-3) |
n |
No | 1 |
Number of images (gpt-image-*: 1–10; dall-e-3: 1; Gemini: 1) |
aspect_ratio |
No | 1:1 |
Gemini-only: 1:1 3:4 4:3 9:16 16:9 |
response_format |
No | auto |
url / base64 / auto — see Response Format below |
timeout |
No | 120 |
Max wait time in seconds. Increase for slow proxies or high-quality models |
Supported model families:
- OpenAI / OpenAI-compatible:
gpt-image-2,gpt-image-1,dall-e-3,dall-e-2,doubao-*,volcengine/doubao-* - Gemini:
gemini-2.5-flash-image,gemini-2.0-flash-exp,imagen-3.0-generate-001
Response Format
The response_format parameter controls how image URLs and file paths are returned alongside the base64 ImageContent blocks:
| Value | Behavior |
|---|---|
auto (default) |
Always returns a local file path in the response text (Saved to: /tmp/abc123.png) alongside the base64 ImageContent block. Images are saved to os.tmpdir() with a random filename. This mode is the most compatible and ensures the image is always accessible regardless of the provider's default response format. |
base64 |
Returns ImageContent blocks only (forces b64_json for OpenAI). |
url |
Always returns a file path or URL in the response text: <br>• If the API returns a url → Image URL: https://... <br>• If the API returns only base64 → the image is saved to os.tmpdir() with a random filename → Saved to: /tmp/abc123.png |
Security: files saved to the temp directory use
crypto.randomBytes(16)for filenames withwx(exclusive-create) and0o600(owner-only) flags — no path-traversal risk, no file-overwrite collisions.
Usage
Claude Desktop / Kiro (stdio mode)
{
"mcpServers": {
"assets-gen": {
"command": "node",
"args": ["/path/to/assets-gen-mcp/dist/index.js"],
"env": {
"GEMINI_API_KEY": "your-key",
"GEMINI_BASE_URL": "https://your-proxy.com"
}
}
}
}
If your MCP client cannot pass env, use CLI arguments instead:
{
"mcpServers": {
"assets-gen": {
"command": "npx",
"args": [
"-y",
"@ayaka209/assets-gen-mcp",
"--openai-api-key",
"your-key",
"--openai-base-url",
"https://your-proxy.com/gptapi",
"--default-model",
"gpt-image-2"
]
}
}
}
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\\Claude\\claude_desktop_config.json
MCP SDK Client
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
const transport = new StdioClientTransport({
command: "node",
args: ["dist/index.js"],
env: { GEMINI_API_KEY: "your-key" },
});
const client = new Client({ name: "my-app", version: "1.0.0" }, { capabilities: {} });
await client.connect(transport);
const result = await client.callTool({
name: "generate_image",
arguments: { prompt: "A cat in space" },
});
// result.content -> [{ type: "image", data: "<base64>", mimeType: "image/png" }]
Provider Selection Rules
- If
modelis provided, the provider is chosen from the model prefix - If
modelis omitted,DEFAULT_MODELis used gpt-image-*/dall-e-*/doubao-*/volcengine/doubao-*go to the OpenAI-compatible pathgemini-*/imagen-*go to the Gemini path
SSE / HTTP Mode
MCP_TRANSPORT=sse MCP_PORT=3000 node dist/index.js
Endpoints:
GET /sse- SSE connectionPOST /message?sessionId=xxx- Send messagesGET /- Health check
OpenAI-Compatible Proxy Testing
Run the full integration tests:
OPENAI_API_KEY=your-key
OPENAI_BASE_URL=https://your-openai-compatible-endpoint
OPENAI_IMAGE_MODEL=gpt-image-2
npm run test:integration
For a single end-to-end smoke test:
OPENAI_API_KEY=your-key
OPENAI_BASE_URL=https://your-openai-compatible-endpoint
OPENAI_IMAGE_MODEL=gpt-image-2
npm run test:openai-proxy
This script verifies:
- A direct
images.generatecall againstOPENAI_BASE_URL - A stdio MCP round-trip through this repository's
generate_imagetool
To inspect which OpenAI-compatible models your endpoint exposes:
OPENAI_API_KEY=your-key
OPENAI_BASE_URL=https://your-openai-compatible-endpoint
npm run models:openai
If your MCP client cannot pass env, you can launch it directly with CLI arguments:
npx -y @ayaka209/assets-gen-mcp --openai-api-key sk-... --openai-base-url https://your-openai-compatible-endpoint --default-model gpt-image-2
Show all supported CLI options:
npx -y @ayaka209/assets-gen-mcp --help
Development
npm run build # Build
npm run watch # Watch TypeScript
npm test # Unit tests
npm run test:integration # Integration tests (requires API keys)
npm run test:openai-proxy # One-command OpenAI-compatible smoke test
npm run models:openai # List OpenAI-compatible models visible to the endpoint
npm run models # List available Gemini models
Tech Stack
@modelcontextprotocol/sdk- MCP server/client SDK@google/genai- Google Gemini SDKopenai- OpenAI SDK
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。