Get the FREE Ultimate OpenClaw Setup Guide →

ai-image-gen

Scalable MCP backend optimized for Claude Code and Claude Desktop — secure, low-latency, plug-and-play.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio krystian-ai-ai-image-gen-mcp python -m ai_image_gen_mcp.server stdio \
  --env PYTHONPATH="src" \
  --env OPENAI_API_KEY="<your-openai-api-key>"

How to use

This MCP server exposes a unified interface for multiple image generation models (DALL·E 3, DALL·E 2, and GPT‑Image‑1) through the MCP protocol. It presents three MCP primitives—Tools, Resources, and Prompts—so clients can request image generation, discover available models and capabilities, and use built‑in prompt templates for common workflows. The primary tool is generate_image, which lets you select a model, specify output size, and choose a style (for example, vivid or natural for DALL·E 3). You can mix and match models via the same API surface, enabling scenarios like single prompts rendered with DALL·E 3 or batch variations via DALL·E 2. The server also exposes metadata about each model's supported sizes and batch capabilities, helping clients tailor requests to available resources. For Claude Desktop or Claude Code integrations, configure the MCP client to connect to the ai-image-gen server using STDIO transport, enabling prompt-driven interactions, UI rendering, and prompt history within the host application.

How to install

Prerequisites:

  • Python 3.11+ installed on your system
  • A valid OpenAI API key (and access to Claude if you plan MCP integrations with Claude Desktop/Code)
  • Git installed

Installation steps:

  1. Clone the repository git clone https://github.com/krystian-ai/ai-image-gen-mcp.git cd ai-image-gen-mcp

  2. Create and activate a Python virtual environment python3.11 -m venv .venv source .venv/bin/activate

  3. Install the package in editable mode with optional extras for image features and development tooling pip install -e ".[image,dev]"

  4. Copy the example environment file and set your API key cp .env.example .env

    Edit .env and add your OpenAI API key

  5. Run the MCP server (as an example, using STDIO transport via Python module) python -m ai_image_gen_mcp.server stdio

  6. Verify the server starts and is reachable via MCP clients that support STDIO transport

Notes:

  • The server expects OPENAI_API_KEY to be provided in the environment or a .env file
  • You can adjust environment variables like CACHE_DIR or MODEL_DEFAULT in a .env file as needed
  • For Claude integrations, ensure the PYTHONPATH includes the project src/ directory

Additional notes

Tips and caveats:

  • Model selection is exposed as part of the Tools API (generate_image); default is DALL·E 3 with vivid or natural styles. If needed, you can switch models per request.
  • The server caches generated images locally with associated metadata; ensure the cache directory has enough space for your workloads.
  • When running via STDIO or in GUI integrations, ensure the host transports messages using the MCP protocol JSON-RPC 2.0 compatible format.
  • If you encounter API key errors, double‑check OPENAI_API_KEY in your environment or .env file and verify PYTHONPATH points to the src/ directory where modules reside.
  • For debugging, run tests with pytest and use the development extras to exercise image generation pathways.
  • The server supports multiple models; for production usage, consider configuring model defaults and per‑model capabilities in your environment to optimize latency and cost.

Related MCP Servers

Sponsor this space

Reach thousands of developers