OpenAI GPT Image MCP

Integrations

  • Provides tools for generating and editing images using OpenAI's GPT-4o/gpt-image-1 APIs, supporting text-to-image generation, image editing operations (inpainting, outpainting, compositing), and advanced prompt control.

openai-gpt-图像-mcp


OpenAI 的 GPT-4o/gpt-image-1 图像生成和编辑 API 的模型上下文协议 (MCP) 工具服务器。

  • 使用 OpenAI 的最新模型根据文本提示生成图像
  • 使用高级提示控制编辑图像(修复、去除修复、合成)。
  • 支持:Claude Desktop、Cursor、VSCode、Windsurf 以及任何与 MCP 兼容的客户端。

✨ 特点

  • create-image :根据提示生成图像,并带有高级选项(大小、质量、背景等)。
  • edit-image :使用提示和可选掩码编辑或扩展图像,支持文件路径和 base64 输入。
  • 文件输出:将生成的图像直接保存到磁盘,或以 base64 形式接收。

🚀 安装

git clone https://github.com/SureScaleAI/openai-gpt-image-mcp.git cd openai-gpt-image-mcp yarn install yarn build

🔑 配置

添加到 Claude Desktop 或 VSCode(包括 Cursor/Windsurf)配置:

{ "mcpServers": { "openai-gpt-image-mcp": { "command": "node", "args": ["/absolute/path/to/dist/index.js"], "env": { "OPENAI_API_KEY": "sk-..." } } } }

⚡ 高级

  • 对于create-image ,设置n以一次生成最多 10 张图像。
  • 对于edit-image ,提供一个遮罩图像(文件路径或 base64)来控制编辑的应用位置。
  • 请参阅src/index.ts了解所有选项。

🧑‍💻开发

  • TypeScript 源代码: src/index.ts
  • 构建: yarn build
  • 运行: node dist/index.js

📝 许可证

麻省理工学院


🩺 故障排除

  • 确保您的OPENAI_API_KEY有效并且具有图像 API 访问权限。
  • 您必须拥有一个经过验证的 OpenAI 组织。验证后,可能需要 15-20 分钟才能激活图像 API 访问权限。
  • 文件路径必须是绝对路径。
  • 对于文件输出,请确保目录是可写的。
  • 如果您发现有关文件类型的错误,请检查图像文件扩展名和格式。

⚠️ 限制和大文件处理

  • 1MB 有效负载限制: MCP 客户端(包括 Claude Desktop)对工具响应的大小有 1MB 的硬性限制。大图像(尤其是高分辨率或多幅图像)如果以 base64 格式返回,很容易超出此限制。
  • **自动切换到文件输出:**如果图片总大小超过 1MB,该工具将自动将图片保存到磁盘并返回文件路径(而非 base64 编码)。这确保了兼容性,并避免了诸如result exceeds maximum length of 1048576类的错误。
  • **默认文件位置:**如果您未指定file_output路径,图像将以唯一的文件名保存到/tmp (或MCP_HF_WORK_DIR环境变量设置的目录)。
  • 环境变量:
    • MCP_HF_WORK_DIR :设置此项以控制大图像和文件输出的保存位置。例如: export MCP_HF_WORK_DIR=/your/desired/dir
  • **最佳实践:**对于大型或生产图像,始终使用文件输出并确保您的客户端配置为处理文件路径。

📚 参考文献


🙏 致谢

-
security - not tested
A
license - permissive license
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

一个 MCP 工具服务器,可通过 OpenAI 的图像模型生成和编辑图像,支持跨各种 MCP 兼容客户端的文本到图像生成和高级图像编辑(修复、去除)。

  1. ✨ Features
    1. 🚀 Installation
      1. 🔑 Configuration
        1. ⚡ Advanced
          1. 🧑‍💻 Development
            1. 📝 License
              1. 🩺 Troubleshooting
                1. ⚠️ Limitations & Large File Handling
                  1. 📚 References
                    1. 🙏 Credits

                      Related MCP Servers

                      • -
                        security
                        A
                        license
                        -
                        quality
                        An MCP server for analyzing images using OpenRouter vision models, offering capabilities like automatic image resizing, model configuration, and handling custom queries about images.
                        Last updated -
                        5
                        JavaScript
                        MIT License
                      • A
                        security
                        A
                        license
                        A
                        quality
                        An MCP Server that integrates with Stability AI's API to provide high-quality image generation, editing, and manipulation capabilities including background removal, outpainting, search-and-replace, and upscaling.
                        Last updated -
                        13
                        35
                        55
                        TypeScript
                        MIT License
                        • Apple
                      • -
                        security
                        F
                        license
                        -
                        quality
                        An MCP server that allows users to generate, edit, and create variations of images through OpenAI's DALL-E API, supporting both DALL-E 2 and DALL-E 3 models.
                        Last updated -
                        2
                        TypeScript
                      • -
                        security
                        -
                        license
                        -
                        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

                      View all related MCP servers

                      ID: 436idj4xa1