Skip to main content
Glama

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

Related MCP server: Weather MCP Server

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]

Available Tools

1 tool
generate_imageC

Create images based on the prompt

Args:
    prompt: A prompt to generate the image using image generation model

Returns:
    A list of MCP Content objects containing the generated image

Inputs: prompt (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 1 tool

    Disambiguation5/5

    With only one tool, there is no possibility of ambiguity or overlap with other tools. The tool 'generate_image' has a clear, singular purpose that cannot be confused with any other tool in the set.

    Naming Consistency5/5

    The single tool name 'generate_image' follows a clear verb_noun pattern, and since there are no other tools, consistency is inherently perfect with no deviations or mixed conventions to evaluate.

    Tool Count2/5

    A single tool is too few for a server named 'img-gen', which suggests a broader image generation domain. This minimal set feels thin and incomplete, as it lacks operations like editing, upscaling, or managing generated images, which are common in such domains.

    Completeness2/5

    The tool surface is severely incomplete for an image generation server. While 'generate_image' covers creation, there are obvious gaps such as no tools for editing images, retrieving past generations, or handling variations, which limits agent workflows and leads to dead ends.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Integrates Google's Gemini API with MCP-compatible clients for chat, real-time web search, knowledge queries, code/text analysis, and content generation.
      509 npm
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      Provides weather forecasts and alerts for US locations using the National Weather Service API. Enables users to retrieve active alerts by state and detailed forecasts by coordinates via MCP tools.
      12
      2
      ISC
    • F
      license
      C
      quality
      D
      maintenance
      Exposes US weather data as MCP tools, resources, and prompts via the National Weather Service API, enabling clients like Claude Desktop to get alerts, forecasts, and weather briefings.
      2
      1
      -