图像生成MCP服务器

基于Gemini AI的图像生成MCP服务器,提供文本生成图像并保存或返回base64数据的功能。

  • by c0detnr
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 Emirix/Gemini-Image-MCP

使用说明

Gemini Image Generator MCP Server

A Model Context Protocol (MCP) server that generates images using Google's Gemini AI.

Installation

Via npx (recommended)

npx gemini-image-mcp

Via npm (global install)

npm install -g gemini-image-mcp
gemini-image-mcp

From source

git clone https://github.com/YOUR_USERNAME/gemini-image-mcp.git
cd gemini-image-mcp
npm install
npm run build
npm start

Features

  • generate_image: Generate an image from a text prompt and save it to a file
  • generate_image_base64: Generate an image and return it as base64 encoded data

Prerequisites

Configuration

Set your API key as an environment variable:

# Windows PowerShell
$env:GEMINI_API_KEY = "your-api-key-here"

# Windows CMD
set GEMINI_API_KEY=your-api-key-here

# Linux/macOS
export GEMINI_API_KEY="your-api-key-here"

Or use GOOGLE_API_KEY instead.

Integration with Claude Desktop

Add the following to your Claude Desktop configuration file:

Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Using npx

{
  "mcpServers": {
    "gemini-image": {
      "command": "npx",
      "args": ["-y", "gemini-image-mcp"],
      "env": {
        "GEMINI_API_KEY": "your-api-key-here"
      }
    }
  }
}

Using local installation

{
  "mcpServers": {
    "gemini-image": {
      "command": "node",
      "args": ["C:\\path\\to\\gemini-image-mcp\\dist\\index.js"],
      "env": {
        "GEMINI_API_KEY": "your-api-key-here"
      }
    }
  }
}

Testing with MCP Inspector

npx @modelcontextprotocol/inspector npx gemini-image-mcp

Or from source:

npm run inspector

Tool Reference

generate_image

Generates an image and saves it to a file.

Parameters:

  • prompt (required): The text description of the image to generate
  • outputPath (optional): Where to save the image. Defaults to generated_image_<timestamp>.png

Example:

Generate an image of a futuristic city at sunset

generate_image_base64

Generates an image and returns it as base64 data.

Parameters:

  • prompt (required): The text description of the image to generate

Example:

Create a picture of a nano banana dish in a fancy restaurant

Publishing to npm

  1. Create an npm account at npmjs.com

  2. Login to npm:

npm login
  1. Publish:
npm publish

License

MIT