mcp-server-openai-image-generator
Generates images from text prompts using the OpenAI Images API, saves them locally, and serves them via HTTP.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-server-openai-image-generatorgenerate a digital painting of an astronaut riding a horse on Mars"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-server-openai-image-generator
An MCP (Model Context Protocol) server that exposes an OpenAI image generation tool over HTTP. It generates images from text prompts, saves them locally, and serves them via an integrated static file server.
Stack
Runtime / Language: Bun + TypeScript
MCP Transport: HTTP — standard JSON responses (
POST /mcp)Image generation: OpenAI Images API (
gpt-image-2by default)CORS:
Access-Control-Allow-Origin: *on all routes
Related MCP server: nano-banana
Prerequisites
Bun >= 1.0
An OpenAI API key with access to the Images API
Installation
bun installConfiguration
Edit config.json at the project root:
{
"port": 1980,
"model": "gpt-image-2",
"size": "1024x1536",
"quality": "low",
"imagesDir": "images"
}Field | Description | Default |
| HTTP server listening port |
|
| OpenAI image model |
|
| Generated image dimensions |
|
| Image quality ( |
|
| Directory where generated images are stored |
|
The imagesDir directory is created automatically if it does not exist.
API Key
Provide your OpenAI key via the environment variable:
export OPENAI_API_KEY=sk-...Usage
# production
bun run start
# development (watch mode)
bun run devThe server starts on the configured port (default: http://localhost:1980).
MCP Tool: generate_image
Request
POST /mcp with a JSON-RPC 2.0 body:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "generate_image",
"arguments": {
"description": "A futuristic city at sunset, digital art"
}
}
}Response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"url": "http://localhost:1980/images/1720000000000.png",
"filename": "1720000000000.png",
"model": "gpt-image-2",
"size": "1024x1536",
"prompt": "A futuristic city at sunset, digital art"
}
}Generated images are saved as <timestamp>.png in imagesDir and immediately accessible at GET /images/:filename.
Project Structure
src/
index.ts # Entry point — loads config, starts server
server.ts # Bun HTTP server, routes requests
mcpHandler.ts # JSON-RPC 2.0 MCP handler
imageGenerator.ts # OpenAI Images API integration
staticHandler.ts # Static file serving for generated images
config.ts # Config loading from config.json
types.ts # Shared TypeScript types
config.json # Server configuration
images/ # Generated images (auto-created)License
Private — all rights reserved.
This server cannot be deployed
Maintenance
Related MCP Connectors
Focused MCP server for OpenAI image/audio generation (v2.0.0). Wraps endpoints via HAPI CLI.
LLM chat, text tools, image generation, editing, batch image jobs, and asynchronous video generation
Generate AI images and videos from any compatible MCP client.
Create images and videos from prompts, with options for image mixing, reference images, and start/…
Related MCP Servers
- AlicenseBqualityDmaintenanceA local MCP server for generating and editing images using OpenAI-compatible APIs. It provides text-to-image generation and image editing capabilities with configurable endpoints and saves output directly to local files.211 npmMIT
- AlicenseAqualityDmaintenanceA local stdio MCP server for generating images using Google's Gemini image models, saving to disk as JPEG.1403 npmMIT
- AlicenseNot gradedqualityDmaintenanceLocal-first MCP image generation server supporting OpenAI and Google Gemini models for generating and editing images, with an embedded interactive studio.4 npmISC
- FlicenseNot gradedqualityCmaintenanceMCP server that wraps OpenAI's gpt-image-2 image generation API, enabling image generation from text prompts, listing saved images, and loading images inline.1-