ultimate-gemini-mcp 1.6.1__tar.gz → 1.6.2__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.6.1 → ultimate_gemini_mcp-1.6.2}/CLAUDE.md +3 -1
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/PKG-INFO +75 -9
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/README.md +74 -8
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/pyproject.toml +1 -1
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/src/__init__.py +1 -1
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/src/config/__init__.py +2 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/src/config/constants.py +55 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/src/core/validation.py +2 -2
- ultimate_gemini_mcp-1.6.2/src/server.py +233 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/src/services/image_service.py +3 -1
- ultimate_gemini_mcp-1.6.1/src/server.py +0 -165
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/.env.example +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/.github/workflows/README.md +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/.github/workflows/claude-code-review.yml +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/.github/workflows/claude.yml +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/.github/workflows/publish.yml +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/.github/workflows/test.yml +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/.gitignore +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/LICENSE +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/MANIFEST.in +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/PUBLISHING.md +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/TEST_RESULTS.md +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/src/config/settings.py +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/src/core/__init__.py +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/src/core/exceptions.py +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/src/services/__init__.py +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/src/services/gemini_client.py +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/src/services/imagen_client.py +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/src/services/prompt_enhancer.py +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/src/tools/__init__.py +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/src/tools/batch_generate.py +0 -0
- {ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/src/tools/generate_image.py +0 -0
|
@@ -104,7 +104,9 @@ await image_service.generate(
|
|
|
104
104
|
|
|
105
105
|
**`server.py`** - FastMCP initialization
|
|
106
106
|
- Creates app via `create_app()` factory function
|
|
107
|
-
- Registers tools
|
|
107
|
+
- Registers tools (generate_image, batch_generate)
|
|
108
|
+
- Registers prompts (6 ready-to-use templates for common use cases)
|
|
109
|
+
- Registers resources (models://list, settings://config)
|
|
108
110
|
- Entry point for both `python -m src.server` and `uvx`
|
|
109
111
|
|
|
110
112
|
### Data Flow for Image Generation
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ultimate-gemini-mcp
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.2
|
|
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
|
|
@@ -61,7 +61,7 @@ Description-Content-Type: text/markdown
|
|
|
61
61
|
- Comprehensive error handling and validation
|
|
62
62
|
- Configurable settings via environment variables
|
|
63
63
|
- Detailed logging and debugging
|
|
64
|
-
- MCP resources for
|
|
64
|
+
- MCP prompts, tools, and resources for complete MCP integration
|
|
65
65
|
|
|
66
66
|
## 🎬 Showcase - See It In Action
|
|
67
67
|
|
|
@@ -143,10 +143,14 @@ a maine coon cat blended with spiderman raimi suit version
|
|
|
143
143
|
2. **Model Variety**: Compare Imagen 4, Imagen 4 Ultra, and Gemini 2.5 Flash results side-by-side
|
|
144
144
|
3. **AI Enhancement Magic**: See how prompt enhancement adds lighting, composition, and technical details
|
|
145
145
|
4. **Consistent Quality**: All images feature dramatic chiaroscuro lighting, atmospheric effects, and hyper-detailed textures
|
|
146
|
+
|
|
146
147
|
5. **Model-Specific Strengths**:
|
|
147
|
-
- Imagen 4 Ultra
|
|
148
|
-
-
|
|
149
|
-
- Imagen 4
|
|
148
|
+
- **Imagen 4 Ultra**: Maximum quality and material detail - best for final production work
|
|
149
|
+
- **Imagen 4**: Balanced quality with good performance - the standard choice
|
|
150
|
+
- **Imagen 4 Fast**: Optimized speed while maintaining quality - perfect for rapid iteration and prototyping
|
|
151
|
+
- **Gemini 2.5 Flash**: Dynamic poses and creative interpretations with editing capabilities
|
|
152
|
+
|
|
153
|
+
**Note**: The showcase above demonstrates `imagen-4`, `imagen-4-ultra`, and `gemini-2.5-flash-image`. All Imagen models (including `imagen-4-fast`) produce similar quality outputs, with the main difference being generation speed.
|
|
150
154
|
|
|
151
155
|
## 🚀 Quick Start
|
|
152
156
|
|
|
@@ -384,13 +388,75 @@ Running with the same seed will produce the same image.
|
|
|
384
388
|
| `MAX_BATCH_SIZE` | Maximum parallel batch size | `8` |
|
|
385
389
|
| `LOG_LEVEL` | Logging level | `INFO` |
|
|
386
390
|
|
|
391
|
+
## 💬 Prompts
|
|
392
|
+
|
|
393
|
+
The server provides several ready-to-use prompt templates to help you get started. These can be selected in your MCP client (Claude Desktop, Cursor, etc.) for instant use.
|
|
394
|
+
|
|
395
|
+
### `quick_image_generation`
|
|
396
|
+
**Description**: Quick start - Generate a single image with Gemini.
|
|
397
|
+
|
|
398
|
+
**What it does**: Creates a serene mountain landscape at sunset using the default Gemini model with prompt enhancement enabled.
|
|
399
|
+
|
|
400
|
+
**Usage in Claude Desktop**: Select this prompt to get started immediately with a basic image generation.
|
|
401
|
+
|
|
402
|
+
### `high_quality_image`
|
|
403
|
+
**Description**: Generate a high-quality image using Imagen 4 Ultra.
|
|
404
|
+
|
|
405
|
+
**What it does**: Creates a professional quality futuristic cityscape with neon lights using Imagen's highest quality model.
|
|
406
|
+
|
|
407
|
+
**Usage example**: Perfect when you need the absolute best quality for professional work or final presentations.
|
|
408
|
+
|
|
409
|
+
### `image_with_negative_prompt`
|
|
410
|
+
**Description**: Generate an image using negative prompts (Imagen only).
|
|
411
|
+
|
|
412
|
+
**What it does**: Creates a beautiful garden with flowers while explicitly avoiding people or animals using Imagen's negative prompt feature.
|
|
413
|
+
|
|
414
|
+
**Usage example**: Use this when you want precise control over what NOT to include in your images.
|
|
415
|
+
|
|
416
|
+
### `batch_image_generation`
|
|
417
|
+
**Description**: Generate multiple images from a list of prompts.
|
|
418
|
+
|
|
419
|
+
**What it does**: Creates three different images (cat on windowsill, dog in park, bird in tree) in a single request.
|
|
420
|
+
|
|
421
|
+
**Usage example**: Ideal for generating multiple related images at once, like social media content or design variations.
|
|
422
|
+
|
|
423
|
+
### `edit_existing_image`
|
|
424
|
+
**Description**: Edit an existing image using Gemini (requires input image).
|
|
425
|
+
|
|
426
|
+
**What it does**: Takes an existing image and modifies it to change the time of day to sunset.
|
|
427
|
+
|
|
428
|
+
**Usage example**: Select this prompt and update the path to your own image file (e.g., ~/Pictures/photo.jpg) to edit it.
|
|
429
|
+
|
|
430
|
+
### `character_consistency`
|
|
431
|
+
**Description**: Generate images with character consistency across multiple scenes (Gemini only, multi-step).
|
|
432
|
+
|
|
433
|
+
**What it does**: First generates a wizard character in a library, then generates the same wizard in a different scene (magical forest) while maintaining consistent character appearance.
|
|
434
|
+
|
|
435
|
+
**Usage example**: Perfect for creating consistent character designs across multiple images for storytelling, character sheets, or animation concepts.
|
|
436
|
+
|
|
387
437
|
## 📚 MCP Resources
|
|
388
438
|
|
|
389
|
-
|
|
390
|
-
|
|
439
|
+
Resources provide read-only access to server information and can be attached as context in your MCP client.
|
|
440
|
+
|
|
441
|
+
### `models://list` - Available Models
|
|
442
|
+
**URI**: `models://list`
|
|
443
|
+
**Type**: application/json
|
|
444
|
+
**Description**: Lists all available image generation models (Gemini and Imagen) with their features, capabilities, and descriptions.
|
|
445
|
+
|
|
446
|
+
**Use this when you need to**:
|
|
447
|
+
- Check which models are available
|
|
448
|
+
- Understand model capabilities
|
|
449
|
+
- See model-specific features
|
|
450
|
+
|
|
451
|
+
### `settings://config` - Server Configuration
|
|
452
|
+
**URI**: `settings://config`
|
|
453
|
+
**Type**: application/json
|
|
454
|
+
**Description**: Shows current server configuration including output directory, timeout settings, batch size limits, and default parameters.
|
|
391
455
|
|
|
392
|
-
|
|
393
|
-
|
|
456
|
+
**Use this when you need to**:
|
|
457
|
+
- Check where images are being saved
|
|
458
|
+
- Verify prompt enhancement is enabled
|
|
459
|
+
- See current timeout and batch settings
|
|
394
460
|
|
|
395
461
|
## 🎭 Use Cases
|
|
396
462
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
- Comprehensive error handling and validation
|
|
26
26
|
- Configurable settings via environment variables
|
|
27
27
|
- Detailed logging and debugging
|
|
28
|
-
- MCP resources for
|
|
28
|
+
- MCP prompts, tools, and resources for complete MCP integration
|
|
29
29
|
|
|
30
30
|
## 🎬 Showcase - See It In Action
|
|
31
31
|
|
|
@@ -107,10 +107,14 @@ a maine coon cat blended with spiderman raimi suit version
|
|
|
107
107
|
2. **Model Variety**: Compare Imagen 4, Imagen 4 Ultra, and Gemini 2.5 Flash results side-by-side
|
|
108
108
|
3. **AI Enhancement Magic**: See how prompt enhancement adds lighting, composition, and technical details
|
|
109
109
|
4. **Consistent Quality**: All images feature dramatic chiaroscuro lighting, atmospheric effects, and hyper-detailed textures
|
|
110
|
+
|
|
110
111
|
5. **Model-Specific Strengths**:
|
|
111
|
-
- Imagen 4 Ultra
|
|
112
|
-
-
|
|
113
|
-
- Imagen 4
|
|
112
|
+
- **Imagen 4 Ultra**: Maximum quality and material detail - best for final production work
|
|
113
|
+
- **Imagen 4**: Balanced quality with good performance - the standard choice
|
|
114
|
+
- **Imagen 4 Fast**: Optimized speed while maintaining quality - perfect for rapid iteration and prototyping
|
|
115
|
+
- **Gemini 2.5 Flash**: Dynamic poses and creative interpretations with editing capabilities
|
|
116
|
+
|
|
117
|
+
**Note**: The showcase above demonstrates `imagen-4`, `imagen-4-ultra`, and `gemini-2.5-flash-image`. All Imagen models (including `imagen-4-fast`) produce similar quality outputs, with the main difference being generation speed.
|
|
114
118
|
|
|
115
119
|
## 🚀 Quick Start
|
|
116
120
|
|
|
@@ -348,13 +352,75 @@ Running with the same seed will produce the same image.
|
|
|
348
352
|
| `MAX_BATCH_SIZE` | Maximum parallel batch size | `8` |
|
|
349
353
|
| `LOG_LEVEL` | Logging level | `INFO` |
|
|
350
354
|
|
|
355
|
+
## 💬 Prompts
|
|
356
|
+
|
|
357
|
+
The server provides several ready-to-use prompt templates to help you get started. These can be selected in your MCP client (Claude Desktop, Cursor, etc.) for instant use.
|
|
358
|
+
|
|
359
|
+
### `quick_image_generation`
|
|
360
|
+
**Description**: Quick start - Generate a single image with Gemini.
|
|
361
|
+
|
|
362
|
+
**What it does**: Creates a serene mountain landscape at sunset using the default Gemini model with prompt enhancement enabled.
|
|
363
|
+
|
|
364
|
+
**Usage in Claude Desktop**: Select this prompt to get started immediately with a basic image generation.
|
|
365
|
+
|
|
366
|
+
### `high_quality_image`
|
|
367
|
+
**Description**: Generate a high-quality image using Imagen 4 Ultra.
|
|
368
|
+
|
|
369
|
+
**What it does**: Creates a professional quality futuristic cityscape with neon lights using Imagen's highest quality model.
|
|
370
|
+
|
|
371
|
+
**Usage example**: Perfect when you need the absolute best quality for professional work or final presentations.
|
|
372
|
+
|
|
373
|
+
### `image_with_negative_prompt`
|
|
374
|
+
**Description**: Generate an image using negative prompts (Imagen only).
|
|
375
|
+
|
|
376
|
+
**What it does**: Creates a beautiful garden with flowers while explicitly avoiding people or animals using Imagen's negative prompt feature.
|
|
377
|
+
|
|
378
|
+
**Usage example**: Use this when you want precise control over what NOT to include in your images.
|
|
379
|
+
|
|
380
|
+
### `batch_image_generation`
|
|
381
|
+
**Description**: Generate multiple images from a list of prompts.
|
|
382
|
+
|
|
383
|
+
**What it does**: Creates three different images (cat on windowsill, dog in park, bird in tree) in a single request.
|
|
384
|
+
|
|
385
|
+
**Usage example**: Ideal for generating multiple related images at once, like social media content or design variations.
|
|
386
|
+
|
|
387
|
+
### `edit_existing_image`
|
|
388
|
+
**Description**: Edit an existing image using Gemini (requires input image).
|
|
389
|
+
|
|
390
|
+
**What it does**: Takes an existing image and modifies it to change the time of day to sunset.
|
|
391
|
+
|
|
392
|
+
**Usage example**: Select this prompt and update the path to your own image file (e.g., ~/Pictures/photo.jpg) to edit it.
|
|
393
|
+
|
|
394
|
+
### `character_consistency`
|
|
395
|
+
**Description**: Generate images with character consistency across multiple scenes (Gemini only, multi-step).
|
|
396
|
+
|
|
397
|
+
**What it does**: First generates a wizard character in a library, then generates the same wizard in a different scene (magical forest) while maintaining consistent character appearance.
|
|
398
|
+
|
|
399
|
+
**Usage example**: Perfect for creating consistent character designs across multiple images for storytelling, character sheets, or animation concepts.
|
|
400
|
+
|
|
351
401
|
## 📚 MCP Resources
|
|
352
402
|
|
|
353
|
-
|
|
354
|
-
|
|
403
|
+
Resources provide read-only access to server information and can be attached as context in your MCP client.
|
|
404
|
+
|
|
405
|
+
### `models://list` - Available Models
|
|
406
|
+
**URI**: `models://list`
|
|
407
|
+
**Type**: application/json
|
|
408
|
+
**Description**: Lists all available image generation models (Gemini and Imagen) with their features, capabilities, and descriptions.
|
|
409
|
+
|
|
410
|
+
**Use this when you need to**:
|
|
411
|
+
- Check which models are available
|
|
412
|
+
- Understand model capabilities
|
|
413
|
+
- See model-specific features
|
|
414
|
+
|
|
415
|
+
### `settings://config` - Server Configuration
|
|
416
|
+
**URI**: `settings://config`
|
|
417
|
+
**Type**: application/json
|
|
418
|
+
**Description**: Shows current server configuration including output directory, timeout settings, batch size limits, and default parameters.
|
|
355
419
|
|
|
356
|
-
|
|
357
|
-
|
|
420
|
+
**Use this when you need to**:
|
|
421
|
+
- Check where images are being saved
|
|
422
|
+
- Verify prompt enhancement is enabled
|
|
423
|
+
- See current timeout and batch settings
|
|
358
424
|
|
|
359
425
|
## 🎭 Use Cases
|
|
360
426
|
|
|
@@ -10,6 +10,7 @@ from .constants import (
|
|
|
10
10
|
IMAGEN_MODELS,
|
|
11
11
|
MAX_BATCH_SIZE,
|
|
12
12
|
MAX_IMAGES_PER_REQUEST,
|
|
13
|
+
MODEL_METADATA,
|
|
13
14
|
PERSON_GENERATION_OPTIONS,
|
|
14
15
|
)
|
|
15
16
|
from .settings import APIConfig, ServerConfig, Settings, get_settings
|
|
@@ -24,6 +25,7 @@ __all__ = [
|
|
|
24
25
|
"IMAGEN_MODELS",
|
|
25
26
|
"MAX_BATCH_SIZE",
|
|
26
27
|
"MAX_IMAGES_PER_REQUEST",
|
|
28
|
+
"MODEL_METADATA",
|
|
27
29
|
"PERSON_GENERATION_OPTIONS",
|
|
28
30
|
"APIConfig",
|
|
29
31
|
"ServerConfig",
|
|
@@ -75,3 +75,58 @@ BATCH_TIMEOUT = 120
|
|
|
75
75
|
|
|
76
76
|
# Output settings
|
|
77
77
|
DEFAULT_OUTPUT_DIR = "generated_images"
|
|
78
|
+
|
|
79
|
+
# Model metadata for MCP resources
|
|
80
|
+
MODEL_METADATA = {
|
|
81
|
+
"gemini": {
|
|
82
|
+
"gemini-2.5-flash-image": {
|
|
83
|
+
"name": "Gemini 2.5 Flash Image",
|
|
84
|
+
"description": "Advanced image generation with editing and prompt enhancement",
|
|
85
|
+
"features": [
|
|
86
|
+
"Prompt enhancement",
|
|
87
|
+
"Image editing",
|
|
88
|
+
"Character consistency",
|
|
89
|
+
"Multi-image blending",
|
|
90
|
+
"World knowledge integration",
|
|
91
|
+
],
|
|
92
|
+
"default": True,
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"imagen": {
|
|
96
|
+
"imagen-4": {
|
|
97
|
+
"name": "Imagen 4",
|
|
98
|
+
"description": "High-quality image generation with improved text rendering",
|
|
99
|
+
"features": [
|
|
100
|
+
"Enhanced quality",
|
|
101
|
+
"Better text rendering",
|
|
102
|
+
"Negative prompts",
|
|
103
|
+
"Seed-based reproducibility",
|
|
104
|
+
"Person generation controls",
|
|
105
|
+
"Advanced controls",
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
"imagen-4-fast": {
|
|
109
|
+
"name": "Imagen 4 Fast",
|
|
110
|
+
"description": "Optimized for faster generation while maintaining good quality",
|
|
111
|
+
"features": [
|
|
112
|
+
"Faster generation speed",
|
|
113
|
+
"Good quality output",
|
|
114
|
+
"Negative prompts",
|
|
115
|
+
"Seed-based reproducibility",
|
|
116
|
+
"Person generation controls",
|
|
117
|
+
"Cost-effective",
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
"imagen-4-ultra": {
|
|
121
|
+
"name": "Imagen 4 Ultra",
|
|
122
|
+
"description": "Highest quality with best prompt adherence",
|
|
123
|
+
"features": [
|
|
124
|
+
"Highest quality",
|
|
125
|
+
"Best prompt adherence",
|
|
126
|
+
"Professional results",
|
|
127
|
+
"Enhanced text rendering",
|
|
128
|
+
"Advanced controls",
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
}
|
|
@@ -126,9 +126,9 @@ def validate_prompts_list(prompts: list[str]) -> None:
|
|
|
126
126
|
def sanitize_filename(filename: str) -> str:
|
|
127
127
|
"""Sanitize filename to remove unsafe and special characters."""
|
|
128
128
|
# Replace all non-alphanumeric characters (except hyphens) with underscores
|
|
129
|
-
safe_name = re.sub(r
|
|
129
|
+
safe_name = re.sub(r"[^a-zA-Z0-9-]", "_", filename)
|
|
130
130
|
# Remove multiple consecutive underscores
|
|
131
|
-
safe_name = re.sub(r
|
|
131
|
+
safe_name = re.sub(r"_+", "_", safe_name)
|
|
132
132
|
# Remove leading/trailing underscores
|
|
133
133
|
safe_name = safe_name.strip("_")
|
|
134
134
|
# Ensure filename is not empty
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Ultimate Gemini MCP Server - Main Entry Point
|
|
4
|
+
|
|
5
|
+
Unified MCP server supporting:
|
|
6
|
+
- Gemini 2.5 Flash Image (with prompt enhancement and editing)
|
|
7
|
+
- Imagen 3, 4, and 4-Ultra (with advanced controls)
|
|
8
|
+
- Batch processing, prompt templates, and comprehensive features
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
import logging
|
|
13
|
+
import sys
|
|
14
|
+
from functools import lru_cache
|
|
15
|
+
from typing import TypedDict
|
|
16
|
+
|
|
17
|
+
from fastmcp import FastMCP
|
|
18
|
+
|
|
19
|
+
from .config import ALL_MODELS, MODEL_METADATA, get_settings
|
|
20
|
+
from .tools import register_batch_generate_tool, register_generate_image_tool
|
|
21
|
+
|
|
22
|
+
# Set up logging
|
|
23
|
+
logging.basicConfig(
|
|
24
|
+
level=logging.INFO,
|
|
25
|
+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
|
26
|
+
stream=sys.stderr, # Important: use stderr for logging in MCP
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
logger = logging.getLogger(__name__)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class PromptMessage(TypedDict):
|
|
33
|
+
"""Type definition for MCP prompt messages."""
|
|
34
|
+
|
|
35
|
+
role: str
|
|
36
|
+
content: str
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _validate_prompt_messages(messages: list[PromptMessage]) -> list[PromptMessage]:
|
|
40
|
+
"""
|
|
41
|
+
Validate prompt message structure for MCP compliance.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
messages: List of message dictionaries with 'role' and 'content' keys
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
Validated messages (same as input if valid)
|
|
48
|
+
|
|
49
|
+
Raises:
|
|
50
|
+
ValueError: If message structure is invalid or types are incorrect
|
|
51
|
+
"""
|
|
52
|
+
for msg in messages:
|
|
53
|
+
if "role" not in msg or "content" not in msg:
|
|
54
|
+
raise ValueError(f"Invalid prompt message structure: {msg}")
|
|
55
|
+
if not isinstance(msg["role"], str) or not isinstance(msg["content"], str):
|
|
56
|
+
raise ValueError(f"Prompt message role and content must be strings: {msg}")
|
|
57
|
+
return messages
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@lru_cache(maxsize=1)
|
|
61
|
+
def _get_models_json() -> str:
|
|
62
|
+
"""
|
|
63
|
+
Get models information as JSON (cached).
|
|
64
|
+
|
|
65
|
+
This function is cached because the models list is static.
|
|
66
|
+
Uses MODEL_METADATA from constants.py as the single source of truth.
|
|
67
|
+
"""
|
|
68
|
+
return json.dumps(MODEL_METADATA, indent=2)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def create_app() -> FastMCP:
|
|
72
|
+
"""
|
|
73
|
+
Create and configure the Ultimate Gemini MCP application.
|
|
74
|
+
|
|
75
|
+
This is the factory function used by FastMCP CLI.
|
|
76
|
+
"""
|
|
77
|
+
logger.info("Initializing Ultimate Gemini MCP Server...")
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
# Load settings (validates API key)
|
|
81
|
+
settings = get_settings()
|
|
82
|
+
|
|
83
|
+
logger.info(f"Output directory: {settings.output_dir}")
|
|
84
|
+
logger.info(f"Prompt enhancement: {settings.api.enable_prompt_enhancement}")
|
|
85
|
+
logger.info(f"Available models: {', '.join(ALL_MODELS.keys())}")
|
|
86
|
+
|
|
87
|
+
# Create FastMCP server
|
|
88
|
+
mcp = FastMCP(
|
|
89
|
+
"Ultimate Gemini MCP",
|
|
90
|
+
version="1.5.0",
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
# Register tools
|
|
94
|
+
register_generate_image_tool(mcp)
|
|
95
|
+
register_batch_generate_tool(mcp)
|
|
96
|
+
|
|
97
|
+
# Add prompts
|
|
98
|
+
@mcp.prompt()
|
|
99
|
+
def quick_image_generation() -> list[PromptMessage]:
|
|
100
|
+
"""Quick start: Generate a single image with Gemini."""
|
|
101
|
+
return _validate_prompt_messages(
|
|
102
|
+
[
|
|
103
|
+
{
|
|
104
|
+
"role": "user",
|
|
105
|
+
"content": "Generate an image of a serene mountain landscape at sunset using the default Gemini model.",
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
@mcp.prompt()
|
|
111
|
+
def high_quality_image() -> list[PromptMessage]:
|
|
112
|
+
"""Generate a high-quality image using Imagen 4 Ultra."""
|
|
113
|
+
return _validate_prompt_messages(
|
|
114
|
+
[
|
|
115
|
+
{
|
|
116
|
+
"role": "user",
|
|
117
|
+
"content": "Generate a professional quality image of a futuristic cityscape with neon lights using the imagen-4-ultra model.",
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
@mcp.prompt()
|
|
123
|
+
def image_with_negative_prompt() -> list[PromptMessage]:
|
|
124
|
+
"""Generate an image using negative prompts (Imagen only)."""
|
|
125
|
+
return _validate_prompt_messages(
|
|
126
|
+
[
|
|
127
|
+
{
|
|
128
|
+
"role": "user",
|
|
129
|
+
"content": "Generate an image of a beautiful garden with flowers using imagen-4. Make sure there are no people or animals in the image.",
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
@mcp.prompt()
|
|
135
|
+
def batch_image_generation() -> list[PromptMessage]:
|
|
136
|
+
"""Generate multiple images from a list of prompts."""
|
|
137
|
+
return _validate_prompt_messages(
|
|
138
|
+
[
|
|
139
|
+
{
|
|
140
|
+
"role": "user",
|
|
141
|
+
"content": "Generate images for these three scenes: a cat on a windowsill, a dog in a park, and a bird in a tree.",
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
@mcp.prompt()
|
|
147
|
+
def edit_existing_image() -> list[PromptMessage]:
|
|
148
|
+
"""Edit an existing image using Gemini (requires input image)."""
|
|
149
|
+
return _validate_prompt_messages(
|
|
150
|
+
[
|
|
151
|
+
{
|
|
152
|
+
"role": "user",
|
|
153
|
+
"content": "I have an image at ~/Pictures/photo.jpg. Can you edit it to change the time of day to sunset?",
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
@mcp.prompt()
|
|
159
|
+
def character_consistency() -> list[PromptMessage]:
|
|
160
|
+
"""Generate images with character consistency across multiple scenes (Gemini only, multi-step)."""
|
|
161
|
+
return _validate_prompt_messages(
|
|
162
|
+
[
|
|
163
|
+
{
|
|
164
|
+
"role": "user",
|
|
165
|
+
"content": "First, generate an image of a cartoon wizard character studying in a library with maintain_character_consistency enabled. Then, generate a second image of the same wizard character exploring a magical forest, also with maintain_character_consistency enabled to keep the character's appearance consistent between scenes.",
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
# Add resources
|
|
171
|
+
@mcp.resource(
|
|
172
|
+
"models://list",
|
|
173
|
+
name="Available Models",
|
|
174
|
+
description="List all available image generation models with their features and capabilities",
|
|
175
|
+
mime_type="application/json",
|
|
176
|
+
)
|
|
177
|
+
def list_models() -> str:
|
|
178
|
+
"""List all available image generation models."""
|
|
179
|
+
return _get_models_json()
|
|
180
|
+
|
|
181
|
+
@mcp.resource(
|
|
182
|
+
"settings://config",
|
|
183
|
+
name="Server Configuration",
|
|
184
|
+
description="Shows current server configuration including output directory, timeout settings, batch size limits, and default parameters",
|
|
185
|
+
mime_type="application/json",
|
|
186
|
+
)
|
|
187
|
+
def get_config() -> str:
|
|
188
|
+
"""Get current server configuration."""
|
|
189
|
+
# Note: Settings are not cached because they could change based on environment
|
|
190
|
+
config = {
|
|
191
|
+
"output_directory": str(settings.output_dir),
|
|
192
|
+
"prompt_enhancement_enabled": settings.api.enable_prompt_enhancement,
|
|
193
|
+
"batch_processing_enabled": settings.api.enable_batch_processing,
|
|
194
|
+
"default_gemini_model": settings.api.default_gemini_model,
|
|
195
|
+
"default_imagen_model": settings.api.default_imagen_model,
|
|
196
|
+
"max_batch_size": settings.api.max_batch_size,
|
|
197
|
+
"request_timeout": settings.api.request_timeout,
|
|
198
|
+
"default_aspect_ratio": settings.api.default_aspect_ratio,
|
|
199
|
+
"default_output_format": settings.api.default_output_format,
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return json.dumps(config, indent=2)
|
|
203
|
+
|
|
204
|
+
logger.info("Ultimate Gemini MCP Server initialized successfully")
|
|
205
|
+
return mcp
|
|
206
|
+
|
|
207
|
+
except Exception as e:
|
|
208
|
+
logger.error(f"Failed to initialize server: {e}", exc_info=True)
|
|
209
|
+
raise
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def main() -> None:
|
|
213
|
+
"""Main entry point for direct execution."""
|
|
214
|
+
try:
|
|
215
|
+
logger.info("Starting Ultimate Gemini MCP Server...")
|
|
216
|
+
|
|
217
|
+
# Create application
|
|
218
|
+
app = create_app()
|
|
219
|
+
|
|
220
|
+
# Run the server (FastMCP handles stdio transport)
|
|
221
|
+
logger.info("Server is ready and listening for MCP requests")
|
|
222
|
+
app.run()
|
|
223
|
+
|
|
224
|
+
except KeyboardInterrupt:
|
|
225
|
+
logger.info("Server shutdown requested by user")
|
|
226
|
+
sys.exit(0)
|
|
227
|
+
except Exception as e:
|
|
228
|
+
logger.error(f"Server error: {e}", exc_info=True)
|
|
229
|
+
sys.exit(1)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
if __name__ == "__main__":
|
|
233
|
+
main()
|
|
@@ -57,7 +57,9 @@ class ImageResult:
|
|
|
57
57
|
"""Generate clean, short filename."""
|
|
58
58
|
timestamp = self.timestamp.strftime("%Y%m%d_%H%M%S")
|
|
59
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(
|
|
60
|
+
model_short = self.model.replace("gemini-2.5-flash-image", "gemini-flash").replace(
|
|
61
|
+
"imagen-4-", "img4-"
|
|
62
|
+
)
|
|
61
63
|
# Sanitize and shorten prompt (max 30 chars)
|
|
62
64
|
prompt_snippet = sanitize_filename(self.prompt[:30])
|
|
63
65
|
index_str = f"_{self.index + 1}" if self.index > 0 else ""
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
Ultimate Gemini MCP Server - Main Entry Point
|
|
4
|
-
|
|
5
|
-
Unified MCP server supporting:
|
|
6
|
-
- Gemini 2.5 Flash Image (with prompt enhancement and editing)
|
|
7
|
-
- Imagen 3, 4, and 4-Ultra (with advanced controls)
|
|
8
|
-
- Batch processing, prompt templates, and comprehensive features
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
import logging
|
|
12
|
-
import sys
|
|
13
|
-
|
|
14
|
-
from fastmcp import FastMCP
|
|
15
|
-
|
|
16
|
-
from .config import ALL_MODELS, get_settings
|
|
17
|
-
from .tools import register_batch_generate_tool, register_generate_image_tool
|
|
18
|
-
|
|
19
|
-
# Set up logging
|
|
20
|
-
logging.basicConfig(
|
|
21
|
-
level=logging.INFO,
|
|
22
|
-
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
|
23
|
-
stream=sys.stderr, # Important: use stderr for logging in MCP
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
logger = logging.getLogger(__name__)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def create_app() -> FastMCP:
|
|
30
|
-
"""
|
|
31
|
-
Create and configure the Ultimate Gemini MCP application.
|
|
32
|
-
|
|
33
|
-
This is the factory function used by FastMCP CLI.
|
|
34
|
-
"""
|
|
35
|
-
logger.info("Initializing Ultimate Gemini MCP Server...")
|
|
36
|
-
|
|
37
|
-
try:
|
|
38
|
-
# Load settings (validates API key)
|
|
39
|
-
settings = get_settings()
|
|
40
|
-
|
|
41
|
-
logger.info(f"Output directory: {settings.output_dir}")
|
|
42
|
-
logger.info(f"Prompt enhancement: {settings.api.enable_prompt_enhancement}")
|
|
43
|
-
logger.info(f"Available models: {', '.join(ALL_MODELS.keys())}")
|
|
44
|
-
|
|
45
|
-
# Create FastMCP server
|
|
46
|
-
mcp = FastMCP(
|
|
47
|
-
"Ultimate Gemini MCP",
|
|
48
|
-
version="1.5.0",
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
# Register tools
|
|
52
|
-
register_generate_image_tool(mcp)
|
|
53
|
-
register_batch_generate_tool(mcp)
|
|
54
|
-
|
|
55
|
-
# Add resources
|
|
56
|
-
@mcp.resource("models://list")
|
|
57
|
-
def list_models() -> str:
|
|
58
|
-
"""List all available image generation models."""
|
|
59
|
-
import json
|
|
60
|
-
|
|
61
|
-
models_info = {
|
|
62
|
-
"gemini": {
|
|
63
|
-
"gemini-2.5-flash-image": {
|
|
64
|
-
"name": "Gemini 2.5 Flash Image",
|
|
65
|
-
"description": "Advanced image generation with editing and prompt enhancement",
|
|
66
|
-
"features": [
|
|
67
|
-
"Prompt enhancement",
|
|
68
|
-
"Image editing",
|
|
69
|
-
"Character consistency",
|
|
70
|
-
"Multi-image blending",
|
|
71
|
-
"World knowledge integration",
|
|
72
|
-
],
|
|
73
|
-
"default": True,
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
"imagen": {
|
|
77
|
-
"imagen-4": {
|
|
78
|
-
"name": "Imagen 4",
|
|
79
|
-
"description": "High-quality image generation with improved text rendering",
|
|
80
|
-
"features": [
|
|
81
|
-
"Enhanced quality",
|
|
82
|
-
"Better text rendering",
|
|
83
|
-
"Negative prompts",
|
|
84
|
-
"Seed-based reproducibility",
|
|
85
|
-
"Person generation controls",
|
|
86
|
-
"Advanced controls",
|
|
87
|
-
],
|
|
88
|
-
},
|
|
89
|
-
"imagen-4-fast": {
|
|
90
|
-
"name": "Imagen 4 Fast",
|
|
91
|
-
"description": "Optimized for faster generation while maintaining good quality",
|
|
92
|
-
"features": [
|
|
93
|
-
"Faster generation speed",
|
|
94
|
-
"Good quality output",
|
|
95
|
-
"Negative prompts",
|
|
96
|
-
"Seed-based reproducibility",
|
|
97
|
-
"Person generation controls",
|
|
98
|
-
"Cost-effective",
|
|
99
|
-
],
|
|
100
|
-
},
|
|
101
|
-
"imagen-4-ultra": {
|
|
102
|
-
"name": "Imagen 4 Ultra",
|
|
103
|
-
"description": "Highest quality with best prompt adherence",
|
|
104
|
-
"features": [
|
|
105
|
-
"Highest quality",
|
|
106
|
-
"Best prompt adherence",
|
|
107
|
-
"Professional results",
|
|
108
|
-
"Enhanced text rendering",
|
|
109
|
-
"Advanced controls",
|
|
110
|
-
],
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return json.dumps(models_info, indent=2)
|
|
116
|
-
|
|
117
|
-
@mcp.resource("settings://config")
|
|
118
|
-
def get_config() -> str:
|
|
119
|
-
"""Get current server configuration."""
|
|
120
|
-
import json
|
|
121
|
-
|
|
122
|
-
config = {
|
|
123
|
-
"output_directory": str(settings.output_dir),
|
|
124
|
-
"prompt_enhancement_enabled": settings.api.enable_prompt_enhancement,
|
|
125
|
-
"batch_processing_enabled": settings.api.enable_batch_processing,
|
|
126
|
-
"default_gemini_model": settings.api.default_gemini_model,
|
|
127
|
-
"default_imagen_model": settings.api.default_imagen_model,
|
|
128
|
-
"max_batch_size": settings.api.max_batch_size,
|
|
129
|
-
"request_timeout": settings.api.request_timeout,
|
|
130
|
-
"default_aspect_ratio": settings.api.default_aspect_ratio,
|
|
131
|
-
"default_output_format": settings.api.default_output_format,
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return json.dumps(config, indent=2)
|
|
135
|
-
|
|
136
|
-
logger.info("Ultimate Gemini MCP Server initialized successfully")
|
|
137
|
-
return mcp
|
|
138
|
-
|
|
139
|
-
except Exception as e:
|
|
140
|
-
logger.error(f"Failed to initialize server: {e}", exc_info=True)
|
|
141
|
-
raise
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
def main() -> None:
|
|
145
|
-
"""Main entry point for direct execution."""
|
|
146
|
-
try:
|
|
147
|
-
logger.info("Starting Ultimate Gemini MCP Server...")
|
|
148
|
-
|
|
149
|
-
# Create application
|
|
150
|
-
app = create_app()
|
|
151
|
-
|
|
152
|
-
# Run the server (FastMCP handles stdio transport)
|
|
153
|
-
logger.info("Server is ready and listening for MCP requests")
|
|
154
|
-
app.run()
|
|
155
|
-
|
|
156
|
-
except KeyboardInterrupt:
|
|
157
|
-
logger.info("Server shutdown requested by user")
|
|
158
|
-
sys.exit(0)
|
|
159
|
-
except Exception as e:
|
|
160
|
-
logger.error(f"Server error: {e}", exc_info=True)
|
|
161
|
-
sys.exit(1)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if __name__ == "__main__":
|
|
165
|
-
main()
|
|
File without changes
|
|
File without changes
|
{ultimate_gemini_mcp-1.6.1 → ultimate_gemini_mcp-1.6.2}/.github/workflows/claude-code-review.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|