Gemini 2.5 Flash Image MCP

Gemini 2.5 Flash Image MCP

Enables conversational image generation and editing with Google's Gemini 2.5 Flash Image Preview. Supports text-to-image generation, natural language image editing, multi-image composition, and style transfer with optional file saving.

Category
访问服务器

README

Gemini 2.5 Flash Image MCP

A Model Context Protocol (MCP) server for conversational image generation and editing with Google's Gemini 2.5 Flash Image Preview. Designed to be easy to install and use from Claude Code and other MCP clients.

Key Features

  • Text-to-Image: Generate images from detailed prompts
  • Image Editing: Edit images with natural language instructions
  • Multi-Image Composition / Style Transfer: Combine images or transfer styles
  • File Save Option: Return base64 image and optionally save to file
  • Provider-Agnostic MCP: Works in any MCP-enabled client

Requirements

  • Node.js 18 or newer
  • An MCP client (Claude Code, Cursor, VS Code, Windsurf, etc.)
  • Google Gemini API Key: set GEMINI_API_KEY

Get a Gemini API key

Follow these steps to obtain an API key from Google AI Studio:

  1. Open Google AI Studio and sign in: https://aistudio.google.com/apikey
  2. Click “Create API key” (or “Manage keys” if you already have one)
  3. Copy the generated key
  4. Set it as an environment variable on your machine when running this server

Examples:

# macOS / Linux (bash/zsh)
export GEMINI_API_KEY="YOUR_API_KEY"

# Windows PowerShell
$env:GEMINI_API_KEY="YOUR_API_KEY"

Getting Started

First, install the MCP server with your client. The following examples center on Claude Code usage.

Standard config works in most tools:

{
  "mcpServers": {
    "gemini-2-5-flash-mcp": {
      "command": "npx",
      "args": ["@taiyokimura/gemini-2-5-flash-mcp@latest"]
    }
  }
}

Quick usage (Claude Code)

# npx(非対話フラグ付き) + APIキー同時指定(Claudeの -e 指定)
claude mcp add gemini-2-5-flash-mcp -s user -e GEMINI_API_KEY="YOUR_API_KEY" -- npx -y @taiyokimura/gemini-2-5-flash-mcp@latest

# グローバルインストール + APIキー同時指定(Claudeの -e 指定)
npm i -g @taiyokimura/gemini-2-5-flash-mcp \
  && claude mcp add gemini-2-5-flash-mcp -s user -e GEMINI_API_KEY="YOUR_API_KEY" -- gemini-2-5-flash-mcp

# HTTP モードで登録(SSE既定)例(対応クライアントのみ)
# ※ HTTP モードはこのプロセス自体がHTTPサーバとして常駐します
claude mcp add gemini-2-5-flash-mcp -s user \
  -e GEMINI_API_KEY="YOUR_API_KEY" \
  -e MCP_TRANSPORT="http" \
  -e MCP_HTTP_PORT="7801" \
  -e MCP_HTTP_PATH="/mcp" \
  -- npx -y @taiyokimura/gemini-2-5-flash-mcp@latest

Streamable HTTP mode(実験的)

STDIO の代わりに Streamable HTTP を使うこともできます。MCP クライアントが Streamable HTTP に対応している場合のみ利用してください。

  1. サーバーを HTTP モードで起動
export MCP_TRANSPORT=http
export GEMINI_API_KEY=YOUR_API_KEY
# 任意(既定: 7801, /mcp, SSE)
export MCP_HTTP_PORT=7801
export MCP_HTTP_PATH=/mcp
export MCP_HTTP_ENABLE_JSON=false

npm run build
node ./build/index.js
# => HTTP transport listening on http://localhost:7801/mcp
  1. クライアント側設定(例: Streamable HTTP対応クライアント)
  • Type: HTTP (Streamable)
  • URL: http://localhost:7801/mcp

注:

  • SSE ストリーミングが既定。JSONレスポンスで使いたい場合は MCP_HTTP_ENABLE_JSON=true
  • セッションはサーバー側で生成(stateful)。完全 stateless にしたい場合はコード側で sessionIdGenerator: undefined に変更可能です。

<details> <summary><b>Claude Code (Recommended)</b></summary>

Use the Claude Code CLI to add the MCP server:

claude mcp add gemini-2-5-flash-mcp -s user -- npx @taiyokimura/gemini-2-5-flash-mcp@latest

Remove if needed:

claude mcp remove gemini-2-5-flash-mcp

</details>

<details> <summary>Claude Desktop</summary>

Follow the MCP install guide and use the standard config above.

  • Guide: https://modelcontextprotocol.io/quickstart/user </details>

<details> <summary>Cursor</summary>

Go to Cursor SettingsMCPAdd new MCP Server.

Use the following:

  • Name: gemini-2-5-flash-mcp
  • Type: command
  • Command: npx
  • Args: @taiyokimura/gemini-2-5-flash-mcp@latest
  • Auto start: on (optional) </details>

<details> <summary>VS Code</summary>

Add via CLI:

code --add-mcp '{"name":"gemini-2-5-flash-mcp","command":"npx","args":["@taiyokimura/gemini-2-5-flash-mcp@latest"]}'

Or use the standard config in settings. </details>

<details> <summary>LM Studio</summary>

Add MCP Server with:

  • Command: npx
  • Args: ["@taiyokimura/gemini-2-5-flash-mcp@latest"] </details>

<details> <summary>Goose</summary>

Advanced settings → Extensions → Add custom extension:

  • Type: STDIO
  • Command: npx
  • Args: @taiyokimura/gemini-2-5-flash-mcp@latest
  • Enabled: true </details>

<details> <summary>opencode</summary>

Example ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "gemini-2-5-flash-mcp": {
      "type": "local",
      "command": [
        "npx",
        "@taiyokimura/gemini-2-5-flash-mcp@latest"
      ],
      "enabled": true
    }
  }
}

</details>

<details> <summary>Qodo Gen</summary>

Open Qodo Gen → Connect more tools → + Add new MCP → Paste the standard config above → Save. </details>

<details> <summary>Windsurf</summary>

Follow Windsurf MCP documentation and use the standard config above.

  • Docs: https://docs.windsurf.com/windsurf/cascade/mcp </details>

Environment Variables

  • GEMINI_API_KEY (required)
  • GEMINI_IMAGE_ENDPOINT (optional) default: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image-preview:generateContent
  • MCP_NAME (optional, default: gemini-2-5-flash-mcp)

Available Tools

1. generate_image

Generate an image from a text prompt.

Parameters:

  • prompt (required): Detailed description to generate
  • saveToFilePath (optional): Path to save the image

Example input:

{
  "prompt": "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme",
  "saveToFilePath": "./gemini-native-image.png"
}

2. edit_image

Edit an image using a prompt.

Parameters:

  • prompt (required): Edit instruction
  • image (required): { dataBase64?: string, path?: string, mimeType?: string }
  • saveToFilePath (optional)

Example input:

{
  "prompt": "Add a small, knitted wizard hat to the cat",
  "image": { "path": "./cat.jpeg", "mimeType": "image/jpeg" },
  "saveToFilePath": "./gemini-edited-image.png"
}

3. compose_images

Combine elements from multiple images.

Parameters:

  • prompt (required)
  • images (required): Array of image inputs (2-3 recommended)
  • saveToFilePath (optional)

4. style_transfer

Transfer the style of one image to another.

Parameters:

  • prompt (optional)
  • baseImage (required)
  • styleImage (required)
  • saveToFilePath (optional)

Development

Run locally:

npm install
npm run build
npx .

Name Consistency & Troubleshooting

  • Always use CANONICAL_ID (gemini-2-5-flash-mcp) for identifiers and keys.
  • Use CANONICAL_DISPLAY (Gemini 2.5 Flash MCP) only for UI labels.
  • Do not mix different names across clients.

Consistency Matrix:

  • npm package name → gemini-2-5-flash-mcp
  • Binary name → gemini-2-5-flash-mcp
  • MCP server name (SDK metadata) → gemini-2-5-flash-mcp
  • Env default MCP_NAME → gemini-2-5-flash-mcp
  • Client registry key → gemini-2-5-flash-mcp
  • UI label → Gemini 2.5 Flash MCP

Conflict Cleanup:

  • Remove any old entries like "GeminiFlash" and re-add with gemini-2-5-flash-mcp.
  • Ensure global registries only use gemini-2-5-flash-mcp for keys.
  • Cursor: configure in the UI only. This project does not include .cursor/mcp.json.

References

  • MCP SDK: https://modelcontextprotocol.io/docs/sdks
  • Architecture: https://modelcontextprotocol.io/docs/learn/architecture
  • Server concepts: https://modelcontextprotocol.io/docs/learn/server-concepts
  • Server spec (2025-06-18): https://modelcontextprotocol.io/specification/2025-06-18/server/index
  • Gemini image generation: https://ai.google.dev/gemini-api/docs/image-generation

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选