Skip to main content
Glama

openai-gpt-图像-mcp


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

  • 使用 OpenAI 的最新模型根据文本提示生成图像

  • 使用高级提示控制编辑图像(修复、去除修复、合成)。

  • 支持:Claude Desktop、Cursor、VSCode、Windsurf 以及任何与 MCP 兼容的客户端。


✨ 特点

  • create-image :根据提示生成图像,并带有高级选项(大小、质量、背景等)。

  • edit-image :使用提示和可选掩码编辑或扩展图像,支持文件路径和 base64 输入。

  • 文件输出:将生成的图像直接保存到磁盘,或以 base64 形式接收。


Related MCP server: imagegen-mcp

🚀 安装

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

  • **最佳实践:**对于大型或生产图像,始终使用文件输出并确保您的客户端配置为处理文件路径。


📚 参考文献


🙏 致谢

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

No tool schema history has been recorded yet.

Maintenance

ActivityInactive
ResponsivenessUnresponsive

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

Related MCP Connectors

Related MCP Servers

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/SureScaleAI/openai-gpt-image-mcp'

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