Skip to main content
Glama
JunWoo0406

TypeScript MCP Server Boilerplate

by JunWoo0406

generate-image

Generate images from text prompts using the Hugging Face FLUX.1-schnell model. Specify prompt and inference steps to create visual content.

Instructions

텍스트 프롬프트를 입력하면 이미지를 생성합니다. Hugging Face FLUX.1-schnell 모델을 사용합니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYes이미지 생성 프롬프트 (영어 권장)
num_inference_stepsNo추론 스텝 수 (기본값: 4, 범위: 1~10)

Implementation Reference

  • Implementation of the 'generate-image' tool, which uses Hugging Face InferenceClient to generate images based on a text prompt.
    server.registerTool(
        'generate-image',
        {
            description: '텍스트 프롬프트를 입력하면 이미지를 생성합니다. Hugging Face FLUX.1-schnell 모델을 사용합니다.',
            inputSchema: z.object({
                prompt: z.string().describe('이미지 생성 프롬프트 (영어 권장)'),
                num_inference_steps: z
                    .number()
                    .int()
                    .min(1)
                    .max(10)
                    .optional()
                    .default(4)
                    .describe('추론 스텝 수 (기본값: 4, 범위: 1~10)')
            })
        },
        async ({ prompt, num_inference_steps }) => {
            const token = process.env.HF_TOKEN
            if (!token || token === 'YOUR_HF_TOKEN_HERE') {
                const errorText = '오류: HF_TOKEN 환경변수가 설정되지 않았습니다. .cursor/mcp.json의 env.HF_TOKEN에 실제 토큰을 입력해 주세요.'
                return {
                    content: [{ type: 'text' as const, text: errorText }],
                    structuredContent: { content: [{ type: 'text' as const, text: errorText }] }
                }
            }
    
            try {
                const client = new InferenceClient(token)
                const imageBlob = await client.textToImage(
                    {
                        provider: 'together',
                        model: 'black-forest-labs/FLUX.1-schnell',
                        inputs: prompt,
                        parameters: { num_inference_steps }
                    },
                    { outputType: 'blob' }
                )
                const base64 = Buffer.from(await imageBlob.arrayBuffer()).toString('base64')
                return {
                    content: [
                        {
                            type: 'image' as const,
                            data: base64,
                            mimeType: 'image/png' as const
                        }
                    ]
                }
            } catch (err) {
                const errorText = `오류: 이미지 생성 실패 — ${err instanceof Error ? err.message : String(err)}`
                return {
                    content: [{ type: 'text' as const, text: errorText }],
                    structuredContent: { content: [{ type: 'text' as const, text: errorText }] }
                }
            }
        }
    )
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It successfully discloses the specific model (FLUX.1-schnell) which hints at speed/quality tradeoffs, but lacks details about output format (URL vs base64), file persistence, authentication requirements, or rate limiting that would be crucial for an agent to know before invocation.

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?

Two compact sentences with zero redundancy. The first establishes the input-output contract (prompt → image), the second provides implementation context (model name). Every word earns its place; structure is front-loaded with the most critical information.

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?

For a 2-parameter tool with complete schema documentation, the description is minimally sufficient. It mentions the specific model which is helpful context. However, given no output schema exists, the description could have clarified the return format (e.g., image URL, base64 data) or whether the generation is synchronous/asynchronous.

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?

Schema coverage is 100%, establishing a baseline of 3. The description references '텍스트 프롬프트' (text prompt) which aligns with the required 'prompt' parameter, but adds no semantic detail beyond the schema for 'num_inference_steps' or regarding parameter interactions. The schema fully documents both parameters, so minimal additional description is needed.

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

Purpose5/5

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

The description clearly states the specific action (generate images) and resource (images from text prompts), and explicitly names the underlying model (FLUX.1-schnell). It clearly distinguishes from siblings like calc, geocode, and get-weather which handle completely different domains.

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

Usage Guidelines3/5

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

No explicit when-to-use or when-not-to-use guidance is provided. While the purpose is clear enough that an agent would know to use this for image generation tasks, there is no discussion of prerequisites, rate limits, or comparison to hypothetical alternative image generation approaches.

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/JunWoo0406/my-mcp-server'

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