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
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | Choose AI model: "dall-e-3" (photorealistic, artistic), "flux" (creative, flexible), or "auto" (smart selection based on prompt) | auto |
| prompt | Yes | 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" | |
| quality | No | Image quality (DALL-E only): "standard" for faster generation, "hd" for higher detail | standard |
| size | No | Image dimensions: Square (1024x1024) for social media, Wide (1792x1024) for banners, Tall (1024x1792) for posters | 1024x1024 |
| style | No | Visual style (DALL-E only): "vivid" for dramatic/artistic, "natural" for realistic/subdued | vivid |
Implementation Reference
- azure-image-generation-server.js:103-151 (handler)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'] }
- azure-image-generation-server.js:37-75 (registration)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'] } } ]
- azure-image-generation-server.js:82-84 (registration)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'; }