Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AIFire in da houseCheck it out free

openai-gpt-image-mcp

MCP.Pizza Chef: SureScaleAI

The openai-gpt-image-mcp is a Model Context Protocol server that integrates OpenAI's GPT-4o and gpt-image-1 APIs for image generation and editing. It enables real-time, structured interaction with advanced image AI capabilities within MCP-enabled applications, facilitating seamless image creation and modification workflows using GPT-powered models.

Use This MCP server To

Generate images from textual prompts using GPT-4o/gpt-image-1 APIs Edit existing images via natural language instructions Integrate image generation into MCP-enabled applications Automate creative workflows involving AI image synthesis Combine text and image generation for multimedia content creation Enable real-time image editing in chat or assistant environments

README

openai-gpt-image-mcp

MCP SDK OpenAI SDK License GitHub stars Build Status


A Model Context Protocol (MCP) tool server for OpenAI's GPT-4o/gpt-image-1 image generation and editing APIs.

  • Generate images from text prompts using OpenAI's latest models.
  • Edit images (inpainting, outpainting, compositing) with advanced prompt control.
  • Supports: Claude Desktop, Cursor, VSCode, Windsurf, and any MCP-compatible client.

✨ Features

  • create-image: Generate images from a prompt, with advanced options (size, quality, background, etc).
  • edit-image: Edit or extend images using a prompt and optional mask, supporting both file paths and base64 input.
  • File output: Save generated images directly to disk, or receive as base64.

πŸš€ Installation

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

πŸ”‘ Configuration

Add to Claude Desktop or VSCode (including Cursor/Windsurf) config:

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

⚑ Advanced

  • For create-image, set n to generate up to 10 images at once.
  • For edit-image, provide a mask image (file path or base64) to control where edits are applied.
  • See src/index.ts for all options.

πŸ§‘β€πŸ’» Development

  • TypeScript source: src/index.ts
  • Build: yarn build
  • Run: node dist/index.js

πŸ“ License

MIT


🩺 Troubleshooting

  • Make sure your OPENAI_API_KEY is valid and has image API access.
  • You must have a verified OpenAI organization. After verifying, it can take 15–20 minutes for image API access to activate.
  • File paths must be absolute.
    • Unix/macOS/Linux: Starting with / (e.g., /path/to/image.png)
    • Windows: Drive letter followed by : (e.g., C:/path/to/image.png or C:\path\to\image.png)
  • For file output, ensure the directory is writable.
  • If you see errors about file types, check your image file extensions and formats.

⚠️ Limitations & Large File Handling

  • 1MB Payload Limit: MCP clients (including Claude Desktop) have a hard 1MB limit for tool responses. Large images (especially high-res or multiple images) can easily exceed this limit if returned as base64.
  • Auto-Switch to File Output: If the total image size exceeds 1MB, the tool will automatically save images to disk and return the file path(s) instead of base64. This ensures compatibility and prevents errors like result exceeds maximum length of 1048576.
  • Default File Location: If you do not specify a file_output path, images will be saved to /tmp (or the directory set by the MCP_HF_WORK_DIR environment variable) with a unique filename.
  • Environment Variable:
    • MCP_HF_WORK_DIR: Set this to control where large images and file outputs are saved. Example: export MCP_HF_WORK_DIR=/your/desired/dir
  • Best Practice: For large or production images, always use file output and ensure your client is configured to handle file paths.

πŸ“š References

  • OpenAI Images API Documentation

πŸ™ Credits

  • Built with @modelcontextprotocol/sdk
  • Uses openai Node.js SDK
  • Built by SureScale.ai

openai-gpt-image-mcp FAQ

How do I authenticate the openai-gpt-image-mcp server?
Authentication is typically done via API keys provided by OpenAI, configured in the server environment variables or config files.
Can this MCP server handle both image generation and editing?
Yes, it supports both generating new images and editing existing ones using OpenAI's GPT-4o/gpt-image-1 APIs.
Is the openai-gpt-image-mcp compatible with other LLM providers?
While primarily designed for OpenAI's APIs, it can be extended or adapted to work with other providers like Anthropic's Claude or Google's Gemini with additional integration work.
What programming languages or environments support this MCP server?
It is implemented in JavaScript/TypeScript and can be integrated into any environment supporting Node.js.
How does this MCP server handle image data transmission?
It uses structured JSON and base64 encoding to transmit image data securely and efficiently within MCP protocols.
Are there rate limits or usage quotas to consider?
Yes, usage is subject to OpenAI's API rate limits and quotas, which should be managed in your application logic.
Can I customize the image generation parameters?
Yes, parameters like resolution, style, and prompt details can be customized through the MCP server's API calls.
How do I monitor or debug interactions with this MCP server?
The server includes logging and error reporting features compatible with standard Node.js debugging tools.