image-gen
An MCP server that integrates with gpt-image-1 & Gemini imagen4 model for text-to-image generation services
claude mcp add --transport stdio lansespirit-image-gen-mcp python scripts/dev.py dev \ --env PROVIDERS__GEMINI__API_KEY="Path to Google Vertex AI service account JSON file (for Imagen models)" \ --env PROVIDERS__OPENAI__API_KEY="OpenAI API key (for OpenAI models, e.g., gpt-image-1, dall-e-3, dall-e-2)"
How to use
This MCP server provides a universal image generation interface that enables any MCP-enabled LLM client to request images from multiple providers, including OpenAI's image models and Google's Imagen series. With the image-gen MCP server, you can discover available models at runtime, generate text-to-image outputs, and perform image edits via a single, standardized MCP tool. Clients can connect using the MCP transports supported by the server (STDIO for desktop integrations like Claude Desktop, HTTP for web-based clients, and others as configured) and obtain consistent responses that reference either inline data or persistent image resources.
To use it, ensure your MCP client is configured to route image generation requests through the image-gen MCP tool. The server handles querying the available providers, constructing prompts, and returning generated images in common formats (PNG, JPEG, WebP) with options for quality settings and background handling. You can also leverage prompt templates and the built-in caching and storage features to optimize performance and manage generated assets across sessions.
How to install
Prerequisites:
- Python 3.10+
- UV package manager (for dependency installation and environment isolation)
- Access keys for your image providers (OpenAI API key; Google Vertex AI service account if using Imagen models)
Installation steps:
-
Clone the repository and install dependencies via UV: git clone <repository-url> cd image-gen-mcp uv sync
-
Configure environment variables:
- Copy the example env file if provided and edit it with your credentials: cp .env.example .env
- Ensure you have: PROVIDERS__OPENAI__API_KEY set to your OpenAI API key PROVIDERS__GEMINI__API_KEY set to the path of your Vertex AI service account JSON (if using Imagen models)
-
Run the development server using UV: uv run python scripts/dev.py setup uv run python scripts/dev.py test
-
Start the server in development mode (HTTP transport by default is configured for web testing): ./run.sh dev
Notes:
- The image-gen MCP server is designed to work with multiple image-generation providers; ensure your provider keys and permissions are correctly configured for the models you intend to use.
- If you plan to deploy production-grade, switch to the prod run target and configure Docker/NGINX, TLS, and monitoring as appropriate.
Additional notes
Tips and common issues:
- Ensure your OpenAI and Google Vertex AI credentials are valid and have the required permissions for the image generation models you intend to use.
- If you encounter transport-related issues, verify the MCP client configuration matches the server's transport endpoints (STDIO for Claude Desktop, HTTP for web clients).
- Enable verbose logging during development to pinpoint model capability discovery or prompt formatting issues.
- The server supports dynamic model discovery; if a new provider or model is added, restart the server to refresh the model list.
- For production, consider enabling Redis-based caching and setting appropriate TTLs to balance performance and storage usage.
Related MCP Servers
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
mcp-yfinance
Real-time stock API with Python, MCP server example, yfinance stock analysis dashboard
cloudwatch-logs
MCP server from serkanh/cloudwatch-logs-mcp
gemini-cli-media-generation
An example of using Gemini CLI with MCP Servers for Genmedia and Gemini 2.5 Flash Image model
servicenow-api
ServiceNow MCP Server and API Wrapper
the -company
TheMCPCompany: Creating General-purpose Agents with Task-specific Tools