agileimagegen-mcp

agileimagegen-mcp

Enables AI-powered image generation and editing using Google Gemini models, with support for transparency, reference images, and flexible output sizes.

Category
访问服务器

README

agileimagegen-mcp

Thin MCP server for Gemini image generation and image editing using a Google AI Studio API key.

This project is designed for fast AI-assisted iteration. For repo-specific guidance, see AGENTS.md, PROJECT_STATE.md, and ARCHITECTURE.md.

What It Does

  • Exposes exactly 2 MCP tools: image.generate and image.edit
  • Uses @google/genai with GOOGLE_API_KEY
  • Runs as a local stdio MCP server
  • Can also run from Docker with the same env contract
  • Saves generated images to disk and returns structured metadata
  • Supports reference-guided generation with anchor images
  • Uses a shared transparency pipeline across generate and edit

Requirements

  • Node.js 20+
  • A Google AI Studio API key with access to Gemini image-capable models

Environment

Copy .env.example to .env and fill in your key:

GOOGLE_API_KEY=your-google-ai-studio-api-key
AGILEIMAGEGEN_DEFAULT_MODEL=gemini-2.5-flash-image
AGILEIMAGEGEN_OUTPUT_DIR=./output
AGILEIMAGEGEN_LOG_LEVEL=info
AGILEIMAGEGEN_SAVE_PROMPTS=false

Notes:

  • GOOGLE_API_KEY is required.
  • AGILEIMAGEGEN_DEFAULT_MODEL can be overridden per tool call.
  • AGILEIMAGEGEN_OUTPUT_DIR is where generated images are written by default.
  • .env is gitignored and should stay local.

Local Development

Install dependencies:

cmd /c npm install

Run in dev mode:

cmd /c npm run dev

Build:

cmd /c npm run build

Run the built server:

cmd /c npm start

Run tests:

cmd /c npm test

Run live smoke tests:

cmd /c npm run smoke:generate
cmd /c npm run smoke:edit

Docker

Build:

docker build -t agileimagegen-mcp .

Run:

docker run --rm -i --env-file .env -v "${PWD}/output:/app/output" agileimagegen-mcp

The container expects to run as a stdio MCP server, so use -i and wire it through your MCP client.

MCP Client Example

Example local stdio MCP config:

{
  "mcpServers": {
    "agileimagegen": {
      "command": "node",
      "args": ["C:/git/agileimagegen-mcp/dist/server.js"],
      "cwd": "C:/git/agileimagegen-mcp",
      "env": {
        "GOOGLE_API_KEY": "your-key-here"
      }
    }
  }
}

If you prefer .env, keep the cwd pointed at this repo so the server can load it locally.

Tools

image.generate

Input:

{
  "prompt": "Arcade grime sewer cartoon logo",
  "model": "gemini-2.5-flash-image",
  "reference_image_paths": ["C:/temp/input/anchor-logo.png"],
  "size": "square",
  "background": "transparent",
  "transparency_mode": "repair",
  "transparency_threshold": "balanced",
  "filename_hint": "sewer-logo",
  "output_dir": "C:/temp/output"
}

Supported size inputs:

  • preset: square, landscape, portrait, widescreen
  • explicit: WIDTHxHEIGHT
  • or width + height

Transparency controls:

  • transparency_mode: off, validate, or repair
  • transparency_threshold: balanced or strict

Reference guidance:

  • reference_image_paths: optional local anchor images used to steer image.generate
  • when present, generate requests are sent as multimodal requests instead of text-only prompts

Defaults:

  • background: "transparent" implies transparency_mode: "repair"
  • otherwise transparency handling defaults to off
  • transparent workflows prefer a chroma-key background color of #01FF01, but can also accept good native alpha or infer and remove a different solid border color when the provider drifts
  • image.edit and image.generate both run through the same transparency validation/extraction pipeline

image.edit

Input:

{
  "prompt": "Make this sign grimier and add a toxic green edge glow",
  "input_image_paths": ["C:/temp/input/sign.png"],
  "model": "gemini-2.5-flash-image",
  "transparency_mode": "repair",
  "transparency_threshold": "balanced",
  "filename_hint": "sign-edit",
  "output_dir": "C:/temp/output"
}

For image.edit, transparency repair runs by default when the prompt implies transparent or alpha output.

Tool Output Shape

Both tools return structured content in this shape:

{
  "path": "C:/git/agileimagegen-mcp/output/123456-sewer-logo.png",
  "mime_type": "image/png",
  "model": "gemini-2.5-flash-image",
  "provider": "google",
  "prompt_summary": "Arcade grime sewer cartoon logo",
  "warnings": [],
  "width": 1024,
  "height": 1024,
  "transparency": {
    "requested": true,
    "mode": "repair",
    "threshold": "balanced",
    "source_mime_type": "image/jpeg",
    "has_alpha": true,
    "alpha_pixel_ratio": 0.44,
    "fully_transparent_ratio": 0.39,
    "opaque_border_ratio": 0.02,
    "checkerboard_detected": false,
    "key_color": "#01FF01",
    "key_color_match_ratio": 0.91,
    "background_mode": "keyed",
    "repair_attempted": true,
    "repair_succeeded": true,
    "warnings": []
  }
}

Design Notes

  • Width, height, size, and transparent background are passed as prompt guidance because Gemini image-capable models may not honor them as hard output controls in all cases.
  • When transparency is requested, the server uses a tiered strategy: accept usable native alpha first, otherwise prefer the requested #01FF01 chroma-key background, then fall back to inferring and removing a different solid border color.
  • Provider-native transparency is still validated before use; opaque outputs are converted to transparency only when the background is cleanly separable.
  • Transparency diagnostics are returned to the caller so layered asset workflows can reason about confidence, repair attempts, and failure modes.
  • Prompt specialization is intentionally out of scope for this repo. Project-specific prompt rules should live in the caller’s skill/workflow layer.
  • Error messages are sanitized so normal failures do not leak raw API keys.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选