Skip to main content
Glama

generate_image

Generate AI images using Azure DALL-E 3 or FLUX models. Describe your desired image in natural language, choose models and dimensions, and create visuals for various applications.

Instructions

🎨 Create stunning AI-generated images using Azure DALL-E 3 or FLUX models with intelligent model selection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesDescribe the image you want to create in natural language. Be detailed for best results. Examples: "A serene mountain landscape at sunset", "Modern minimalist logo design", "Cute cartoon mascot for a coffee shop"
modelNoChoose AI model: "dall-e-3" (photorealistic, artistic), "flux" (creative, flexible), or "auto" (smart selection based on prompt)auto
sizeNoImage dimensions: Square (1024x1024) for social media, Wide (1792x1024) for banners, Tall (1024x1792) for posters1024x1024
styleNoVisual style (DALL-E only): "vivid" for dramatic/artistic, "natural" for realistic/subduedvivid
qualityNoImage quality (DALL-E only): "standard" for faster generation, "hd" for higher detailstandard

Implementation Reference

  • The core handler function that implements the logic for the 'generate_image' tool. It destructures input arguments, selects the model, calls the appropriate image generation method (DALL-E or FLUX), handles the response, and formats the output with text and base64-encoded image data.
    async generateImage(args) {
        const startTime = Date.now();
        // Starting image generation
    
        const { prompt, model: requestedModel = 'auto', size = '1024x1024', style = 'vivid', quality = 'standard' } = args;
    
        if (!prompt) {
            throw new Error('Prompt is required for image generation');
        }
    
        try {
            const modelSelectionStart = Date.now();
            const selectedModel = this.selectModel(prompt, requestedModel);
            const modelSelectionTime = Date.now() - modelSelectionStart;
    
            // Model selection and generation setup complete
    
            const apiCallStart = Date.now();
            let result;
            if (selectedModel === 'dall-e-3') {
                result = await this.generateWithDallE(prompt, size, style, quality);
            } else {
                result = await this.generateWithFlux(prompt, size);
            }
            const apiCallTime = Date.now() - apiCallStart;
    
            const totalTime = Date.now() - startTime;
            // Image generation completed successfully
    
            return {
                content: [
                    {
                        type: 'text',
                        text: `🎨 **Your AI-Generated Image is Ready!**\n\n✨ **Created from:** "${prompt}"\n🤖 **AI Model:** ${selectedModel.toUpperCase()} ${selectedModel === 'dall-e-3' ? '(Photorealistic AI)' : '(Creative AI)'}\n📐 **Size:** ${size}\n⏱️ **Generation Time:** ${(totalTime / 1000).toFixed(1)}s\n${requestedModel === 'auto' ? `🧠 **Smart Selection:** Chose ${selectedModel.toUpperCase()} based on your prompt\n` : ''}\n🖼️ Your custom image has been generated and is displayed below. Feel free to save, share, or use it however you'd like!`
                    },
                    {
                        type: 'image',
                        mimeType: 'image/png',
                        data: result.imageData
                    }
                ]
            };
    
        } catch (error) {
            const totalTime = Date.now() - startTime;
            console.error(`❌ [MCP] Error after ${totalTime}ms:`, error);
            throw new Error(`Failed to generate image: ${error.message}`);
        }
    }
  • The input schema for the 'generate_image' tool, defining the structure and validation for parameters: prompt (required), model (with enum and default), size, style, and quality.
    inputSchema: {
        type: 'object',
        properties: {
            prompt: {
                type: 'string',
                description: 'Describe the image you want to create in natural language. Be detailed for best results. Examples: "A serene mountain landscape at sunset", "Modern minimalist logo design", "Cute cartoon mascot for a coffee shop"'
            },
            model: {
                type: 'string',
                description: 'Choose AI model: "dall-e-3" (photorealistic, artistic), "flux" (creative, flexible), or "auto" (smart selection based on prompt)',
                enum: ['dall-e-3', 'flux', 'auto'],
                default: 'auto'
            },
            size: {
                type: 'string',
                description: 'Image dimensions: Square (1024x1024) for social media, Wide (1792x1024) for banners, Tall (1024x1792) for posters',
                enum: ['1024x1024', '1792x1024', '1024x1792'],
                default: '1024x1024'
            },
            style: {
                type: 'string',
                description: 'Visual style (DALL-E only): "vivid" for dramatic/artistic, "natural" for realistic/subdued',
                enum: ['vivid', 'natural'],
                default: 'vivid'
            },
            quality: {
                type: 'string',
                description: 'Image quality (DALL-E only): "standard" for faster generation, "hd" for higher detail',
                enum: ['standard', 'hd'],
                default: 'standard'
            }
        },
        required: ['prompt']
  • Tool registration in the ListToolsRequestHandler. Responds with the 'generate_image' tool's name, description, and input schema when clients query available tools.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
        tools: [
            {
                name: 'generate_image',
                description: '🎨 Create stunning AI-generated images using Azure DALL-E 3 or FLUX models with intelligent model selection',
                inputSchema: {
                    type: 'object',
                    properties: {
                        prompt: {
                            type: 'string',
                            description: 'Describe the image you want to create in natural language. Be detailed for best results. Examples: "A serene mountain landscape at sunset", "Modern minimalist logo design", "Cute cartoon mascot for a coffee shop"'
                        },
                        model: {
                            type: 'string',
                            description: 'Choose AI model: "dall-e-3" (photorealistic, artistic), "flux" (creative, flexible), or "auto" (smart selection based on prompt)',
                            enum: ['dall-e-3', 'flux', 'auto'],
                            default: 'auto'
                        },
                        size: {
                            type: 'string',
                            description: 'Image dimensions: Square (1024x1024) for social media, Wide (1792x1024) for banners, Tall (1024x1792) for posters',
                            enum: ['1024x1024', '1792x1024', '1024x1792'],
                            default: '1024x1024'
                        },
                        style: {
                            type: 'string',
                            description: 'Visual style (DALL-E only): "vivid" for dramatic/artistic, "natural" for realistic/subdued',
                            enum: ['vivid', 'natural'],
                            default: 'vivid'
                        },
                        quality: {
                            type: 'string',
                            description: 'Image quality (DALL-E only): "standard" for faster generation, "hd" for higher detail',
                            enum: ['standard', 'hd'],
                            default: 'standard'
                        }
                    },
                    required: ['prompt']
                }
            }
        ]
    }));
  • Tool call dispatch registration in the CallToolRequestHandler. Routes 'generate_image' tool invocations to the generateImage handler method.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
        const { name, arguments: args } = request.params;
    
        if (name === 'generate_image') {
            return await this.generateImage(args);
        }
    
        throw new Error(`Unknown tool: ${name}`);
    });
  • Helper method for intelligent model selection between 'dall-e-3' and 'flux' based on explicit user request or prompt keywords.
    selectModel(prompt, requestedModel) {
        if (requestedModel !== 'auto') {
            return requestedModel;
        }
    
        // Check if user explicitly mentions DALL-E
        const lowerPrompt = prompt.toLowerCase();
        const isDalleRequest = ['dall-e', 'dalle', 'dall e'].some(keyword => lowerPrompt.includes(keyword));
    
        return isDalleRequest ? 'dall-e-3' : 'flux';
    }
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/malikmalikayesha/Azure-Image-Generation-MCP'

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