Skip to main content
Glama

generate_icons

Create multiple game icons from text descriptions for use in game development projects. Supports style presets, customizable sizes, and optional spritesheet generation.

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Handler function for the 'generate_icons' tool. Decorated with @mcp.tool() for registration. Generates multiple icons from prompts using the backend, applies resizing, optionally creates a spritesheet atlas, and handles file saving. Input schema defined by function parameters.
    @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)
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes the tool's function and parameters but lacks details on permissions, rate limits, or potential side effects (e.g., file system impact from save_to_file). The return format is mentioned, but behavioral traits like error handling or performance are not covered.

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, followed by a bullet-point style breakdown of args and returns. Every sentence adds value without redundancy, making it easy to scan and understand quickly.

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 the complexity (6 parameters, no annotations) and the presence of an output schema (which covers return values), the description is largely complete. It explains all parameters and the tool's purpose, though it could benefit from more behavioral context (e.g., file system interactions, error cases) to fully compensate for the lack of annotations.

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

Parameters4/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. It provides clear semantics for all 6 parameters, explaining what each does (e.g., 'preset: Style preset to use', 'seed: Base seed for reproducibility') with examples and defaults. This adds significant value beyond the bare schema, though some details like preset options could be more explicit.

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

Purpose5/5

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

The description clearly states the specific action ('Generate multiple game icons') and resource ('from a list of descriptions'), distinguishing it from siblings like generate_character or generate_sprite by focusing on icons rather than characters, sprites, or other assets. The examples provided (sword, shield, potion) further clarify the type of content.

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

Usage Guidelines3/5

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

The description implies usage for generating game icons from text descriptions, but does not explicitly state when to use this tool versus alternatives like generate_sprite or create_sprite_atlas. No exclusions or specific contexts are provided, leaving the agent to infer based on the tool name and examples.

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