Skip to main content
Glama

batch_generate

Generate multiple 2D game assets from a list of prompts using AI workflows, with style presets, dimension control, and reproducibility options.

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

Implementation Reference

  • The batch_generate tool handler, registered via @mcp.tool() decorator. Generates multiple images in batch using the backend, supports presets, saving to file, and returns JSON with base64 images.
    @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)

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