openai-gpt-图像-mcp
OpenAI 的 GPT-4o/gpt-image-1 图像生成和编辑 API 的模型上下文协议 (MCP) 工具服务器。
使用 OpenAI 的最新模型根据文本提示生成图像。
使用高级提示控制编辑图像(修复、去除修复、合成)。
支持:Claude Desktop、Cursor、VSCode、Windsurf 以及任何与 MCP 兼容的客户端。
✨ 特点
create-image :根据提示生成图像,并带有高级选项(大小、质量、背景等)。
edit-image :使用提示和可选掩码编辑或扩展图像,支持文件路径和 base64 输入。
文件输出:将生成的图像直接保存到磁盘,或以 base64 形式接收。
🚀 安装
🔑 配置
添加到 Claude Desktop 或 VSCode(包括 Cursor/Windsurf)配置:
⚡ 高级
对于
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
**最佳实践:**对于大型或生产图像,始终使用文件输出并确保您的客户端配置为处理文件路径。
📚 参考文献
🙏 致谢
使用openai Node.js SDK
由SureScale.ai构建
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
一个 MCP 工具服务器,可通过 OpenAI 的图像模型生成和编辑图像,支持跨各种 MCP 兼容客户端的文本到图像生成和高级图像编辑(修复、去除)。
Related MCP Servers
- -security-license-qualityAn OpenAI API-based MCP server that provides deep thinking and analysis capabilities, integrating with AI editor models to deliver comprehensive insights and practical solutions.Last updated -
- -security-license-qualityAn MCP (Model Context Protocol) server that allows generating, editing, and creating variations of images using OpenAI's DALL-E APIs.
- -security-license-qualityProvides tools for generating and editing images using OpenAI's gpt-image-1 model via an MCP interface, enabling AI assistants to create and modify images based on text prompts.Last updated -16Apache 2.0
Recraft AI MCP Serverofficial
Asecurity-licenseAqualityAn MCP server that integrates with Recraft AI to enable generation and manipulation of high-quality raster and vector images through tools like image generation, editing, vectorization, background removal, and upscaling.Last updated -94335MIT License