Skip to main content
Glama
ciel240
by ciel240

generate_image

Create custom images from text prompts using AI image generation. Describe what you want to see and generate corresponding visuals.

Instructions

텍스트 프롬프트를 사용하여 이미지를 생성하는 도구

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYes이미지 생성을 위한 프롬프트

Implementation Reference

  • Core handler function that generates an image from a text prompt using Hugging Face Inference API (FLUX.1-schnell model) and returns it as base64 string.
    const generateImage = async (prompt: string, hfToken: string): Promise<string> => {
        if (!hfToken) {
            throw new Error('HF_TOKEN이 설정되지 않았습니다. Hugging Face API 토큰을 설정해주세요.')
        }
    
        const client = new InferenceClient(hfToken)
        
        try {
            const image = await client.textToImage({
                provider: "fal-ai",
                model: "black-forest-labs/FLUX.1-schnell",
                inputs: prompt,
                parameters: { num_inference_steps: 5 }
            })
    
            // Convert to base64
            let base64: string
            if (typeof image === 'string') {
                // If it's already a base64 string, use it directly
                base64 = image
            } else if (image && typeof image === 'object' && 'arrayBuffer' in image) {
                // If it's a Blob-like object
                const arrayBuffer = await (image as any).arrayBuffer()
                base64 = Buffer.from(arrayBuffer).toString('base64')
            } else {
                // If it's a Buffer or Uint8Array
                base64 = Buffer.from(image as any).toString('base64')
            }
            
            return base64
        } catch (error) {
            throw new Error(`이미지 생성 중 오류가 발생했습니다: ${error instanceof Error ? error.message : '알 수 없는 오류'}`)
        }
    }
  • Zod schema defining the input for generate_image tool: a single 'prompt' string parameter.
    const ImageGenerationToolSchema = z.object({
        prompt: z.string().describe('이미지 생성을 위한 프롬프트')
    })
  • src/index.ts:394-407 (registration)
    Registration of generate_image tool in the MCP listTools handler, specifying name, description, and input schema.
    {
        name: 'generate_image',
        description: '텍스트 프롬프트를 사용하여 이미지를 생성하는 도구',
        inputSchema: {
            type: 'object',
            properties: {
                prompt: {
                    type: 'string',
                    description: '이미지 생성을 위한 프롬프트'
                }
            },
            required: ['prompt']
        }
    }
  • MCP CallToolRequest handler branch for generate_image: validates input with schema, invokes generateImage function, returns base64 image content or error text.
    if (request.params.name === 'generate_image') {
        try {
            const { prompt } = ImageGenerationToolSchema.parse(request.params.arguments)
            
            const base64Image = await generateImage(prompt, hfToken)
            
            return {
                content: [
                    {
                        type: 'image',
                        data: base64Image,
                        mimeType: 'image/png',
                        annotations: {
                            audience: ['user'],
                            priority: 0.9
                        }
                    }
                ]
            }
        } catch (error) {
            return {
                content: [
                    {
                        type: 'text',
                        text: `이미지 생성 오류: ${error instanceof Error ? error.message : '알 수 없는 오류'}`
                    }
                ],
                isError: true
            }
        }
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It only states the basic function without details on traits like rate limits, quality of output, processing time, or error conditions. For a generative tool with zero annotation coverage, this is a significant gap in transparency.

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

Conciseness5/5

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

The description is a single, efficient sentence that directly states the tool's purpose without any wasted words. It is appropriately sized and front-loaded, making it easy to understand quickly.

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

Completeness2/5

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

Given the tool's complexity (generative AI with potential for varied outputs) and lack of annotations and output schema, the description is incomplete. It doesn't cover behavioral aspects, return values, or usage context, leaving gaps for an AI agent to understand how to invoke it effectively.

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 schema description coverage is 100%, with the parameter 'prompt' fully documented in the schema. The description adds no additional meaning beyond what the schema provides, such as prompt formatting tips or examples. Baseline 3 is appropriate since the schema does the heavy lifting.

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: '텍스트 프롬프트를 사용하여 이미지를 생성하는 도구' translates to 'A tool that generates images using text prompts.' This specifies the verb (generate images) and resource (images) with the mechanism (text prompts). However, it doesn't distinguish from siblings since none are image-related tools, so it lacks explicit differentiation.

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. It states what the tool does but offers no context about scenarios, prerequisites, or comparisons with other tools. Since siblings include unrelated tools like calculator and code_review, there's no implied usage for choosing this one.

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

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/ciel240/class_study'

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