Skip to main content
Glama

generate_image

Create AI-generated images from text descriptions using Azure DALL-E 3 or FLUX models with automatic model selection for photorealistic or creative results.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelNoChoose AI model: "dall-e-3" (photorealistic, artistic), "flux" (creative, flexible), or "auto" (smart selection based on prompt)auto
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"
qualityNoImage quality (DALL-E only): "standard" for faster generation, "hd" for higher detailstandard
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

Implementation Reference

  • Main handler function for the 'generate_image' tool. Validates input, selects model (DALL-E 3 or FLUX), calls the appropriate generator, formats response with image data and descriptive text.
    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}`); } }
  • Input schema for the generate_image tool defining parameters: prompt (required), model, size, style, quality with descriptions, enums, and defaults.
    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 ListToolsRequestSchema handler, defining name, description, and inputSchema for 'generate_image'.
    { 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'] } } ]
  • Dispatch/registration in CallToolRequestSchema handler: routes 'generate_image' calls to the generateImage method.
    if (name === 'generate_image') { return await this.generateImage(args); }
  • Helper function to select between 'dall-e-3' and 'flux' models based on user request or prompt analysis.
    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'; }

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