Skip to main content
Glama

generate_icons

Generate multiple game icons from text descriptions using style presets, with options for spritesheet creation and file saving.

Instructions

Generate multiple game icons from a list of descriptions.

Args: prompts: List of icon descriptions (e.g., ["sword", "shield", "potion"]) preset: Style preset to use (default: icon). Options: icon, icon_item, flat_ui size: Icon size in pixels (square) seed: Base seed for reproducibility (each icon gets seed+index) create_atlas: Whether to combine icons into a single spritesheet save_to_file: Whether to save images to disk Returns: JSON with base64 images for each icon and optional atlas

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptsYes
presetNoicon
sizeNo
seedNo
create_atlasNo
save_to_fileNo

Implementation Reference

  • The main handler function for the 'generate_icons' tool. It generates multiple icons from a list of prompts using the backend's generate_image method, applies resizing, optionally creates a spritesheet atlas, handles file saving, and returns a JSON response with base64-encoded images.
    @mcp.tool() async def generate_icons( prompts: List[str], preset: str = "icon", size: int = 64, seed: Optional[int] = None, create_atlas: bool = False, save_to_file: bool = False ) -> str: """Generate multiple game icons from a list of descriptions. Args: prompts: List of icon descriptions (e.g., ["sword", "shield", "potion"]) preset: Style preset to use (default: icon). Options: icon, icon_item, flat_ui size: Icon size in pixels (square) seed: Base seed for reproducibility (each icon gets seed+index) create_atlas: Whether to combine icons into a single spritesheet save_to_file: Whether to save images to disk Returns: JSON with base64 images for each icon and optional atlas """ if not prompts: return json.dumps({"success": False, "error": "No prompts provided"}, indent=2) preset_config = get_preset(preset) icons = [] for i, prompt in enumerate(prompts): full_prompt = f"{preset_config.prompt_prefix}{prompt}{preset_config.prompt_suffix}" 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=preset_config.default_width, height=preset_config.default_height, seed=gen_seed, steps=preset_config.steps, cfg_scale=preset_config.cfg_scale, sampler=preset_config.sampler, scheduler=preset_config.scheduler ) resample = Image.Resampling.NEAREST if preset.startswith("pixel") else Image.Resampling.LANCZOS image_bytes = resize_image(image_bytes, size, size, resample=resample) icon_data = { "index": i, "prompt": prompt, "image_base64": image_to_base64(image_bytes), "size": size } if save_to_file: output_dir = ensure_directory(OUTPUT_DIR / "icons") fname = generate_filename(prefix=f"icon_{i}", suffix=prompt[:20].replace(" ", "_")) file_path = output_dir / fname file_path.write_bytes(image_bytes) icon_data["file_path"] = str(file_path) icons.append(icon_data) result = { "success": True, "count": len(icons), "icons": icons } # Create atlas if requested if create_atlas and icons: all_images = [base64.b64decode(icon["image_base64"]) for icon in icons] atlas_bytes = create_spritesheet(all_images, columns=min(4, len(icons))) result["atlas_base64"] = image_to_base64(atlas_bytes) if save_to_file: output_dir = ensure_directory(OUTPUT_DIR / "atlases") atlas_path = output_dir / generate_filename(prefix="icon_atlas") atlas_path.write_bytes(atlas_bytes) result["atlas_file_path"] = str(atlas_path) return json.dumps(result, 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