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
      ],
    }));
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but offers minimal information. It doesn't describe what happens during generation (e.g., processing order, error handling), output format, rate limits, authentication needs, or whether it's a read/write operation. The description merely states what the tool does without revealing how it behaves.

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?

The description is extremely concise - a single sentence with zero wasted words. It's front-loaded with the core functionality and appropriately sized for the tool's complexity. Every word earns its place in communicating the essential purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a batch generation tool with no annotations and no output schema, the description is insufficiently complete. It doesn't address critical context like what the tool returns (image URLs, file paths, error information), how multiple prompts are processed, or any behavioral characteristics. The agent would need to guess about important operational aspects.

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 description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain prompt formatting expectations, width/height constraints, or customPath usage scenarios. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('generate multiple images') and the resource ('from a list of prompts'), making the purpose immediately understandable. It distinguishes from 'generateImage' by specifying 'multiple' images, but doesn't explicitly differentiate from 'quickImage' which might imply a similar batch capability.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus the sibling tools 'generateImage' or 'quickImage'. There's no mention of use cases, prerequisites, performance considerations, or alternative selection criteria, leaving the agent with insufficient context for optimal tool selection.

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/frankdeno/flux-image-generator-mcp'

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