Skip to main content
Glama

batch_generate

Generate multiple 2D game assets simultaneously from a list of prompts using style presets and customizable dimensions for efficient workflow automation.

Instructions

Generate multiple assets in batch from a list of prompts.

Args:
    prompts: List of asset descriptions
    preset: Style preset to use for all generations
    width: Override width for all assets
    height: Override height for all assets
    seed: Base seed for reproducibility (each prompt gets seed+index)
    save_to_file: Whether to save all images to disk

Returns:
    JSON with all generated assets

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptsYes
presetNodefault
widthNo
heightNo
seedNo
save_to_fileNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The batch_generate tool handler: an async function decorated with @mcp.tool() that registers and implements the tool. It generates multiple game assets in batch from a list of prompts using the configured backend (Mock or ComfyUI), applies presets, handles parameters like width/height/seed, and returns JSON with base64 images or file paths.
    @mcp.tool()
    async def batch_generate(
        prompts: List[str],
        preset: str = "default",
        width: Optional[int] = None,
        height: Optional[int] = None,
        seed: Optional[int] = None,
        save_to_file: bool = False
    ) -> str:
        """Generate multiple assets in batch from a list of prompts.
        
        Args:
            prompts: List of asset descriptions
            preset: Style preset to use for all generations
            width: Override width for all assets
            height: Override height for all assets
            seed: Base seed for reproducibility (each prompt gets seed+index)
            save_to_file: Whether to save all images to disk
        
        Returns:
            JSON with all generated assets
        """
        if not prompts:
            return json.dumps({"success": False, "error": "No prompts provided"}, indent=2)
        
        preset_config = get_preset(preset)
        
        results = []
        for i, prompt in enumerate(prompts):
            full_prompt = f"{preset_config.prompt_prefix}{prompt}{preset_config.prompt_suffix}"
            
            img_width = width or preset_config.default_width
            img_height = height or preset_config.default_height
            gen_seed = (seed + i) if seed is not None else None
            
            image_bytes = await backend.generate_image(
                prompt=full_prompt,
                negative_prompt=preset_config.negative_prompt,
                width=img_width,
                height=img_height,
                seed=gen_seed,
                steps=preset_config.steps,
                cfg_scale=preset_config.cfg_scale,
                sampler=preset_config.sampler,
                scheduler=preset_config.scheduler
            )
            
            asset_data = {
                "index": i,
                "prompt": prompt,
                "image_base64": image_to_base64(image_bytes),
                "width": img_width,
                "height": img_height
            }
            
            if save_to_file:
                output_dir = ensure_directory(OUTPUT_DIR / "batch")
                fname = generate_filename(prefix=f"batch_{i}")
                file_path = output_dir / fname
                file_path.write_bytes(image_bytes)
                asset_data["file_path"] = str(file_path)
            
            results.append(asset_data)
        
        return json.dumps({
            "success": True,
            "preset": preset,
            "count": len(results),
            "assets": results
        }, indent=2)
Behavior3/5

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

With no annotations, the description carries full burden. It discloses that assets are generated from prompts, can be saved to disk, and seeds are reproducible with index offset. However, it lacks details on rate limits, authentication needs, error handling, or what 'assets' specifically are (e.g., images, sprites). Some behavioral context is given but incomplete for a mutation tool.

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 well-structured and front-loaded with the core purpose. Each sentence adds value: the first states the batch operation, the Args section details parameters efficiently, and the Returns section clarifies output. No wasted words, appropriately sized for the complexity.

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

Completeness4/5

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

Given 6 parameters, no annotations, and an output schema, the description is mostly complete. It explains parameters thoroughly and notes the JSON return, leveraging the output schema. However, as a mutation tool with no annotations, it could better cover behavioral aspects like side effects or error cases, slightly reducing completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate fully. It provides clear semantics for all 6 parameters: prompts as asset descriptions, preset for style, width/height as overrides, seed for reproducibility with index offset, and save_to_file for disk storage. This adds substantial meaning beyond the bare schema.

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 tool generates multiple assets from prompts, specifying 'batch' operation. It distinguishes from single-generation siblings like generate_sprite or generate_character by emphasizing multiple assets from a list. However, it doesn't explicitly contrast with other batch-capable tools like generate_icons or generate_tileset.

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?

No guidance on when to use this tool versus alternatives is provided. The description doesn't mention when batch generation is preferred over individual tools, nor does it reference sibling tools like generate_sprite for single assets or generate_icons for specific types. Usage context is implied but not stated.

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/tuannguyen14/ComfyAI-MCP-GameAssets'

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