Skip to main content
Glama

DALL-E MCP Server

by Garoth

DALL-E MCP 服务器

使用 OpenAI 的 DALL-E API 生成图像的 MCP(模型上下文协议)服务器。

特征

  • 使用 DALL-E 2 或 DALL-E 3 生成图像
  • 编辑现有图像(仅限 DALL-E 2)
  • 创建现有图像的变体(仅限 DALL-E 2)
  • 验证 OpenAI API 密钥

安装

# Clone the repository git clone https://github.com/Garoth/dalle-mcp.git cd dalle-mcp # Install dependencies npm install # Build the project npm run build

Cline 用户重要提示

将 DALL-E MCP 服务器与 Cline 一起使用时,建议将生成的图像保存在当前工作区目录中,方法是将saveDir参数设置为与当前工作目录匹配。这可确保 Cline 能够在对话中正确定位并显示生成的图像。

Cline 的使用示例:

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

用法

运行服务器

# Run the server node build/index.js

Cline 的配置

将 dall-e 服务器添加到 VSCode 设置中的 Cline MCP 设置文件中(例如 ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json):

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

请确保:

  1. /path/to/dalle-mcp-server/build/index.js替换为构建的 index.js 文件的实际路径
  2. your-api-key-here替换为您的 OpenAI API 密钥

可用工具

生成图像

根据文本提示使用 DALL-E 生成图像。

{ "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" }

参数:

  • prompt (必需):所需图像的文本描述
  • model (可选):要使用的 DALL-E 型号(“dall-e-2”或“dall-e-3”,默认值:“dall-e-3”)
  • size (可选):生成图像的尺寸(默认值:“1024x1024”)
    • DALL-E 3:“1024x1024”、“1792x1024”或“1024x1792”
    • DALL-E 2:“256x256”、“512x512”或“1024x1024”
  • quality (可选):生成图像的质量,仅限 DALL-E 3(“标准”或“高清”,默认值:“标准”)
  • style (可选):生成图像的风格,仅限 DALL-E 3(“生动”或“自然”,默认值:“生动”)
  • n (可选):要生成的图像数量(1-10,默认值:1)
  • saveDir (可选):保存生成图像的目录(默认值:当前目录或 .env 文件中的 SAVE_DIR)。**对于 Cline 用户:**建议将其设置为当前工作区目录,以便正确显示图像。
  • fileName (可选):生成的图像的基本文件名,不带扩展名(默认值:“dalle-{timestamp}”)
编辑图像

根据文本提示使用 DALL-E 编辑现有图像。

⚠️ 已知问题(2025 年 3 月 18 日): DALL-E 2 图像编辑 API 当前存在一个错误,即使使用正确的 RGBA 格式图像和蒙版,它有时会忽略提示并返回未进行任何编辑的原始图像。此问题已在OpenAI 社区论坛中报告。如果您遇到此问题,请尝试使用create_variation工具,该工具似乎运行更可靠。

{ "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" }

参数:

  • prompt (必需):所需编辑的文本描述
  • imagePath (必需):要编辑的图像的路径
  • mask (可选):蒙版图像的路径(白色区域将被编辑,黑色区域将被保留)
  • model (可选):要使用的 DALL-E 模型(目前仅“dall-e-2”支持编辑,默认值:“dall-e-2”)
  • size (可选):生成图像的尺寸(默认值:“1024x1024”)
  • n (可选):要生成的图像数量(1-10,默认值:1)
  • saveDir (可选):保存编辑后图像的目录(默认值:当前目录或 .env 文件中的 SAVE_DIR)。**对于 Cline 用户:**建议将其设置为当前工作区目录,以便正确显示图像。
  • fileName (可选):编辑图像的基本文件名,不带扩展名(默认值:“dalle-edit-{timestamp}”)
创建变体

使用 DALL-E 创建现有图像的变体。

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

参数:

  • imagePath (必需):用于创建变体的图像路径
  • model (可选):要使用的 DALL-E 模型(目前只有“dall-e-2”支持变体,默认值:“dall-e-2”)
  • size (可选):生成图像的尺寸(默认值:“1024x1024”)
  • n (可选):要生成的变体数量(1-10,默认值:1)
  • saveDir (可选):保存变体图像的目录(默认值:当前目录或 .env 文件中的 SAVE_DIR)。**对于 Cline 用户:**建议将其设置为当前工作区目录,以便正确显示图像。
  • fileName (可选):变体图像的基本文件名(不带扩展名)(默认值:“dalle-variation-{timestamp}”)
验证密钥

验证 OpenAI API 密钥。

{}

无需任何参数。

发展

测试配置

注意:以下 .env 配置仅适用于运行测试,不需要用于正常操作。

如果您正在为该项目开发或运行测试,请使用您的 OpenAI API 密钥在根目录中创建一个.env文件:

# 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

为了使 Cline 正常运行,请按照上面“添加到 MCP 设置”部分中的说明,在 MCP 设置 JSON 中配置您的 API 密钥。

您可以从OpenAI 的 API 密钥页面获取您的 API 密钥。

运行测试

# 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"

注意:测试使用真实的 API 调用,可能会对您的 OpenAI 帐户产生费用。

生成测试图像

该项目包含一个用于生成用于开发和测试的测试图像的脚本:

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

这将在assets目录中创建一个简单的测试图像,可用于测试编辑和变化功能。

执照

麻省理工学院

-
security - not tested
F
license - not found
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

MCP 服务器允许用户通过 OpenAI 的 DALL-E API 生成、编辑和创建图像变体,支持 DALL-E 2 和 DALL-E 3 模型。

  1. 特征
    1. 安装
      1. Cline 用户重要提示
        1. 用法
          1. 运行服务器
          2. Cline 的配置
          3. 可用工具
        2. 发展
          1. 测试配置
            1. 运行测试
            2. 生成测试图像
          2. 执照

            Related MCP Servers

            • A
              security
              F
              license
              A
              quality
              A TypeScript-based MCP server that generates images using OpenAI's dall-e-3 model based on text prompts and saves them to a specified directory.
              Last updated -
              1
              10
              JavaScript
              • Apple
            • A
              security
              F
              license
              A
              quality
              A TypeScript-based MCP server that lets users generate images using OpenAI's dall-e-3 model by providing a prompt and image name.
              Last updated -
              1
              1
            • -
              security
              A
              license
              -
              quality
              An MCP tool server that enables generating and editing images through OpenAI's image models, supporting text-to-image generation and advanced image editing (inpainting, outpainting) across various MCP-compatible clients.
              Last updated -
              60
              TypeScript
              MIT License
              • Linux
              • Apple
            • A
              security
              F
              license
              A
              quality
              An MCP (Model Context Protocol) server that allows generating, editing, and creating variations of images using OpenAI's DALL-E APIs.
              Last updated -
              1
              TypeScript

            View all related MCP servers

            MCP directory API

            We provide all the information about MCP servers via our MCP API.

            curl -X GET 'https://glama.ai/api/mcp/v1/servers/Garoth/dalle-mcp'

            If you have feedback or need assistance with the MCP directory API, please join our Discord server