Integrations
Enables image generation and editing using OpenAI's gpt-image-1 model, providing tools to create images from text prompts, edit existing images, and perform inpainting with masks.
Uses the OpenAI Python SDK to implement the image generation capabilities, allowing for programmatic access to OpenAI's image models through Python.
OpenAI 图像生成 MCP 服务器
该项目实现了一个 MCP(模型上下文协议)服务器,该服务器通过官方 Python SDK 提供使用 OpenAI 的gpt-image-1
模型生成和编辑图像的工具。
特征
该 MCP 服务器提供以下工具:
generate_image
:根据文本提示,使用 OpenAI 的gpt-image-1
模型生成图像并保存。- 输入模式:Copy
- 输出:
{"status": "success", "saved_path": "path/to/image.png"}
或错误字典。
- 输入模式:
edit_image
:使用 OpenAI 的gpt-image-1
模型编辑图像或创建变体并保存。可以使用多张输入图像作为参考,或使用遮罩进行修复。- 输入模式:Copy
- 输出:
{"status": "success", "saved_path": "path/to/image.png"}
或错误字典。
- 输入模式:
先决条件
- Python(建议使用 3.8 或更高版本)
- pip(Python 包安装程序)
- OpenAI API 密钥(直接在脚本中设置或通过
OPENAI_API_KEY
环境变量设置 -强烈建议使用环境变量以确保安全)。 - MCP 客户端环境(如 Cline 使用的环境)能够管理和启动 MCP 服务器。
安装
- 克隆存储库:Copy
- 设置虚拟环境(推荐):Copy
- 安装依赖项:Copy
- **(可选但推荐)设置环境变量:**使用您的 OpenAI 密钥设置
OPENAI_API_KEY
环境变量,而不是将其硬编码在脚本中。如何设置取决于您的操作系统。
配置(适用于 Cline MCP 客户端)
为了使您的 AI 助手(如 Cline)可以使用此服务器,请将其配置添加到您的 MCP 设置文件(例如, cline_mcp_settings.json
)。
在您的设置文件中找到mcpServers
对象并添加以下条目:
**重要提示:**请将C:/path/to/your/cloned/repo/
替换为您在计算机上克隆此仓库的正确绝对路径。请确保路径分隔符与您的操作系统匹配(例如,在 Windows 上使用反斜杠\
)。如果您通过环境变量设置了 API 密钥,则可以将其从脚本中移除,并在您的 MCP 客户端支持的情况下将其添加到此处的env
部分。
运行服务器
通常情况下,您无需手动运行服务器。MCP 客户端(例如 Cline)会在首次调用其工具时,使用配置文件中指定的command
和args
自动启动服务器。
如果您想手动测试它(确保依赖项已安装并且 API 密钥可用):
用法
AI 助手使用generate_image
和edit_image
工具与服务器交互。图像保存在openai_image_mcp.py
脚本所在位置的ai-images
子目录中。成功后,这两个工具会返回已保存图像的绝对路径。
This server cannot be installed
通过 MCP 接口提供使用 OpenAI 的 gpt-image-1 模型生成和编辑图像的工具,使 AI 助手能够根据文本提示创建和修改图像。
Related MCP Servers
- AsecurityAlicenseAqualityEnables the generation of images using Together AI's models through an MCP server, supporting customizable parameters such as model selection, image dimensions, and output directory.Last updated -14JavaScriptMIT License
- AsecurityAlicenseAqualityA MCP server that enables Claude and other MCP-compatible assistants to generate images from text prompts using Together AI's image generation models.Last updated -12TypeScriptMIT License
- -securityAlicense-qualityA MCP server that integrates with Cursor IDE to generate images based on text descriptions using JiMeng AI, allowing users to create and save custom images directly within their development environment.Last updated -82PythonMIT License
- -securityFlicense-qualityAn 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 -2TypeScript