@jordyvd/openrouter-imagegen-mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +184 -0
  2. package/dist/index.js +62475 -0
  3. package/package.json +52 -0
package/README.md ADDED
@@ -0,0 +1,184 @@
1
+ # ImageGen MCP Server
2
+
3
+ An MCP (Model Context Protocol) server for AI image generation and editing using OpenRouter and Google Gemini.
4
+
5
+ ## Features
6
+
7
+ - **Generate images** from text prompts using Gemini Flash Image Preview
8
+ - **Edit existing images** with natural language instructions (e.g., "make the sky orange")
9
+ - **S3 image hosting** - upload images to S3-compatible storage (MinIO, Cloudflare R2, etc.) and return public URLs
10
+ - **Conversation persistence** - pick up where you left off with saved conversation history
11
+ - **Automatic image saving** - all generated images saved to disk with metadata
12
+ - **API request logging** - debug logs saved to conversation folders
13
+
14
+ ## Prerequisites
15
+
16
+ - [Bun](https://bun.sh) runtime (v1.0+)
17
+ - [OpenRouter](https://openrouter.ai) API key
18
+
19
+ ## Installation
20
+
21
+ 1. Clone the repository:
22
+ ```bash
23
+ git clone https://github.com/yourusername/imagegen-mcp.git
24
+ cd imagegen-mcp
25
+ ```
26
+
27
+ 2. Install dependencies:
28
+ ```bash
29
+ bun install
30
+ ```
31
+
32
+ 3. Get an API key from [OpenRouter](https://openrouter.ai/settings/keys)
33
+
34
+ ## Configuration
35
+
36
+ ### Claude Desktop (Windows)
37
+
38
+ Add to your Claude Desktop config at `%APPDATA%\Claude\claude_desktop_config.json`:
39
+
40
+ ```json
41
+ {
42
+ "mcpServers": {
43
+ "imagegen": {
44
+ "command": "bun",
45
+ "args": ["run", "C:\\path\\to\\imagegen-mcp\\index.ts"],
46
+ "env": {
47
+ "OPENROUTER_API_KEY": "your-api-key-here"
48
+ }
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ ### Claude Desktop (Windows with WSL2)
55
+
56
+ If running Bun through WSL:
57
+
58
+ ```json
59
+ {
60
+ "mcpServers": {
61
+ "imagegen": {
62
+ "command": "wsl",
63
+ "args": ["bun", "run", "/home/user/projects/imagegen-mcp/index.ts"],
64
+ "env": {
65
+ "OPENROUTER_API_KEY": "your-api-key-here"
66
+ }
67
+ }
68
+ }
69
+ }
70
+ ```
71
+
72
+ ### Claude Desktop (macOS/Linux)
73
+
74
+ ```json
75
+ {
76
+ "mcpServers": {
77
+ "imagegen": {
78
+ "command": "bun",
79
+ "args": ["run", "/path/to/imagegen-mcp/index.ts"],
80
+ "env": {
81
+ "OPENROUTER_API_KEY": "your-api-key-here"
82
+ }
83
+ }
84
+ }
85
+ }
86
+ ```
87
+
88
+ ## S3 Image Hosting (Optional)
89
+
90
+ For server deployments (e.g., Coolify, Docker), you can configure S3-compatible storage to host images and return public URLs instead of local file paths.
91
+
92
+ ### Environment Variables
93
+
94
+ | Variable | Required | Description |
95
+ |----------|----------|-------------|
96
+ | `S3_ENDPOINT` | Yes | S3-compatible endpoint URL (e.g., `https://minio.example.com`) |
97
+ | `S3_BUCKET` | Yes | Bucket name for storing images |
98
+ | `S3_ACCESS_KEY_ID` | Yes | S3 access key ID |
99
+ | `S3_SECRET_ACCESS_KEY` | Yes | S3 secret access key |
100
+ | `S3_PUBLIC_URL_BASE` | Yes | Public URL base for accessing images (e.g., `https://cdn.example.com/bucket`) |
101
+ | `S3_REGION` | No | S3 region (default: `auto`) |
102
+ | `S3_PREFIX` | No | Path prefix for uploaded images (default: `images`) |
103
+
104
+ ### Example: Coolify with MinIO
105
+
106
+ ```bash
107
+ # In your Coolify environment variables:
108
+ OPENROUTER_API_KEY=sk-or-...
109
+ S3_ENDPOINT=https://minio.yourdomain.com
110
+ S3_BUCKET=imagegen
111
+ S3_ACCESS_KEY_ID=your-access-key
112
+ S3_SECRET_ACCESS_KEY=your-secret-key
113
+ S3_PUBLIC_URL_BASE=https://minio.yourdomain.com/imagegen
114
+ S3_REGION=auto
115
+ S3_PREFIX=generated
116
+ ```
117
+
118
+ ### Example: Cloudflare R2
119
+
120
+ ```bash
121
+ S3_ENDPOINT=https://your-account-id.r2.cloudflarestorage.com
122
+ S3_BUCKET=imagegen
123
+ S3_ACCESS_KEY_ID=your-r2-access-key
124
+ S3_SECRET_ACCESS_KEY=your-r2-secret-key
125
+ S3_PUBLIC_URL_BASE=https://your-r2-public-url.com
126
+ ```
127
+
128
+ When S3 is configured, generated images will be uploaded and the tool will return `IMAGE_URL: https://...` instead of `IMAGE_PATH: /local/path/...`.
129
+
130
+ ## Usage
131
+
132
+ Once configured, the following tools are available in Claude:
133
+
134
+ ### `generate_image`
135
+ Create a new image from a text prompt.
136
+
137
+ **Example:** "Generate an image of a cat sitting on a rainbow"
138
+
139
+ ### `edit_image`
140
+ Modify an existing image with natural language instructions. The model receives the previous image and attempts to make only the requested changes.
141
+
142
+ **Example:** "Make the cat's fur orange" or "Add sunglasses to the cat"
143
+
144
+ ### `handle_generated_image`
145
+ Opens the generated image in your system's default image viewer. Called automatically after generation.
146
+
147
+ ### `list_conversations`
148
+ View all saved image generation conversations with their IDs and descriptions.
149
+
150
+ ### `clear_conversation`
151
+ Delete a specific conversation or all conversations from disk.
152
+
153
+ ## How It Works
154
+
155
+ 1. **Image Generation**: Prompts are sent to Gemini Flash Image Preview via OpenRouter
156
+ 2. **Image Editing**: The previous image is sent inline with edit instructions for better results
157
+ 3. **Persistence**: Images saved to `images/{conversation_id}/` with `messages.json` tracking history
158
+ 4. **Logging**: API requests/responses logged to `request-{timestamp}.json` for debugging
159
+
160
+ ## File Structure
161
+
162
+ ```
163
+ imagegen-mcp/
164
+ ├── index.ts # Main MCP server
165
+ ├── images/ # Generated images and conversation data
166
+ │ └── {conv-id}/
167
+ │ ├── *.png # Generated images
168
+ │ ├── messages.json # Conversation history
169
+ │ ├── README.md # Conversation summary
170
+ │ └── request-*.json # API logs
171
+ ├── package.json
172
+ └── tsconfig.json
173
+ ```
174
+
175
+ ## Development
176
+
177
+ Run the server directly:
178
+ ```bash
179
+ OPENROUTER_API_KEY=your-key bun run index.ts
180
+ ```
181
+
182
+ ## License
183
+
184
+ MIT