Skip to main content
Glama

mcp_openai_image

Generate images using OpenAI's DALL-E API by providing a text prompt, model, size, and quality parameters. Returns the file path for the created image, ensuring users can access and utilize the output effectively.

Instructions

OpenAI DALL-E API를 사용하여 이미지를 생성합니다. 생성된 이미지 파일 경로를 반환하며, 이 경로는 반드시 사용자에게 알려주어야 합니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileNameNo저장할 파일 이름 (확장자 제외)
modelNo사용할 모델 (예: dall-e-3, dall-e-2)
nNo생성할 이미지 수
promptYes이미지를 생성할 프롬프트
qualityNo이미지 품질 (dall-e-3만 해당)
saveDirNo이미지를 저장할 디렉토리
sizeNo이미지 크기
styleNo이미지 스타일 (dall-e-3만 해당)

Implementation Reference

  • MCP tool handler function that invokes openaiService.generateImage and formats the response as ToolResponse
    async handler(args: any): Promise<ToolResponse> {
      try {
        const result = await openaiService.generateImage(args);
        return {
          content: [{
            type: 'text',
            text: result
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `OpenAI 이미지 생성 오류: ${error instanceof Error ? error.message : String(error)}`
          }]
        };
      }
    }
  • Input schema for mcp_openai_image tool defining parameters such as prompt, model, size, quality, etc.
    inputSchema: {
      type: 'object',
      properties: {
        prompt: {
          type: 'string',
          description: '이미지를 생성할 프롬프트'
        },
        model: {
          type: 'string',
          description: '사용할 모델 (예: dall-e-3, dall-e-2)'
        },
        n: {
          type: 'number',
          description: '생성할 이미지 수',
          minimum: 1,
          maximum: 10
        },
        size: {
          type: 'string',
          description: '이미지 크기',
          enum: ['256x256', '512x512', '1024x1024', '1792x1024', '1024x1792']
        },
        quality: {
          type: 'string',
          description: '이미지 품질 (dall-e-3만 해당)',
          enum: ['standard', 'hd']
        },
        style: {
          type: 'string',
          description: '이미지 스타일 (dall-e-3만 해당)',
          enum: ['vivid', 'natural']
        },
        saveDir: {
          type: 'string',
          description: '이미지를 저장할 디렉토리'
        },
        fileName: {
          type: 'string',
          description: '저장할 파일 이름 (확장자 제외)'
        }
      },
      required: ['prompt']
    },
  • src/index.ts:25-54 (registration)
    Tool registration in MCP server capabilities, enabling mcp_openai_image
    tools: {
      mcp_sparql_execute_query: true,
      mcp_sparql_update: true,
      mcp_sparql_list_repositories: true,
      mcp_sparql_list_graphs: true,
      mcp_sparql_get_resource_info: true,
      mcp_ollama_run: true,
      mcp_ollama_show: true,
      mcp_ollama_pull: true,
      mcp_ollama_list: true,
      mcp_ollama_rm: true,
      mcp_ollama_chat_completion: true,
      mcp_ollama_status: true,
      mcp_http_request: true,
      mcp_openai_chat: true,
      mcp_openai_image: true,
      mcp_openai_tts: true,
      mcp_openai_transcribe: true,
      mcp_openai_embedding: true,
      mcp_gemini_generate_text: true,
      mcp_gemini_chat_completion: true,
      mcp_gemini_list_models: true,
      mcp_gemini_generate_images: false,
      mcp_gemini_generate_image: false,
      mcp_gemini_generate_videos: false,
      mcp_gemini_generate_multimodal_content: false,
      mcp_imagen_generate: false,
      mcp_gemini_create_image: false,
      mcp_gemini_edit_image: false
    },
  • Core implementation of image generation using OpenAI DALL-E API: calls /images/generations endpoint, downloads images from URLs, saves locally and returns file paths.
    async generateImage(args: {
      prompt: string;
      model?: string;
      n?: number;
      size?: string;
      quality?: string;
      style?: string;
      saveDir?: string;
      fileName?: string;
    }): Promise<string> {
      try {
        if (!OPENAI_API_KEY) {
          throw new McpError(
            ErrorCode.InternalError,
            'OPENAI_API_KEY가 설정되지 않았습니다.'
          );
        }
    
        const response = await axios.post(
          `${OPENAI_API_BASE}/images/generations`,
          {
            model: args.model || 'dall-e-3',
            prompt: args.prompt,
            n: args.n || 1,
            size: args.size || '1024x1024',
            quality: args.quality || 'standard',
            style: args.style || 'vivid',
            response_format: 'url'
          },
          {
            headers: {
              'Content-Type': 'application/json',
              'Authorization': `Bearer ${OPENAI_API_KEY}`
            }
          }
        );
    
        const images = response.data.data;
        const saveDir = args.saveDir || DEFAULT_SAVE_DIR;
        await this.ensureDirectoryExists(saveDir);
    
        // 이미지 URL을 다운로드하여 파일로 저장
        const savedFiles = [];
        for (let i = 0; i < images.length; i++) {
          const timestamp = Date.now();
          const fileName = args.fileName 
            ? `${args.fileName}_${i}.png` 
            : `dalle_${timestamp}_${i}.png`;
          const filePath = path.join(saveDir, fileName);
          
          const imageResponse = await axios.get(images[i].url, { responseType: 'arraybuffer' });
          await writeFileAsync(filePath, Buffer.from(imageResponse.data));
          
          savedFiles.push({ path: filePath, url: images[i].url });
        }
    
        return JSON.stringify({
          generated_images: savedFiles,
          original_response: response.data
        }, null, 2);
      } catch (error) {
        if (axios.isAxiosError(error)) {
          const statusCode = error.response?.status;
          const responseData = error.response?.data;
          
          throw new McpError(
            ErrorCode.InternalError,
            `OpenAI API 오류 (${statusCode}): ${
              typeof responseData === 'object' 
                ? JSON.stringify(responseData, null, 2) 
                : responseData || error.message
            }`
          );
        }
        
        throw new McpError(ErrorCode.InternalError, `이미지 생성 요청 실패: ${formatError(error)}`);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool 'returns the generated image file path' and that 'this path must be communicated to the user,' which provides some behavioral context about output format and user communication requirements. However, it doesn't disclose important behavioral traits like whether this is a read-only operation, potential costs/rate limits, authentication needs, error handling, or what happens with the generated files. For a tool that creates external resources (image files), this is insufficient behavioral transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with two sentences that efficiently convey the core functionality and a key behavioral requirement. The first sentence states the primary purpose, and the second adds important output handling information. There's no wasted language or unnecessary elaboration. However, it could be slightly more structured by explicitly separating purpose from behavioral requirements.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (8 parameters, image generation with file creation) and the absence of both annotations and output schema, the description is minimally adequate. It covers the basic purpose and mentions the return value format (file path), but doesn't address important contextual aspects like error conditions, file system implications, or how this tool differs from the many sibling image generation tools. The 100% schema coverage helps, but for a tool that creates external resources, more behavioral context would be beneficial.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with all 8 parameters well-documented in the schema itself. The description adds no parameter-specific information beyond what's already in the schema. According to the scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description. The description doesn't compensate with additional parameter semantics, but doesn't need to since the schema is comprehensive.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'OpenAI DALL-E API를 사용하여 이미지를 생성합니다' (uses OpenAI DALL-E API to generate images). It specifies the verb ('생성합니다' - generate) and resource ('이미지' - images). However, it doesn't explicitly differentiate from sibling tools like 'mcp_gemini_create_image' or 'mcp_imagen_generate', which appear to serve similar image generation purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With multiple image generation tools in the sibling list (mcp_gemini_create_image, mcp_gemini_generate_image, mcp_gemini_generate_images, mcp_imagen_generate), there's no indication of when this OpenAI-specific tool is preferred over Gemini or Imagen alternatives. The description only states what the tool does, not when to choose it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/bigdata-coss/agent_mcp'

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