Skip to main content
Glama

generate_tileset

Create tileable game tiles for specific themes and tile types using AI workflows, supporting style presets and reproducible seeds for consistent asset generation.

Instructions

Generate a set of tileable game tiles.

Args:
    theme: Overall theme for the tileset (e.g., "forest", "dungeon", "sci-fi")
    tile_types: List of tile types to generate (e.g., ["ground", "wall", "water"])
    preset: Style preset to use (default: tileset). Options: tileset, topdown_tile
    tile_size: Size of each tile in pixels (square)
    seed: Base seed for reproducibility (each tile gets seed+index)
    save_to_file: Whether to save images to disk

Returns:
    JSON with base64 images for each tile type

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
themeYes
tile_typesYes
presetNotileset
tile_sizeNo
seedNo
save_to_fileNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The complete implementation of the generate_tileset tool handler, including registration via @mcp.tool() decorator. It generates multiple tile images based on theme and types using the AI backend, handles resizing, and returns JSON with base64 images.
    @mcp.tool()
    async def generate_tileset(
        theme: str,
        tile_types: List[str],
        preset: str = "tileset",
        tile_size: int = 32,
        seed: Optional[int] = None,
        save_to_file: bool = False
    ) -> str:
        """Generate a set of tileable game tiles.
        
        Args:
            theme: Overall theme for the tileset (e.g., "forest", "dungeon", "sci-fi")
            tile_types: List of tile types to generate (e.g., ["ground", "wall", "water"])
            preset: Style preset to use (default: tileset). Options: tileset, topdown_tile
            tile_size: Size of each tile in pixels (square)
            seed: Base seed for reproducibility (each tile gets seed+index)
            save_to_file: Whether to save images to disk
        
        Returns:
            JSON with base64 images for each tile type
        """
        if not tile_types:
            return json.dumps({"success": False, "error": "No tile_types provided"}, indent=2)
        
        preset_config = get_preset(preset)
        
        tiles = []
        for i, tile_type in enumerate(tile_types):
            prompt = f"{theme} {tile_type} tile"
            full_prompt = f"{preset_config.prompt_prefix}{prompt}{preset_config.prompt_suffix}"
            gen_seed = (seed + i) if seed is not None else None
     
            render_size = tile_size
            should_downscale = tile_size < min(preset_config.default_width, preset_config.default_height)
            if should_downscale:
                render_size = min(preset_config.default_width, preset_config.default_height)
             
            image_bytes = await backend.generate_image(
                prompt=full_prompt,
                negative_prompt=preset_config.negative_prompt,
                width=render_size,
                height=render_size,
                seed=gen_seed,
                steps=preset_config.steps,
                cfg_scale=preset_config.cfg_scale,
                sampler=preset_config.sampler,
                scheduler=preset_config.scheduler
            )
     
            if should_downscale:
                resample = Image.Resampling.NEAREST if preset.startswith("pixel") else Image.Resampling.LANCZOS
                image_bytes = resize_image(image_bytes, tile_size, tile_size, resample=resample)
            
            tile_data = {
                "index": i,
                "type": tile_type,
                "theme": theme,
                "image_base64": image_to_base64(image_bytes),
                "size": tile_size
            }
            
            if save_to_file:
                output_dir = ensure_directory(OUTPUT_DIR / "tiles" / theme)
                fname = generate_filename(prefix=f"tile_{tile_type}")
                file_path = output_dir / fname
                file_path.write_bytes(image_bytes)
                tile_data["file_path"] = str(file_path)
            
            tiles.append(tile_data)
        
        return json.dumps({
            "success": True,
            "theme": theme,
            "tile_size": tile_size,
            "count": len(tiles),
            "tiles": tiles
        }, 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. It discloses that tiles are generated based on theme and types, includes reproducibility via seed, and mentions output format (JSON with base64 images) and optional file saving. However, it lacks details on performance, rate limits, authentication needs, or error conditions.

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 clear parameter explanations and return value. Every sentence adds value without redundancy, making it efficient and easy to parse.

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 tool's moderate complexity (6 parameters, generation task) and no annotations, the description does well: it explains the purpose, parameters, and output (with output schema present, return values are covered). However, it lacks usage guidelines and some behavioral context like performance or limits, keeping it from a perfect score.

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 adds meaningful context for all parameters: theme examples (e.g., 'forest'), tile_types examples (e.g., ['ground', 'wall', 'water']), preset options and default, tile_size clarification ('in pixels (square)'), seed behavior ('each tile gets seed+index'), and save_to_file purpose. This significantly enhances understanding beyond the bare schema.

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 tool's purpose: 'Generate a set of tileable game tiles.' It specifies the verb ('generate') and resource ('tileable game tiles'), distinguishing it from sibling tools like generate_character or generate_sprite which target different assets.

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 is provided on when to use this tool versus alternatives. While it's clear this generates tiles, there's no mention of when to choose it over sibling tools like generate_topdown_asset or create_sprite_atlas, nor any prerequisites or exclusions for usage.

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