Skip to main content
Glama

OpenAI Image Generation MCP Server

OpenAI 画像生成 MCP サーバー

このプロジェクトは、公式 Python SDK を介して OpenAI のgpt-image-1モデルを使用して画像を生成および編集するためのツールを提供する MCP (Model Context Protocol) サーバーを実装します。

特徴

この 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
  2. 仮想環境をセットアップする (推奨):
    python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
  3. 依存関係をインストールします:
    pip install -r requirements.txt
  4. **(オプションですが推奨)環境変数の設定:**スクリプト内でハードコードするのではなく、 OPENAI_API_KEY環境変数にOpenAIキーを設定します。設定方法はオペレーティングシステムによって異なります。

構成(Cline 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キーを環境変数で設定している場合は、スクリプトから削除し、MCPクライアントがサポートしている場合は、 envセクションに追加することができます。

サーバーの実行

通常、サーバーを手動で起動する必要はありません。MCPクライアント(Clineなど)は、ツールのいずれかが初めて呼び出されたときに、設定ファイルに指定されたcommandargsを使用してサーバーを自動的に起動します。

手動でテストする場合(依存関係がインストールされ、API キーが使用可能であることを確認してください):

python openai_image_mcp.py

使用法

AIアシスタントは、 generate_imageツールとedit_imageツールを使用してサーバーとやり取りします。画像は、 openai_image_mcp.pyスクリプトが配置されている場所に作成されたai-imagesサブディレクトリに保存されます。ツールは成功すると、保存された画像への絶対パスを返します。

-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

MCP インターフェースを介して OpenAI の gpt-image-1 モデルを使用して画像を生成および編集するためのツールを提供し、AI アシスタントがテキスト プロンプトに基づいて画像を作成および変更できるようにします。

  1. 特徴
    1. 前提条件
      1. インストール
        1. 構成(Cline MCP クライアント用)
          1. サーバーの実行
            1. 使用法

              Related MCP Servers

              • A
                security
                A
                license
                A
                quality
                Allows AI assistants to generate and transform high-quality images from text prompts using Google's Gemini model via the MCP protocol.
                Last updated -
                3
                16
                Python
                MIT License
                • Apple
              • -
                security
                A
                license
                -
                quality
                An MCP tool server that enables generating and editing images through OpenAI's image models, supporting text-to-image generation and advanced image editing (inpainting, outpainting) across various MCP-compatible clients.
                Last updated -
                60
                TypeScript
                MIT License
                • Linux
                • Apple
              • A
                security
                F
                license
                A
                quality
                An MCP (Model Context Protocol) server that allows generating, editing, and creating variations of images using OpenAI's DALL-E APIs.
                Last updated -
                1
                TypeScript
              • A
                security
                A
                license
                A
                quality
                An MCP server that allows Claude to use OpenAI's image generation capabilities (gpt-image-1) to create image assets for users, which is particularly useful for game and web development projects.
                Last updated -
                1
                1
                2
                JavaScript
                MIT License

              View all related MCP servers

              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/IncomeStreamSurfer/chatgpt-native-image-gen-mcp'

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