Skip to main content
Glama

openai-images-mcp

使用 OpenAI 的 gpt-image 和 DALL·E 模型生成并编辑图像,并将其作为 Model Context Protocol 工具公开。支持 gpt-image-1.5gpt-image-1gpt-image-1-minidall-e-3dall-e-2

工具

工具

用途

模型

list_models

列出支持的模型及其功能(尺寸、质量、编辑/变体支持)。

全部

generate_image

根据文本提示生成一张或多张图像。

gpt-image-1.5, gpt-image-1, gpt-image-1-mini, dall-e-3, dall-e-2

edit_image

使用提示词和可选遮罩编辑现有图像。

gpt-image-1.5, gpt-image-1, gpt-image-1-mini, dall-e-2

create_variation

生成图像的变体。

dall-e-2

所有生成的图像都会保存到磁盘。在任何调用中设置 return_image_content: true 即可同时以 MCP 图像块的形式接收图像(当客户端需要“查看”结果时很有用,但会增加大量 token)。

安装

npm install
npm run build

配置您的 MCP 客户端

Claude Desktop / Claude Code

添加到 claude_desktop_config.json(或您项目的 .mcp.json):

{
  "mcpServers": {
    "dalle": {
      "command": "node",
      "args": ["/absolute/path/to/dalle-mcp/dist/index.js"],
      "env": {
        "OPENAI_API_KEY": "sk-...",
        "DALLE_OUTPUT_DIR": "/absolute/path/where/images/save"
      }
    }
  }
}

环境变量

变量

用途

OPENAI_API_KEY

必需。 您的 OpenAI API 密钥。

OPENAI_BASE_URL

可选。覆盖 OpenAI 基础 URL。

OPENAI_ORG_ID

可选。

OPENAI_PROJECT_ID

可选。

DALLE_OUTPUT_DIR

可选。保存图像的默认目录。默认为 ~/dalle-mcp-output

DALLE_DEFAULT_MODEL

可选。工具调用省略 model 时使用的模型。默认为 gpt-image-1.5

工具参考

generate_image

必需:prompt

可选:model, size, quality, n, background, output_format, output_compression, moderation, style, user, output_dir, filename_prefix, return_image_content

模型特定说明:

  • GPT Image (gpt-image-1.5, gpt-image-1, gpt-image-1-mini): 尺寸 auto|1024x1024|1536x1024|1024x1536,质量 auto|low|medium|high。支持 background, output_format, output_compression, moderation

  • DALL·E 3: 尺寸 1024x1024|1792x1024|1024x1792,质量 standard|hdn 必须为 1,支持 style

  • DALL·E 2: 尺寸 256x256|512x512|1024x1024,质量 standard

edit_image

必需:prompt, images(绝对路径,GPT Image 最多支持 16 张)。

可选:mask(透明像素表示可编辑区域),以及上述生成选项。DALL·E 3 不支持编辑。

create_variation

仅限 DALL·E 2。必需:image(PNG 格式,正方形,小于 4MB)。

可选:n, size (256x256|512x512|1024x1024), output_dir, filename_prefix, return_image_content

list_models

无参数。返回一个描述每个模型尺寸、质量和支持选项的 JSON 文档 —— 方便调用者在选择参数前查阅。

开发

npm run dev     # run with tsx, no build step
npm run build   # tsc to dist/
npm start       # node dist/index.js

该服务器通过 stdio 使用 MCP 协议通信,因此您可以使用任何兼容 MCP 的客户端驱动它,或者通过将 JSON-RPC 消息管道传输到 node dist/index.js 来手动驱动。

注意事项

  • DALL·E 2 和 DALL·E 3 已被 OpenAI 弃用,支持将于 2026-05-12 结束;请优先使用 GPT Image 系列。

  • GPT Image 模型始终返回 base64 数据;DALL·E 模型也会被要求返回 base64,以便无需第二次 HTTP 往返即可保存文件。

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

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

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/sam-david/openai-images-mcp'

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