Skip to main content
Glama
Gemini Image Generator MCP

Gemini Image Generator MCP

Gemini 画像生成器 MCP サーバー (修正版)

Claude DesktopでGoogle の Gemini AIを使用して高品質な画像を生成・編集できる MCP サーバーです。

🚀 主な特徴

  • テキストから画像生成: Gemini 2.0 Flash を使用したテキスト→画像変換

  • 画像変換: 既存の画像をテキストプロンプトで修正

  • 多言語対応: 日本語・韓国語・中国語プロンプトの自動英語翻訳・最適化

  • AI ファイル名生成: プロンプト基準でファイル名を自動生成

  • ローカル保存: 生成された画像を指定フォルダに自動保存

  • Claude チャット内表示: 生成された画像をチャット画面で直接確認

Related MCP server: NanoBanana MCP

🛠️ インストール要件

  • Python 3.11 以上

  • Google Gemini API キー

  • Claude Desktop またはその他 MCP 互換クライアント

📋 ステップ1: Gemini API キー発行

  1. Google AI Studio API Keys ページ にアクセス

  2. Google アカウントでログイン

  3. "Create API Key" をクリック

  4. 生成された API キーをコピー(後で使用)

💾 ステップ2: MCP サーバーインストール

自動インストール(推奨)

# リポジトリクローン
git clone https://github.com/sungmin-koo-ai/GeminiImageMCP.git
cd GeminiImageMCP

# 仮想環境作成・有効化
python3 -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# パッケージインストール
pip install -e .

インストール確認

# サーバーが正常実行されるかテスト
python -m gemini_image_mcp.server

Starting Gemini Image Generator MCP server... メッセージが表示されれば成功!(Ctrl+CまたはCtrl+Z で終了)

⚙️ ステップ3: Claude Desktop 設定

設定ファイル場所

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

設定ファイル内容

{
  "mcpServers": {
    "gemini-image-generator": {
      "command": "/Users/ユーザー名/GeminiImageMCP/venv/bin/python",
      "args": [
        "-m", "gemini_image_mcp.server"
      ],
      "env": {
        "GEMINI_API_KEY": "ここに実際のAPIキーを入力",
        "OUTPUT_IMAGE_PATH": "/Users/ユーザー名/Pictures/ai_generated"
      }
    }
  }
}

実際の設定例

{
  "mcpServers": {
    "gemini-image-generator": {
      "command": "/Users/ユーザー名/GeminiImageMCP/venv/bin/python",
      "args": [
        "-m", "gemini_image_mcp.server"
      ],
      "env": {
        "GEMINI_API_KEY": "AIzaSy...(実際のAPIキー)",
        "OUTPUT_IMAGE_PATH": "/Users/ユーザー名/Pictures/ai_generated"
      }
    }
  }
}

スクリプト命令を使用する場合(簡単設定)

{
  "mcpServers": {
    "gemini-image-generator": {
      "command": "/Users/ユーザー名/GeminiImageMCP/venv/bin/gemini-image-mcp",
      "env": {
        "GEMINI_API_KEY": "AIzaSy...(実際のAPIキー)",
        "OUTPUT_IMAGE_PATH": "/Users/ユーザー名/Pictures/ai_generated"
      }
    }
  }
}

※ この方法は args 指定が不要でより簡潔です

🚨 重要事項

  1. 絶対パス使用: すべてのパスは完全パスで入力

  2. API キー置換: ここに実際のAPIキーを入力 部分を発行した実際のキーに置換

  3. 画像フォルダ: OUTPUT_IMAGE_PATH に指定したフォルダが事前に作成されている必要があります

画像保存フォルダ作成

mkdir -p ~/Pictures/ai_generated

🎯 ステップ4: 実行・テスト

  1. Claude Desktop 再起動: 設定後完全に終了して再起動

  2. 接続確認: Claude Desktop で MCP サーバーが接続されたか確認

  3. テスト: 「猫の絵を描いて」とリクエストしてみる

📖 使用方法

画像生成

東京タワーの可愛いイラストを描いて

画像変換(ファイルパス)

/Users/username/image.jpg この画像に虹を追加して

画像変換(アップロード)

画像を Claude にアップロード後:

背景をレインボーブリッジの夜景にしてくれ

🔧 トラブルシューティング

サーバー接続失敗

  1. ログ確認: Claude Desktop のログフォルダで gemini-image-generator.log を確認

  2. パス確認: claude_desktop_config.json の Python パスが正確か確認

  3. 権限確認: 画像保存フォルダに書き込み権限があるか確認

API キーエラー

  1. キー有効性: Google AI Studio で API キーが有効化されているか確認

  2. 引用符確認: 設定ファイルで API キーが引用符で囲まれているか確認

手動テスト

cd ~/GeminiImageMCP
source venv/bin/activate
export GEMINI_API_KEY="実際のAPIキー"
export OUTPUT_IMAGE_PATH="~/Pictures/ai_generated"
python -m gemini_image_mcp.server

📊 提供ツール

1. generate_image_from_text

  • 機能: テキストプロンプトで新しい画像生成

  • 入力: 画像説明テキスト

  • 出力: 生成された画像(Claude チャット内表示 + ローカル保存)

2. transform_image_from_file

  • 機能: ファイルパスの画像をテキストプロンプトで変換

  • 入力: 画像ファイルパス、変換プロンプト

  • 出力: 変換された画像(Claude チャット内表示 + ローカル保存)

3. transform_image_from_encoded

  • 機能: Base64 エンコードされた画像をテキストプロンプトで変換

  • 入力: Base64 画像データ、変換プロンプト

  • 出力: 変換された画像(Claude チャット内表示 + ローカル保存)

📝 オリジナルからの相違点

この修正版は元のリポジトリの以下の問題を解決しました:

  • ❌ 元の問題: JSON シリアル化エラー (invalid utf-8 sequence)

  • ❌ 元の問題: MCP ツールがバイナリデータ返却により実行失敗

  • ✅ 修正事項: ファイルパス返却で安定的な動作

  • ✅ 修正事項: Claude Desktop で完璧に動作

  • ✅ 修正事項: 生成された画像を Claude チャット内で直接確認可能

🤝 貢献・お問い合わせ

📄 ライセンス

MIT License - 元のプロジェクトと同じ


ヒント: 初回設定時はステップごとに進め、問題が発生した場合はまずログファイルを確認してください! 🚀

Available Tools

3 tools
generate_image_from_textA

Generate an image based on the given text prompt using Google's Gemini model.

Args:
    prompt: User's text prompt describing the desired image to generate
    
Returns:
    Path to the generated image file using Gemini's image generation capabilities

Inputs: prompt (required).

transform_image_from_encodedA

Transform an existing image based on the given text prompt using Google's Gemini model.

Args:
    encoded_image: Base64 encoded image data with header. Must be in format:
                "data:image/[format];base64,[data]"
                Where [format] can be: png, jpeg, jpg, gif, webp, etc.
    prompt: Text prompt describing the desired transformation or modifications
    
Returns:
    Path to the transformed image file saved on the server

Inputs: encoded_image (required), prompt (required).

transform_image_from_fileA

Transform an existing image file based on the given text prompt using Google's Gemini model.

Args:
    image_file_path: Path to the image file to be transformed
    prompt: Text prompt describing the desired transformation or modifications
    
Returns:
    Path to the transformed image file saved on the server

Inputs: image_file_path (required), prompt (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 3 tools

    Disambiguation4/5

    The three tools have distinct purposes: one generates images from text, while the other two transform existing images but differ in input method (encoded data vs. file path). There is minor overlap between the two transform tools, as they serve similar functions with different input formats, which could cause slight confusion, but their descriptions clearly differentiate them.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun_from_noun pattern (e.g., generate_image_from_text, transform_image_from_encoded, transform_image_from_file). This uniformity makes the set predictable and easy to understand, with no deviations in style or convention.

    Tool Count3/5

    With only 3 tools, the server feels slightly thin for an image generation domain, as it lacks operations like listing, deleting, or managing generated images. However, the count is reasonable for basic functionality, covering core tasks without being excessive.

    Completeness3/5

    The tools cover generation and transformation of images, which are key operations, but there are notable gaps. For example, there is no way to retrieve, update, or delete generated images, and no tools for batch processing or status checking, which could limit agent workflows in a full image management context.

    Related MCP Connectors

    Related MCP Servers