Skip to main content
Glama
bakcoder

TypeScript MCP Server Boilerplate

by bakcoder

generate-image

Create images from text prompts using HuggingFace's FLUX.1-schnell model. Specify inference steps and provide your HF_TOKEN to generate visual content.

Instructions

HuggingFace Inference API를 사용해 텍스트 프롬프트로 이미지를 생성합니다. (모델: black-forest-labs/FLUX.1-schnell, 환경변수 HF_TOKEN 필요)

Input Schema

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

Implementation Reference

  • The handler logic for the 'generate-image' tool, which uses HuggingFace Inference API to generate an image from a prompt.
    async ({ prompt, num_inference_steps }) => {
        const token = process.env.HF_TOKEN
        if (!token) {
            return {
                content: [
                    {
                        type: 'text' as const,
                        text: 'HF_TOKEN 환경변수가 설정되지 않았습니다. Hugging Face 액세스 토큰을 HF_TOKEN 환경변수로 설정해주세요.'
                    }
                ]
            }
        }
    
        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 = await blobToBase64(imageBlob)
    
            return {
                content: [
                    {
                        type: 'image' as const,
                        data: base64,
                        mimeType: 'image/png'
                    }
                ]
            }
        } catch (error) {
            const message =
                error instanceof Error ? error.message : String(error)
            return {
                content: [
                    {
                        type: 'text' as const,
                        text: `이미지 생성 실패: ${message}`
                    }
                ]
  • Input schema definition for the 'generate-image' tool, including prompt and num_inference_steps.
    inputSchema: z.object({
        prompt: z.string().describe('이미지 생성 프롬프트'),
        num_inference_steps: z
            .number()
            .int()
            .min(1)
            .max(10)
            .optional()
            .default(4)
            .describe('추론 스텝 수 (기본값: 4, 범위: 1~10)')
    })
  • src/index.ts:562-578 (registration)
    Registration of the 'generate-image' tool using server.registerTool.
    server.registerTool(
        'generate-image',
        {
            description:
                'HuggingFace Inference API를 사용해 텍스트 프롬프트로 이미지를 생성합니다. (모델: black-forest-labs/FLUX.1-schnell, 환경변수 HF_TOKEN 필요)',
            inputSchema: z.object({
                prompt: z.string().describe('이미지 생성 프롬프트'),
                num_inference_steps: z
                    .number()
                    .int()
                    .min(1)
                    .max(10)
                    .optional()
                    .default(4)
                    .describe('추론 스텝 수 (기본값: 4, 범위: 1~10)')
            })
        },
Behavior3/5

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

No annotations provided, so description carries full burden. It discloses the external API dependency, specific model version, and authentication requirement. However, it omits behavioral traits like output format (base64, URL, or binary?), inference latency expectations, rate limits, or content policy restrictions that would help an agent handle the response appropriately.

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?

Single efficient sentence containing the action, method, and parenthetical technical details (model, auth). No redundant words or wasted space; information density is high with critical details front-loaded.

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?

With no output schema provided, the description should ideally indicate what the tool returns (image data format, URL, etc.). While it covers the input parameters adequately and mentions authentication, the absence of return value documentation leaves a significant gap for an agent attempting to process the result.

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 baseline 3. The description mentions '텍스트 프롬프트' (text prompt) which aligns with the required parameter, but adds no additional semantic meaning, examples, or format guidance beyond what the schema already provides for 'prompt' and 'num_inference_steps'.

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?

Description clearly states the tool generates images using text prompts via HuggingFace Inference API. Specific model (FLUX.1-schnell) is named, and the action (생성합니다/generates) is precise. Distinct from siblings (calc, geocode, weather, etc.) which operate on entirely 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 Guidelines4/5

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

Explicitly states the authentication requirement (HF_TOKEN environment variable) which is critical for usage. While it doesn't explicitly state 'when not to use' alternatives, the sibling tools are functionally distinct (math, location, weather), making the appropriate use case self-evident.

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

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