img-gen

img-gen

Provides tools for generating optimized images via Google's Gemini model and fetching weather forecasts and alerts from the National Weather Service. It enables users to create visual content and retrieve environmental data seamlessly within MCP-compatible clients.

Category
Visit Server

README

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

  1. Clone this repository:
git clone <repository-url>
cd img_gen
  1. Install dependencies using uv:
uv sync

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:

API_KEY = "your-api-key-here"

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:

{
  "mcpServers": {
    "image_generation": {
      "command": "/path/to/uv",
      "args": [
        "--directory",
        "/path/to/img_gen",
        "run",
        "image_generation.py"
      ]
    }
  }
}

Weather Server Configuration:

{
  "mcpServers": {
    "weather": {
      "command": "/path/to/uv",
      "args": [
        "--directory",
        "/path/to/img_gen",
        "run",
        "weather.py"
      ]
    }
  }
}

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:

uv run image_generation.py

Weather Server:

uv run weather.py

Image Generation

The generate_image tool accepts a text prompt and returns a generated image:

  • Tool: generate_image
  • Parameters:
    • 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_alerts
  • Parameters:
    • state (string): Two-letter US state code (e.g., "CA", "NY")
  • Returns: Active weather alerts for the specified state

Get Weather Forecast

  • Tool: get_forecast
  • Parameters:
    • 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

img_gen/
ā”œā”€ā”€ image_generation.py  # MCP server for image generation using Gemini API
ā”œā”€ā”€ weather.py           # MCP server for weather alerts and forecasts
ā”œā”€ā”€ main.py              # Basic entry point
ā”œā”€ā”€ pyproject.toml       # Project dependencies and configuration
ā”œā”€ā”€ uv.lock              # Locked dependency versions
└── README.md            # This file

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 framework
  • google-genai - Google Gemini API client
  • pillow - Image processing
  • httpx - HTTP client for weather API

See pyproject.toml for the complete list of dependencies.

Logging

Both servers include comprehensive logging:

  • Logs are written to stderr
  • Log 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]

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured