AI Image Generation Server with MCP Interface
@aymec
This project provides an HTTP server for image generation using Stable Diffusion, along with a Model Context Protocol (MCP) server that enables AI agents to request image generation.
Overview
What is AI Image Generation Server with MCP Interface?
This project is an MCP (Model Context Protocol) server with integrated Stable Diffusion image generation capabilities. It enables AI agents to request and receive generated images via a standardized MCP interface. It is based on Block's Goose Custom Extension tutorial.
How to use AI Image Generation Server with MCP Interface?
Set up a virtual environment (mandatorily named .venv), install the MCP package (pip install -e .), then run the combined service with image-gen-mcp after setting the IMAGE_GEN_DIR environment variable. Alternatively, use development mode with the FastMCP Inspector for testing and debugging. Integrate with Goose as a StandardIO extension by providing the executable path and the IMAGE_GEN_DIR variable.
Key features of AI Image Generation Server with MCP Interface
- Combined MCP server and image generation service
- Uses Stable Diffusion for text-to-image generation
- Provides a direct HTTP API for image generation
- Returns image URL, dimensions, format, and metadata
- Runs on port 5000 by default (customizable)
- Supports integration with Goose and the FastMCP Inspector
Use cases of AI Image Generation Server with MCP Interface
- AI agents generating images based on user prompts
- Testing and debugging image generation with FastMCP Inspector
- Integrating image generation into custom AI workflows via MCP
- Running local image generation with Ollama (tested with mistral-small3.1)
- Serving generated images via HTTP for direct access
FAQ from AI Image Generation Server with MCP Interface
What runtime does it require?
It requires Python 3 and a virtual environment. The project uses the mcp package and Stable Diffusion dependencies installed via pip install -e ..
How do I set the output folder for images?
Set the environment variable IMAGE_GEN_DIR to the absolute path of the target folder before starting the service.
Can I change the port for the image generation service?
Yes, use the --port flag when running image-gen-mcp (e.g., image-gen-mcp --port 5001).
Does it work with local models like Ollama?
Yes, it can run locally with Ollama. The only model tested successfully is mistral-small3.1, though it is slower than using OpenAI GPT-4o.
How do I stop the service?
Press Ctrl+C to stop both the MCP server and the image generation service, as they run within the same process.