DALL-E MCP Server

DALL-E MCP Server

An MCP (Model Context Protocol) server that allows generating, editing, and creating variations of images using OpenAI's DALL-E APIs.

Category
访问服务器

Tools

generate_image_using_dalle3

Generate an image using DALL-E 3 (Azure or OpenAI) based on a text prompt and save it to an absolute path.

README

DALL-E MCP Server

<img src="assets/dall-e-logo.png" alt="DALL-E MCP Logo" width="256" height="256">

An MCP (Model Context Protocol) server for generating images using OpenAI's DALL-E API.

Features

  • Generate images using DALL-E 2 or DALL-E 3
  • Edit existing images (DALL-E 2 only)
  • Create variations of existing images (DALL-E 2 only)
  • Validate OpenAI API key

Installation

# Clone the repository
git clone https://github.com/joshmouch/mcp-image-generator.git
cd mcp-image-generator

# Install dependencies
npm install

# Build the project
npm run build

Important Note for Cline Users

When using this DALL-E MCP server with Cline, it's recommended to save generated images in your current workspace directory by setting the saveDir parameter to match your current working directory. This ensures Cline can properly locate and display the generated images in your conversation.

Example usage with Cline:

{
  "prompt": "A tropical beach at sunset",
  "saveDir": "/path/to/current/workspace"
}

Usage

Running the Server

# Run the server
node build/index.js

Configuration for Cline

Add the dall-e server to your Cline MCP settings file inside VSCode's settings (ex. ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json):

{
  "mcpServers": {
    "mcp-image-generator": {
      "command": "node",
      "args": ["/path/to/mcp-image-generator-server/build/index.js"],
      "env": {
        "OPENAI_API_KEY": "your-api-key-here",
        "SAVE_DIR": "/path/to/save/directory"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

Make sure to:

  1. Replace /path/to/mcp-image-generator-server/build/index.js with the actual path to the built index.js file
  2. Replace your-api-key-here with your OpenAI API key

Available Tools

generate_image

Generate an image using DALL-E based on a text prompt.

{
  "prompt": "A futuristic city with flying cars and neon lights",
  "model": "dall-e-3",
  "size": "1024x1024",
  "quality": "standard",
  "style": "vivid",
  "n": 1,
  "saveDir": "/path/to/save/directory",
  "fileName": "futuristic-city"
}

Parameters:

  • prompt (required): Text description of the desired image
  • model (optional): DALL-E model to use ("dall-e-2" or "dall-e-3", default: "dall-e-3")
  • size (optional): Size of the generated image (default: "1024x1024")
    • DALL-E 3: "1024x1024", "1792x1024", or "1024x1792"
    • DALL-E 2: "256x256", "512x512", or "1024x1024"
  • quality (optional): Quality of the generated image, DALL-E 3 only ("standard" or "hd", default: "standard")
  • style (optional): Style of the generated image, DALL-E 3 only ("vivid" or "natural", default: "vivid")
  • n (optional): Number of images to generate (1-10, default: 1)
  • saveDir (optional): Directory to save the generated images (default: current directory or SAVE_DIR from .env). For Cline users: Setting this to your current workspace directory is recommended for proper image display.
  • fileName (optional): Base filename for the generated images without extension (default: "dalle-{timestamp}")

edit_image

Edit an existing image using DALL-E based on a text prompt.

⚠️ Known Issue (March 18, 2025): The DALL-E 2 image edit API currently has a bug where it sometimes ignores the prompt and returns the original image without any edits, even when using proper RGBA format images and masks. This issue has been reported in the OpenAI community forum. If you experience this issue, try using the create_variation tool instead, which seems to work more reliably.

{
  "prompt": "Add a red hat",
  "imagePath": "/path/to/image.png",
  "mask": "/path/to/mask.png",
  "model": "dall-e-2",
  "size": "1024x1024",
  "n": 1,
  "saveDir": "/path/to/save/directory",
  "fileName": "edited-image"
}

Parameters:

  • prompt (required): Text description of the desired edits
  • imagePath (required): Path to the image to edit
  • mask (optional): Path to the mask image (white areas will be edited, black areas preserved)
  • model (optional): DALL-E model to use (currently only "dall-e-2" supports editing, default: "dall-e-2")
  • size (optional): Size of the generated image (default: "1024x1024")
  • n (optional): Number of images to generate (1-10, default: 1)
  • saveDir (optional): Directory to save the edited images (default: current directory or SAVE_DIR from .env). For Cline users: Setting this to your current workspace directory is recommended for proper image display.
  • fileName (optional): Base filename for the edited images without extension (default: "dalle-edit-{timestamp}")

create_variation

Create variations of an existing image using DALL-E.

{
  "imagePath": "/path/to/image.png",
  "model": "dall-e-2",
  "size": "1024x1024",
  "n": 4,
  "saveDir": "/path/to/save/directory",
  "fileName": "image-variation"
}

Parameters:

  • imagePath (required): Path to the image to create variations of
  • model (optional): DALL-E model to use (currently only "dall-e-2" supports variations, default: "dall-e-2")
  • size (optional): Size of the generated image (default: "1024x1024")
  • n (optional): Number of variations to generate (1-10, default: 1)
  • saveDir (optional): Directory to save the variation images (default: current directory or SAVE_DIR from .env). For Cline users: Setting this to your current workspace directory is recommended for proper image display.
  • fileName (optional): Base filename for the variation images without extension (default: "dalle-variation-{timestamp}")

validate_key

Validate the OpenAI API key.

{}

No parameters required.

Development

Testing Configuration

Note: The following .env configuration is ONLY needed for running tests, not for normal operation.

If you're developing or running tests for this project, create a .env file in the root directory with your OpenAI API key:

# Required for TESTS ONLY: OpenAI API Key
OPENAI_API_KEY=your-api-key-here

# Optional: Default save directory for test images
# If not specified, images will be saved to the current directory
# SAVE_DIR=/path/to/save/directory

For normal operation with Cline, configure your API key in the MCP settings JSON as described in the "Adding to MCP Settings" section above.

You can get your API key from OpenAI's API Keys page.

Running Tests

# Run basic tests
npm test

# Run all tests including edit and variation tests
npm run test:all

# Run tests in watch mode
npm run test:watch

# Run specific test by name
npm run test:name "should validate API key"

Note: Tests use real API calls and may incur charges on your OpenAI account.

Generating Test Images

The project includes a script to generate test images for development and testing:

# Generate a test image in the assets directory
npm run generate-test-image

This will create a simple test image in the assets directory that can be used for testing the edit and variation features.

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选