Token导航 LogoToken导航TokenDH.com
OpenAI Image Generation MCP Server logo
设计创作stdio官方级别未说明来源级核验

OpenAI Image Generation MCP Server

MCP Server

基于OpenAI的gpt-image-1模型,提供图像生成和编辑功能的MCP服务器。

工具数

0

提示词数

0

GitHub Stars

15

资源数

0
图像生成PythonClineCline

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

IncomeStreamSurfer

提供方

IncomeStreamSurfer

最后核验

2026/5/17 20:23

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python -m venv venv

详细介绍

OpenAI图像生成MCP服务器

该项目实现了一个MCP(模型上下文协议)服务器,该服务器提供使用OpenAI生成和编辑图像的工具 gpt-image-1 通过官方Python SDK建模。

特性

此MCP服务器提供以下工具:

  • generate_image:使用OpenAI生成图像 gpt-image-1 基于文本提示的模型并保存。

- 输入架构:

    {
      "type": "object",
      "properties": {
        "prompt": { "type": "string", "description": "The text description of the desired image(s)." },
        "model": { "type": "string", "default": "gpt-image-1", "description": "The model to use (currently 'gpt-image-1')." },
        "n": { "type": ["integer", "null"], "default": 1, "description": "The number of images to generate (Default: 1)." },
        "size": { "type": ["string", "null"], "enum": ["1024x1024", "1536x1024", "1024x1536", "auto"], "default": "auto", "description": "Image dimensions ('1024x1024', '1536x1024', '1024x1536', 'auto'). Default: 'auto'." },
        "quality": { "type": ["string", "null"], "enum": ["low", "medium", "high", "auto"], "default": "auto", "description": "Rendering quality ('low', 'medium', 'high', 'auto'). Default: 'auto'." },
        "user": { "type": ["string", "null"], "default": null, "description": "An optional unique identifier representing your end-user." },
        "save_filename": { "type": ["string", "null"], "default": null, "description": "Optional filename (without extension). If None, a default name based on the prompt and timestamp is used." }
      },
      "required": ["prompt"]
    }

- 输出: {"status": "success", "saved_path": "path/to/image.png"} 或错误字典。

  • edit_image:使用OpenAI编辑图像或创建变体 gpt-image-1 模型并保存。可以使用多个输入图像作为参考或使用蒙版进行修复。

- 输入架构:

    {
      "type": "object",
      "properties": {
        "prompt": { "type": "string", "description": "The text description of the desired final image or edit." },
        "image_paths": { "type": "array", "items": { "type": "string" }, "description": "A list of file paths to the input image(s). Must be PNG. < 25MB." },
        "mask_path": { "type": ["string", "null"], "default": null, "description": "Optional file path to the mask image (PNG with alpha channel) for inpainting. Must be same size as input image(s). < 25MB." },
        "model": { "type": "string", "default": "gpt-image-1", "description": "The model to use (currently 'gpt-image-1')." },
        "n": { "type": ["integer", "null"], "default": 1, "description": "The number of images to generate (Default: 1)." },
        "size": { "type": ["string", "null"], "enum": ["1024x1024", "1536x1024", "1024x1536", "auto"], "default": "auto", "description": "Image dimensions ('1024x1024', '1536x1024', '1024x1536', 'auto'). Default: 'auto'." },
        "quality": { "type": ["string", "null"], "enum": ["low", "medium", "high", "auto"], "default": "auto", "description": "Rendering quality ('low', 'medium', 'high', 'auto'). Default: 'auto'." },
        "user": { "type": ["string", "null"], "default": null, "description": "An optional unique identifier representing your end-user." },
        "save_filename": { "type": ["string", "null"], "default": null, "description": "Optional filename (without extension). If None, a default name based on the prompt and timestamp is used." }
      },
      "required": ["prompt", "image_paths"]
    }

- 输出: {"status": "success", "saved_path": "path/to/image.png"} 或错误字典。

先决条件

  • Python(建议使用3.8或更高版本)
  • pip(Python包安装程序)
  • OpenAI API密钥(直接在脚本中设置或通过 OPENAI_API_KEY 环境变量- 为了安全起见,强烈建议使用环境变量).
  • 能够管理和启动MCP服务器的MCP客户端环境(如Cline使用的环境)。

安装

  1. 克隆存储库:
   git clone https://github.com/IncomeStreamSurfer/chatgpt-native-image-gen-mcp.git
   cd chatgpt-native-image-gen-mcp
  1. 设置虚拟环境(推荐):
   python -m venv venv
   source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  1. 安装依赖项:
   pip install -r requirements.txt
  1. (可选但推荐)设置环境变量:

设置 OPENAI_API_KEY 使用OpenAI密钥替换环境变量,而不是在脚本中对其进行硬编码。如何设置取决于您的操作系统。

配置(适用于临床MCP客户端)

要使此服务器可供您的AI助手(如Cline)使用,请将其配置添加到MCP设置文件中(例如。, cline_mcp_settings.json).

查找 mcpServers 在设置文件中添加对象,并添加以下条目:

{
  "mcpServers": {
    // ... other server configurations ...

    "openai-image-gen-mcp": {
      "autoApprove": [
        "generate_image",
        "edit_image"
      ],
      "disabled": false,
      "timeout": 180, // Increased timeout for potentially long image generation
      "command": "python", // Or path to python executable if not in PATH
      "args": [
        // IMPORTANT: Replace this path with the actual absolute path
        // to the openai_image_mcp.py file on your system
        "C:/path/to/your/cloned/repo/chatgpt-native-image-gen-mcp/openai_image_mcp.py"
      ],
      "env": {
        // If using environment variables for the API key:
        // "OPENAI_API_KEY": "YOUR_API_KEY_HERE"
      },
      "transportType": "stdio"
    }

    // ... other server configurations ...
  }
}

重要提示: 替换 C:/path/to/your/cloned/repo/ 在计算机上克隆此存储库的正确绝对路径。确保路径分隔符适用于您的操作系统(例如,使用反斜杠 \ 在Windows上)。如果通过环境变量设置API键,则可以将其从脚本中删除,并可能将其添加到 env 如果您的MCP客户端支持,请点击此处。

运行服务器

您通常不需要手动运行服务器。MCP客户端(如Cline)将使用 commandargs 当其工具之一首次被调用时,在配置文件中指定。

如果要手动测试它(确保已安装依赖项并且API密钥可用):

python openai_image_mcp.py

用法

AI助手使用 generate_imageedit_image 工具。图像保存在 ai-images 在以下位置创建的子目录 openai_image_mcp.py 脚本已定位。成功后,这些工具将返回保存图像的绝对路径。

目录标签

目录标签

图像生成PythonCline本地部署图像编辑AI绘图OpenAI

支持客户端

Cline

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

api-key

运行时(runtime,运行环境)

Python

部署方式(deploymentType,部署类型)

remote-capable

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdioapi-keyremote-capable

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP