File size: 1,874 Bytes
4dc437c
 
3f4aae4
 
4dc437c
 
3f4aae4
4dc437c
 
3f4aae4
4dc437c
 
3f4aae4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0b26f38
 
3f4aae4
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
---
title: ImageGenMCP
emoji: ๐ŸŽจ
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.31.0
app_file: app.py
pinned: false
license: mit
---

# ImageGenMCP - Image Generation MCP Server

A Gradio-based image generation application using Google's Gemini 2.0 Flash Preview model, designed to work as an MCP (Model Context Protocol) server for Claude Code.

## Features

- ๐ŸŽจ High-quality image generation using Gemini 2.0 Flash Preview
- ๐Ÿ–ผ๏ธ Support for reference images to guide generation
- ๐Ÿ”ง MCP server integration for Claude Code
- ๐ŸŒ Web interface powered by Gradio 5.31.0
- ๐Ÿ“ Detailed logging for debugging

## Setup

### Environment Variables

Set your Gemini API key:

```bash
export GEMINI_API_KEY="your-gemini-api-key"
```

### Local Development

1. Install dependencies:
```bash
pip install -r requirements.txt
```

2. Run the application:

**Web UI mode:**
```bash
python app.py
```

**MCP server mode:**
```bash
python app.py --mcp
```

## Usage with Claude Code

Add this configuration to your Claude Code settings:

```json
{
  "mcpServers": {
    "image-gen": {
      "command": "python",
      "args": ["/path/to/app.py", "--mcp"],
      "env": {
        "GEMINI_API_KEY": "your-api-key"
      }
    }
  }
}
```

## API

### MCP Tool: `generate_image`

**Description:** Generates images using Gemini 2.0 Flash Preview

**Parameters:**
- `prompt` (string, required): Description of the image to generate

**Returns:**
- `success` (boolean): Whether generation was successful
- `message` (string): Status message
- `image_url` (string): URL to access the generated image (if successful)
- `image_path` (string): Local file path of the generated image (if successful)

## Requirements

- Python 3.8+
- Gemini API key with access to `gemini-2.0-flash-preview-image-generation` model
- Dependencies listed in `requirements.txt`

## License

MIT