# imagegen-mcp [Health: Active]

**Category:** 🎥 Multimedia Process  
**Repository:** https://github.com/spartanz51/imagegen-mcp  
**GitHub Stars:** 37  
**npm Downloads (last month):** 686  
**Views:** 1  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/imagegen-mcp-2

## Description
MCP server to generate images from text using OpenAI's API

## Tools
Capabilities this server exposes over MCP:

- **text-to-image** — Generates an image based on a text prompt.
- **image-to-image** — Edits an existing image based on a text prompt and optional mask.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "imagegen-mcp": {
    "command": "npx",
    "args": ["-y","imagegen-mcp"],
    "env": {
      "OPENAI_API_KEY": ""
    }
  }
}
```

**Requires environment variables:** `OPENAI_API_KEY` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What imagegen-mcp MCP server does

The imagegen-mcp MCP server wraps OpenAI’s image generation and editing APIs and exposes them as MCP tools. It supports text-to-image creation with models listed by the project, including `gpt-image-1`, `dall-e-2`, and `dall-e-3` when available and enabled. It also supports image editing with `gpt-image-1` and `dall-e-2`.

The server provides two tools:

- `text-to-image` creates an image from a required text prompt.
- `image-to-image` edits one or more local image files using a required prompt and an optional PNG mask.

Results are written to temporary files. The tool response includes the path to the generated image, allowing the MCP client or agent to locate the output locally.

## How it works

The imagegen-mcp MCP server runs locally and communicates with an MCP client through standard input and output using `StdioServerTransport`. It sends image requests to OpenAI with the selected model and request parameters, then saves the returned image data as a temporary file.

For text generation, optional settings include image size, output format, compression, moderation, background, quality, style, and image count. The available values depend partly on the selected OpenAI model. For example, `style` applies to DALL·E 3, while transparent backgrounds require PNG or WebP output. DALL·E 3 supports only one image per request.

Editing accepts local file paths rather than remote image URLs. An optional mask file must be a PNG; transparent areas identify the parts of the image to edit.

## Setup and configuration

The project requires Node.js, with version 18 or later recommended, npm or yarn, and an OpenAI API key. Set the key in the `OPENAI_API_KEY` environment variable. A cloned installation can use the repository’s `.env.example` as the starting point for a `.env` file.

You can run the package without cloning the repository:

```bash
npx imagegen-mcp [options]
```

For a local checkout, install dependencies, build the TypeScript source, and run either the development entry point with `ts-node` or the compiled JavaScript in `dist`. The `--models` option restricts which OpenAI models the server exposes. Without it, the default allowlist contains `gpt-image-1`, `dall-e-2`, and `dall-e-3 as defined by the project.

In Cursor, add the server as a custom MCP server and provide `OPENAI_API_KEY` in its environment configuration. The command can include `--models` to limit the models available to Cursor.

## Tools and capabilities

`text-to-image` accepts a required `text` value and optional model, size, style, output format, compression, moderation, background, quality, and `n` parameters. Its default image size is `1024x1024`, and the default output format is PNG.

`image-to-image` accepts local image paths, an edit prompt, and an optional mask. It supports output format, compression, quality, size, model, and count options. Editing is limited to `gpt-image-1` and `dall-e-2`; DALL·E 2 supports only its documented image sizes.

The imagegen-mcp MCP server also supports npm-based execution, local development, TypeScript compilation, linting, and formatting commands described by the project.

## Limitations and notes

Model access depends on the OpenAI API key and the models enabled for that account. Model-specific restrictions apply to sizes, styles, quality settings, transparency, and image counts. The server uses local temporary files, so callers must be able to access the returned paths. Image editing requires local input paths and does not accept URLs according to the documented tool parameters.

_Full upstream README: https://allmcps.com/mcp/imagegen-mcp-2/readme_

