ultimate-gemini-mcp 1.0.19__tar.gz → 1.6.0__tar.gz
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.
Potentially problematic release.
This version of ultimate-gemini-mcp might be problematic. Click here for more details.
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/PKG-INFO +44 -5
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/README.md +43 -4
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/pyproject.toml +1 -1
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/src/__init__.py +1 -1
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/src/config/constants.py +1 -1
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/src/core/validation.py +7 -5
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/src/server.py +1 -22
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/src/services/image_service.py +6 -4
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/src/tools/batch_generate.py +16 -7
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/src/tools/generate_image.py +26 -20
- ultimate_gemini_mcp-1.0.19/.genkit/traces_idx/genkit.metadata +0 -1
- ultimate_gemini_mcp-1.0.19/FIX_VERIFICATION_TEST_PLAN.md +0 -601
- ultimate_gemini_mcp-1.0.19/app.py +0 -17
- ultimate_gemini_mcp-1.0.19/raw_response.json +0 -8
- ultimate_gemini_mcp-1.0.19/request.json +0 -14
- ultimate_gemini_mcp-1.0.19/request_exact.json +0 -14
- ultimate_gemini_mcp-1.0.19/response_exact.json +0 -8
- ultimate_gemini_mcp-1.0.19/src/prompts/__init__.py +0 -1
- ultimate_gemini_mcp-1.0.19/src/resources/__init__.py +0 -1
- ultimate_gemini_mcp-1.0.19/src/utils/__init__.py +0 -1
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/.env.example +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/.github/workflows/README.md +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/.github/workflows/claude-code-review.yml +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/.github/workflows/claude.yml +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/.github/workflows/publish.yml +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/.github/workflows/test.yml +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/.gitignore +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/CLAUDE.md +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/LICENSE +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/MANIFEST.in +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/PUBLISHING.md +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/TEST_RESULTS.md +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/src/config/__init__.py +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/src/config/settings.py +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/src/core/__init__.py +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/src/core/exceptions.py +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/src/services/__init__.py +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/src/services/gemini_client.py +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/src/services/imagen_client.py +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/src/services/prompt_enhancer.py +0 -0
- {ultimate_gemini_mcp-1.0.19 → ultimate_gemini_mcp-1.6.0}/src/tools/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ultimate-gemini-mcp
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.6.0
|
|
4
4
|
Summary: Ultimate image generation MCP server unifying Gemini 2.5 Flash Image and Imagen 4/Fast/Ultra with advanced features
|
|
5
5
|
Project-URL: Homepage, https://github.com/anand-92/ultimate-image-gen-mcp
|
|
6
6
|
Project-URL: Repository, https://github.com/anand-92/ultimate-image-gen-mcp
|
|
@@ -201,13 +201,25 @@ Add to your `claude_desktop_config.json`:
|
|
|
201
201
|
"command": "uvx",
|
|
202
202
|
"args": ["ultimate-gemini-mcp"],
|
|
203
203
|
"env": {
|
|
204
|
-
"GEMINI_API_KEY": "your-api-key-here"
|
|
204
|
+
"GEMINI_API_KEY": "your-api-key-here",
|
|
205
|
+
"OUTPUT_DIR": "/path/to/your/images"
|
|
205
206
|
}
|
|
206
207
|
}
|
|
207
208
|
}
|
|
208
209
|
}
|
|
209
210
|
```
|
|
210
211
|
|
|
212
|
+
**Important Notes:**
|
|
213
|
+
|
|
214
|
+
1. **OUTPUT_DIR is required** when using `uvx` to avoid read-only file system errors. Set it to an absolute path where you want generated images saved:
|
|
215
|
+
- **macOS**: `"/Users/yourusername/gemini_images"`
|
|
216
|
+
- **Windows**: `"C:\\Users\\YourUsername\\gemini_images"`
|
|
217
|
+
|
|
218
|
+
2. **uvx path issues on macOS**: If you get `spawn uvx ENOENT` errors, use the full path to uvx:
|
|
219
|
+
```json
|
|
220
|
+
"command": "/Users/yourusername/.local/bin/uvx"
|
|
221
|
+
```
|
|
222
|
+
|
|
211
223
|
**Config file locations:**
|
|
212
224
|
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
213
225
|
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
@@ -215,10 +227,15 @@ Add to your `claude_desktop_config.json`:
|
|
|
215
227
|
### With Claude Code (VS Code)
|
|
216
228
|
|
|
217
229
|
```bash
|
|
218
|
-
# Add MCP server to Claude Code
|
|
219
|
-
claude mcp add ultimate-gemini
|
|
230
|
+
# Add MCP server to Claude Code (with required OUTPUT_DIR)
|
|
231
|
+
claude mcp add ultimate-gemini \
|
|
232
|
+
--env GEMINI_API_KEY=your-api-key \
|
|
233
|
+
--env OUTPUT_DIR=/path/to/your/images \
|
|
234
|
+
-- uvx ultimate-gemini-mcp
|
|
220
235
|
```
|
|
221
236
|
|
|
237
|
+
**Note**: Replace `/path/to/your/images` with an absolute path to where you want images saved.
|
|
238
|
+
|
|
222
239
|
### With Cursor
|
|
223
240
|
|
|
224
241
|
Add to Cursor's MCP configuration (`.cursor/mcp.json`):
|
|
@@ -230,13 +247,16 @@ Add to Cursor's MCP configuration (`.cursor/mcp.json`):
|
|
|
230
247
|
"command": "uvx",
|
|
231
248
|
"args": ["ultimate-gemini-mcp"],
|
|
232
249
|
"env": {
|
|
233
|
-
"GEMINI_API_KEY": "your-api-key-here"
|
|
250
|
+
"GEMINI_API_KEY": "your-api-key-here",
|
|
251
|
+
"OUTPUT_DIR": "/path/to/your/images"
|
|
234
252
|
}
|
|
235
253
|
}
|
|
236
254
|
}
|
|
237
255
|
}
|
|
238
256
|
```
|
|
239
257
|
|
|
258
|
+
**Note**: Set `OUTPUT_DIR` to an absolute path where you want generated images saved.
|
|
259
|
+
|
|
240
260
|
## 🎯 Available Models
|
|
241
261
|
|
|
242
262
|
### Gemini Models
|
|
@@ -412,6 +432,24 @@ View current server configuration.
|
|
|
412
432
|
|
|
413
433
|
## 🐛 Troubleshooting
|
|
414
434
|
|
|
435
|
+
### "spawn uvx ENOENT" error
|
|
436
|
+
- **Cause**: Claude Desktop cannot find the `uvx` command in its PATH
|
|
437
|
+
- **Solution**: Use the full path to uvx in your config:
|
|
438
|
+
```json
|
|
439
|
+
"command": "/Users/yourusername/.local/bin/uvx"
|
|
440
|
+
```
|
|
441
|
+
- Find your uvx location with: `which uvx`
|
|
442
|
+
|
|
443
|
+
### "[Errno 30] Read-only file system: 'generated_images'"
|
|
444
|
+
- **Cause**: When using `uvx`, the default directory is in a read-only cache location
|
|
445
|
+
- **Solution**: Add `OUTPUT_DIR` to your MCP config:
|
|
446
|
+
```json
|
|
447
|
+
"env": {
|
|
448
|
+
"GEMINI_API_KEY": "your-key",
|
|
449
|
+
"OUTPUT_DIR": "/Users/yourusername/gemini_images"
|
|
450
|
+
}
|
|
451
|
+
```
|
|
452
|
+
|
|
415
453
|
### "GEMINI_API_KEY not found"
|
|
416
454
|
- Add your API key to `.env` or environment variables
|
|
417
455
|
- Get a free key at [Google AI Studio](https://makersuite.google.com/app/apikey)
|
|
@@ -427,6 +465,7 @@ View current server configuration.
|
|
|
427
465
|
### Images not saving
|
|
428
466
|
- Check that OUTPUT_DIR exists and is writable
|
|
429
467
|
- Verify you have sufficient disk space
|
|
468
|
+
- Create the directory manually: `mkdir -p /path/to/your/images`
|
|
430
469
|
|
|
431
470
|
## 🤝 Contributing
|
|
432
471
|
|
|
@@ -165,13 +165,25 @@ Add to your `claude_desktop_config.json`:
|
|
|
165
165
|
"command": "uvx",
|
|
166
166
|
"args": ["ultimate-gemini-mcp"],
|
|
167
167
|
"env": {
|
|
168
|
-
"GEMINI_API_KEY": "your-api-key-here"
|
|
168
|
+
"GEMINI_API_KEY": "your-api-key-here",
|
|
169
|
+
"OUTPUT_DIR": "/path/to/your/images"
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
173
|
}
|
|
173
174
|
```
|
|
174
175
|
|
|
176
|
+
**Important Notes:**
|
|
177
|
+
|
|
178
|
+
1. **OUTPUT_DIR is required** when using `uvx` to avoid read-only file system errors. Set it to an absolute path where you want generated images saved:
|
|
179
|
+
- **macOS**: `"/Users/yourusername/gemini_images"`
|
|
180
|
+
- **Windows**: `"C:\\Users\\YourUsername\\gemini_images"`
|
|
181
|
+
|
|
182
|
+
2. **uvx path issues on macOS**: If you get `spawn uvx ENOENT` errors, use the full path to uvx:
|
|
183
|
+
```json
|
|
184
|
+
"command": "/Users/yourusername/.local/bin/uvx"
|
|
185
|
+
```
|
|
186
|
+
|
|
175
187
|
**Config file locations:**
|
|
176
188
|
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
177
189
|
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
@@ -179,10 +191,15 @@ Add to your `claude_desktop_config.json`:
|
|
|
179
191
|
### With Claude Code (VS Code)
|
|
180
192
|
|
|
181
193
|
```bash
|
|
182
|
-
# Add MCP server to Claude Code
|
|
183
|
-
claude mcp add ultimate-gemini
|
|
194
|
+
# Add MCP server to Claude Code (with required OUTPUT_DIR)
|
|
195
|
+
claude mcp add ultimate-gemini \
|
|
196
|
+
--env GEMINI_API_KEY=your-api-key \
|
|
197
|
+
--env OUTPUT_DIR=/path/to/your/images \
|
|
198
|
+
-- uvx ultimate-gemini-mcp
|
|
184
199
|
```
|
|
185
200
|
|
|
201
|
+
**Note**: Replace `/path/to/your/images` with an absolute path to where you want images saved.
|
|
202
|
+
|
|
186
203
|
### With Cursor
|
|
187
204
|
|
|
188
205
|
Add to Cursor's MCP configuration (`.cursor/mcp.json`):
|
|
@@ -194,13 +211,16 @@ Add to Cursor's MCP configuration (`.cursor/mcp.json`):
|
|
|
194
211
|
"command": "uvx",
|
|
195
212
|
"args": ["ultimate-gemini-mcp"],
|
|
196
213
|
"env": {
|
|
197
|
-
"GEMINI_API_KEY": "your-api-key-here"
|
|
214
|
+
"GEMINI_API_KEY": "your-api-key-here",
|
|
215
|
+
"OUTPUT_DIR": "/path/to/your/images"
|
|
198
216
|
}
|
|
199
217
|
}
|
|
200
218
|
}
|
|
201
219
|
}
|
|
202
220
|
```
|
|
203
221
|
|
|
222
|
+
**Note**: Set `OUTPUT_DIR` to an absolute path where you want generated images saved.
|
|
223
|
+
|
|
204
224
|
## 🎯 Available Models
|
|
205
225
|
|
|
206
226
|
### Gemini Models
|
|
@@ -376,6 +396,24 @@ View current server configuration.
|
|
|
376
396
|
|
|
377
397
|
## 🐛 Troubleshooting
|
|
378
398
|
|
|
399
|
+
### "spawn uvx ENOENT" error
|
|
400
|
+
- **Cause**: Claude Desktop cannot find the `uvx` command in its PATH
|
|
401
|
+
- **Solution**: Use the full path to uvx in your config:
|
|
402
|
+
```json
|
|
403
|
+
"command": "/Users/yourusername/.local/bin/uvx"
|
|
404
|
+
```
|
|
405
|
+
- Find your uvx location with: `which uvx`
|
|
406
|
+
|
|
407
|
+
### "[Errno 30] Read-only file system: 'generated_images'"
|
|
408
|
+
- **Cause**: When using `uvx`, the default directory is in a read-only cache location
|
|
409
|
+
- **Solution**: Add `OUTPUT_DIR` to your MCP config:
|
|
410
|
+
```json
|
|
411
|
+
"env": {
|
|
412
|
+
"GEMINI_API_KEY": "your-key",
|
|
413
|
+
"OUTPUT_DIR": "/Users/yourusername/gemini_images"
|
|
414
|
+
}
|
|
415
|
+
```
|
|
416
|
+
|
|
379
417
|
### "GEMINI_API_KEY not found"
|
|
380
418
|
- Add your API key to `.env` or environment variables
|
|
381
419
|
- Get a free key at [Google AI Studio](https://makersuite.google.com/app/apikey)
|
|
@@ -391,6 +429,7 @@ View current server configuration.
|
|
|
391
429
|
### Images not saving
|
|
392
430
|
- Check that OUTPUT_DIR exists and is writable
|
|
393
431
|
- Verify you have sufficient disk space
|
|
432
|
+
- Create the directory manually: `mkdir -p /path/to/your/images`
|
|
394
433
|
|
|
395
434
|
## 🤝 Contributing
|
|
396
435
|
|
|
@@ -124,11 +124,13 @@ def validate_prompts_list(prompts: list[str]) -> None:
|
|
|
124
124
|
|
|
125
125
|
|
|
126
126
|
def sanitize_filename(filename: str) -> str:
|
|
127
|
-
"""Sanitize filename to remove unsafe characters."""
|
|
128
|
-
#
|
|
129
|
-
safe_name = re.sub(r'[
|
|
130
|
-
# Remove
|
|
131
|
-
safe_name =
|
|
127
|
+
"""Sanitize filename to remove unsafe and special characters."""
|
|
128
|
+
# Replace all non-alphanumeric characters (except hyphens) with underscores
|
|
129
|
+
safe_name = re.sub(r'[^a-zA-Z0-9-]', '_', filename)
|
|
130
|
+
# Remove multiple consecutive underscores
|
|
131
|
+
safe_name = re.sub(r'_+', '_', safe_name)
|
|
132
|
+
# Remove leading/trailing underscores
|
|
133
|
+
safe_name = safe_name.strip("_")
|
|
132
134
|
# Ensure filename is not empty
|
|
133
135
|
if not safe_name:
|
|
134
136
|
safe_name = "image"
|
|
@@ -45,7 +45,7 @@ def create_app() -> FastMCP:
|
|
|
45
45
|
# Create FastMCP server
|
|
46
46
|
mcp = FastMCP(
|
|
47
47
|
"Ultimate Gemini MCP",
|
|
48
|
-
version="1.
|
|
48
|
+
version="1.5.0",
|
|
49
49
|
)
|
|
50
50
|
|
|
51
51
|
# Register tools
|
|
@@ -53,27 +53,6 @@ def create_app() -> FastMCP:
|
|
|
53
53
|
register_batch_generate_tool(mcp)
|
|
54
54
|
|
|
55
55
|
# Add resources
|
|
56
|
-
@mcp.resource("image://latest", mime_type="image/png")
|
|
57
|
-
def get_latest_image() -> bytes:
|
|
58
|
-
"""
|
|
59
|
-
Get the most recently generated image.
|
|
60
|
-
|
|
61
|
-
Returns:
|
|
62
|
-
Binary PNG image data
|
|
63
|
-
"""
|
|
64
|
-
if not settings.output_dir.exists():
|
|
65
|
-
raise FileNotFoundError("No images have been generated yet")
|
|
66
|
-
|
|
67
|
-
# Find most recent PNG file
|
|
68
|
-
images = sorted(
|
|
69
|
-
settings.output_dir.glob("*.png"), key=lambda p: p.stat().st_mtime, reverse=True
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
if not images:
|
|
73
|
-
raise FileNotFoundError("No images found in output directory")
|
|
74
|
-
|
|
75
|
-
return images[0].read_bytes()
|
|
76
|
-
|
|
77
56
|
@mcp.resource("models://list")
|
|
78
57
|
def list_models() -> str:
|
|
79
58
|
"""List all available image generation models."""
|
|
@@ -54,12 +54,14 @@ class ImageResult:
|
|
|
54
54
|
raise ImageProcessingError(f"Failed to save image: {e}") from e
|
|
55
55
|
|
|
56
56
|
def _generate_filename(self) -> str:
|
|
57
|
-
"""Generate
|
|
57
|
+
"""Generate clean, short filename."""
|
|
58
58
|
timestamp = self.timestamp.strftime("%Y%m%d_%H%M%S")
|
|
59
|
-
#
|
|
60
|
-
|
|
59
|
+
# Shorten model name (e.g., gemini-2.5-flash-image -> gemini-flash)
|
|
60
|
+
model_short = self.model.replace("gemini-2.5-flash-image", "gemini-flash").replace("imagen-4-", "img4-")
|
|
61
|
+
# Sanitize and shorten prompt (max 30 chars)
|
|
62
|
+
prompt_snippet = sanitize_filename(self.prompt[:30])
|
|
61
63
|
index_str = f"_{self.index + 1}" if self.index > 0 else ""
|
|
62
|
-
return f"{
|
|
64
|
+
return f"{model_short}_{timestamp}_{prompt_snippet}{index_str}.png"
|
|
63
65
|
|
|
64
66
|
def get_size(self) -> int:
|
|
65
67
|
"""Get image size in bytes."""
|
|
@@ -115,7 +115,6 @@ def register_batch_generate_tool(mcp_server: Any) -> None:
|
|
|
115
115
|
output_format: str = "png",
|
|
116
116
|
batch_size: int | None = None,
|
|
117
117
|
negative_prompt: str | None = None,
|
|
118
|
-
save_to_disk: bool = True,
|
|
119
118
|
) -> str:
|
|
120
119
|
"""
|
|
121
120
|
Generate multiple images from a list of prompts efficiently.
|
|
@@ -131,13 +130,24 @@ def register_batch_generate_tool(mcp_server: Any) -> None:
|
|
|
131
130
|
output_format: Image format for all images (default: png)
|
|
132
131
|
batch_size: Parallel batch size (default: from config)
|
|
133
132
|
negative_prompt: Negative prompt for Imagen models (optional)
|
|
134
|
-
save_to_disk: Save images to disk and return file paths (default: True).
|
|
135
|
-
When True: Returns file paths only (efficient for MCP clients).
|
|
136
|
-
When False: Returns base64 image data (for cloud/serverless).
|
|
137
133
|
|
|
138
134
|
Returns:
|
|
139
|
-
JSON string with batch results
|
|
140
|
-
|
|
135
|
+
JSON string with batch results including individual image paths
|
|
136
|
+
|
|
137
|
+
IMPORTANT - AI Assistant Instructions:
|
|
138
|
+
After batch generation completes, you MUST:
|
|
139
|
+
1. Parse the JSON response to extract file paths from result["results"][i]["images"][0]["path"]
|
|
140
|
+
2. Show the user a summary of all generated images with their file paths
|
|
141
|
+
3. Optionally display one or more images using the Read tool
|
|
142
|
+
4. Let the user know the total count of successful vs failed generations
|
|
143
|
+
|
|
144
|
+
Example response to user:
|
|
145
|
+
"Successfully generated 3 images:
|
|
146
|
+
1. /path/to/image1.png - [description]
|
|
147
|
+
2. /path/to/image2.png - [description]
|
|
148
|
+
3. /path/to/image3.png - [description]"
|
|
149
|
+
|
|
150
|
+
DO NOT just say "batch generation completed" without listing the file paths!
|
|
141
151
|
"""
|
|
142
152
|
try:
|
|
143
153
|
result = await batch_generate_images(
|
|
@@ -148,7 +158,6 @@ def register_batch_generate_tool(mcp_server: Any) -> None:
|
|
|
148
158
|
output_format=output_format,
|
|
149
159
|
batch_size=batch_size,
|
|
150
160
|
negative_prompt=negative_prompt,
|
|
151
|
-
save_to_disk=save_to_disk,
|
|
152
161
|
)
|
|
153
162
|
|
|
154
163
|
return json.dumps(result, indent=2)
|
|
@@ -153,19 +153,10 @@ async def generate_image_tool(
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
if save_to_disk:
|
|
156
|
-
#
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
image_info["filename"] = file_path.name
|
|
161
|
-
logger.info(f"Saved image to {file_path}")
|
|
162
|
-
except Exception as e:
|
|
163
|
-
logger.warning(f"Failed to save image to disk: {e}")
|
|
164
|
-
image_info["save_error"] = str(e)
|
|
165
|
-
else:
|
|
166
|
-
# Only include base64 data when not saving to disk (cloud/serverless scenarios)
|
|
167
|
-
# This prevents token overflow for MCP clients with file system access
|
|
168
|
-
image_info["image_base64"] = result.image_data
|
|
156
|
+
# Save to output directory
|
|
157
|
+
file_path = result.save(settings.output_dir)
|
|
158
|
+
image_info["path"] = str(file_path)
|
|
159
|
+
image_info["filename"] = file_path.name
|
|
169
160
|
|
|
170
161
|
# Add enhanced prompt info
|
|
171
162
|
if "enhanced_prompt" in result.metadata:
|
|
@@ -196,7 +187,6 @@ def register_generate_image_tool(mcp_server: Any) -> None:
|
|
|
196
187
|
use_world_knowledge: bool = False,
|
|
197
188
|
negative_prompt: str | None = None,
|
|
198
189
|
seed: int | None = None,
|
|
199
|
-
save_to_disk: bool = True,
|
|
200
190
|
) -> str:
|
|
201
191
|
"""
|
|
202
192
|
Generate images using Google's Gemini or Imagen models.
|
|
@@ -218,9 +208,6 @@ def register_generate_image_tool(mcp_server: Any) -> None:
|
|
|
218
208
|
use_world_knowledge: Use real-world knowledge (Gemini only)
|
|
219
209
|
negative_prompt: What to avoid in the image (Imagen only)
|
|
220
210
|
seed: Random seed for reproducibility (NOT SUPPORTED - will be ignored)
|
|
221
|
-
save_to_disk: Save images to disk and return file paths (default: True).
|
|
222
|
-
When True: Returns file paths only (efficient for MCP clients).
|
|
223
|
-
When False: Returns base64 image data (for cloud/serverless).
|
|
224
211
|
|
|
225
212
|
Available models:
|
|
226
213
|
- gemini-2.5-flash-image (default)
|
|
@@ -229,8 +216,28 @@ def register_generate_image_tool(mcp_server: Any) -> None:
|
|
|
229
216
|
- imagen-4-ultra
|
|
230
217
|
|
|
231
218
|
Returns:
|
|
232
|
-
JSON string with generation results and
|
|
233
|
-
|
|
219
|
+
JSON string with generation results and file paths
|
|
220
|
+
|
|
221
|
+
IMPORTANT - AI Assistant Instructions:
|
|
222
|
+
After generating an image, you MUST:
|
|
223
|
+
1. Parse the JSON response to extract the file path from result["images"][0]["path"]
|
|
224
|
+
2. Inform the user of the EXACT file path where the image was saved
|
|
225
|
+
3. Use the Read tool to load and display the image to the user
|
|
226
|
+
4. Optionally: Use bash to open the image in the default viewer:
|
|
227
|
+
- macOS: `open /path/to/image.png`
|
|
228
|
+
- Linux: `xdg-open /path/to/image.png`
|
|
229
|
+
- Windows: `start /path/to/image.png`
|
|
230
|
+
|
|
231
|
+
Example workflow:
|
|
232
|
+
```
|
|
233
|
+
1. Call generate_image tool
|
|
234
|
+
2. Parse response JSON to get file_path
|
|
235
|
+
3. Tell user: "Image saved to: /Users/name/gemini_images/image.png"
|
|
236
|
+
4. Call Read tool with the file_path to display the image
|
|
237
|
+
5. Optionally call Bash with `open /path/to/image.png` to open in Preview
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
DO NOT just say "image generated successfully" without showing the path and image!
|
|
234
241
|
"""
|
|
235
242
|
try:
|
|
236
243
|
result = await generate_image_tool(
|
|
@@ -246,7 +253,6 @@ def register_generate_image_tool(mcp_server: Any) -> None:
|
|
|
246
253
|
use_world_knowledge=use_world_knowledge,
|
|
247
254
|
negative_prompt=negative_prompt,
|
|
248
255
|
seed=seed,
|
|
249
|
-
save_to_disk=save_to_disk,
|
|
250
256
|
)
|
|
251
257
|
|
|
252
258
|
return json.dumps(result, indent=2)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"1.21.0"}
|