ai-image-gen
Scalable MCP backend optimized for Claude Code and Claude Desktop — secure, low-latency, plug-and-play.
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:
-
Clone the repository git clone https://github.com/krystian-ai/ai-image-gen-mcp.git cd ai-image-gen-mcp
-
Create and activate a Python virtual environment python3.11 -m venv .venv source .venv/bin/activate
-
Install the package in editable mode with optional extras for image features and development tooling pip install -e ".[image,dev]"
-
Copy the example environment file and set your API key cp .env.example .env
Edit .env and add your OpenAI API key
-
Run the MCP server (as an example, using STDIO transport via Python module) python -m ai_image_gen_mcp.server stdio
-
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
mcp-language
mcp-language-server gives MCP enabled clients access semantic tools like get definition, references, rename, and diagnostics.
MCP-Bridge
A middleware to provide an openAI compatible endpoint that can call MCP tools
mcp-claude-spotify
An integration that allows Claude Desktop to interact with Spotify using the Model Context Protocol (MCP).
seedream-image
🚀 PixelMCP | 为你的 Cursor、Claude Code 等集成AI绘画能力,让AI生成的页面不再单调!
mcp-chat-widget
Configure, host and embed MCP-enabled chat widgets for your website or product. Lightweight and extensible Chatbase clone to remotely configure and embed your agents anywhere.
ObsidianMCPServer
A Model Context Protocol (MCP) server that enables AI assistants to interact with your Obsidian vault