Provides image generation capabilities using Google's Gemini 2.5 Flash model, allowing for text-to-image generation with automatic optimization and compression.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@img-genGenerate a realistic image of a futuristic city with flying cars at sunset"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
img-gen
An MCP (Model Context Protocol) server that provides image generation and weather services for Claude Desktop and other MCP-compatible clients.
Features
šØ Image Generation
Generate images using Google's Gemini 2.5 Flash Image model
Automatic image compression and resizing to optimize token usage
Base64 encoding for seamless integration with MCP clients
Comprehensive logging and error handling
š¤ļø Weather Services
Get weather alerts for US states
Fetch detailed weather forecasts by latitude/longitude
Uses the National Weather Service (NWS) API
Prerequisites
Python 3.11 or higher
uv package manager
Google Gemini API key (for image generation)
Claude Desktop (optional, for MCP integration)
Installation
Clone this repository:
Install dependencies using
uv:
Configuration
Google Gemini API Key
For image generation, you need to set up your Google Gemini API key. Update the API_KEY variable in image_generation.py:
Alternatively, you can modify the code to read from an environment variable for better security.
Claude Desktop Integration
To use this MCP server with Claude Desktop, add the following configuration to your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
Image Generation Server Configuration:
Weather Server Configuration:
Note: Replace /path/to/uv with your actual uv installation path (e.g., /Users/username/.local/bin/uv) and /path/to/img_gen with the absolute path to this project directory.
Usage
Running the MCP Servers
Image Generation Server:
Weather Server:
Image Generation
The generate_image tool accepts a text prompt and returns a generated image:
Tool:
generate_imageParameters:
prompt(string): A text description of the image you want to generate
Returns: MCP Content objects containing the generated image in base64 format
Weather Services
Get Weather Alerts
Tool:
get_alertsParameters:
state(string): Two-letter US state code (e.g., "CA", "NY")
Returns: Active weather alerts for the specified state
Get Weather Forecast
Tool:
get_forecastParameters:
latitude(float): Latitude of the location (up to 4 decimal places recommended)longitude(float): Longitude of the location (up to 4 decimal places recommended)
Returns: Detailed weather forecast for the next 5 periods
Project Structure
Image Processing
The image generation server includes automatic image optimization:
Max Dimension: 1024 pixels (maintains aspect ratio)
JPEG Quality: 85
Target File Size: ~500 KB
Format: Converts all images to JPEG for consistency
Images are automatically resized and compressed to reduce token usage while maintaining reasonable quality.
Dependencies
Key dependencies include:
mcp[cli]- Model Context Protocol frameworkgoogle-genai- Google Gemini API clientpillow- Image processinghttpx- HTTP client for weather API
See pyproject.toml for the complete list of dependencies.
Logging
Both servers include comprehensive logging:
Logs are written to
stderrLog levels: INFO, DEBUG, WARNING, ERROR
Includes timestamps and module names
Error Handling
Image generation failures return error messages via MCP
Weather API failures gracefully handle network issues
Invalid inputs are validated and return appropriate error messages
License
[Add your license here]
Contributing
[Add contribution guidelines if applicable]