Skip to main content
Glama
frankdeno

FLUX Image Generator MCP Server

by frankdeno

batchGenerateImages

Generate multiple images simultaneously from a list of text prompts with customizable dimensions and save paths using the FLUX model.

Instructions

Generate multiple images from a list of prompts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptsYesList of text prompts
widthNoWidth of the images
heightNoHeight of the images
customPathNoCustom path to save the generated images

Implementation Reference

  • The handler function for the 'batchGenerateImages' tool within the CallToolRequestSchema handler. It validates the 'prompts' array, iterates over each prompt, generates images using the 'generateImage' helper, handles individual errors, and compiles a text response with results, image URLs, and local paths.
    case "batchGenerateImages": { if (!Array.isArray(args.prompts)) { throw new Error("Invalid arguments for batchGenerateImages: 'prompts' must be an array"); } // Process multiple prompts const results = []; let htmlOutput = ""; for (const prompt of args.prompts) { if (typeof prompt !== 'string') { throw new Error("Invalid prompt in array: each prompt must be a string"); } try { const result = await generateImage(prompt, { width: typeof args.width === 'number' ? args.width : 1024, height: typeof args.height === 'number' ? args.height : 1024, saveImage: true, filename: `flux_batch_${Date.now()}_${args.prompts.indexOf(prompt)}.png`, customPath: typeof args.customPath === 'string' ? // If customPath ends with .png or .jpg, use it as is for the first image // Otherwise treat it as a directory and append the generated filename (args.prompts.length === 1 && /\.(png|jpg|jpeg)$/i.test(args.customPath) ? args.customPath : args.customPath ? `${args.customPath}/flux_batch_${Date.now()}_${args.prompts.indexOf(prompt)}.png` : undefined) : undefined }); // Add text output for this result with save location info htmlOutput += `Prompt: "${prompt}"\n`; htmlOutput += `Image generated\nLink: ${result.image_url}\n`; // Add information about where the image was saved if (result.local_path) { htmlOutput += `Image saved to: ${result.local_path}\n`; } htmlOutput += `\n`; results.push({ prompt, success: true, image_url: result.image_url, local_path: result.local_path }); } catch (error: any) { // Add error message for failed generations htmlOutput += `Failed to generate image for prompt: "${prompt}"\nError: ${error.message}\n\n`; results.push({ prompt, success: false, error: error.message }); } } return { content: [ { type: "text", text: htmlOutput } ], isError: false, }; }
  • The schema definition for the batchGenerateImages tool, specifying name, description, and inputSchema with required 'prompts' array and optional parameters.
    export const BATCH_GENERATE_IMAGES_TOOL: Tool = { name: "batchGenerateImages", description: "Generate multiple images from a list of prompts", inputSchema: { type: "object", properties: { prompts: { type: "array", items: { type: "string" }, description: "List of text prompts" }, width: { type: "number", description: "Width of the images", default: 1024 }, height: { type: "number", description: "Height of the images", default: 1024 }, customPath: { type: "string", description: "Custom path to save the generated images" } }, required: ["prompts"] } };
  • src/index.ts:48-54 (registration)
    Registration of the batchGenerateImages tool in the listTools response, where BATCH_GENERATE_IMAGES_TOOL is included in the array of available tools returned by the server.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ GENERATE_IMAGE_TOOL, QUICK_IMAGE_TOOL, BATCH_GENERATE_IMAGES_TOOL ], }));
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/frankdeno/flux-image-generator-mcp'

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