Skip to main content
Glama

generate_character

Create character sprites with multiple poses for game development using AI workflows. Specify character descriptions, poses, and style presets to generate 2D game assets.

Instructions

Generate character sprites with optional multiple poses.

Args:
    description: Character description (e.g., "a knight in silver armor")
    poses: List of poses to generate (e.g., ["idle", "walking", "attacking"])
    preset: Style preset to use (default: character). Options: character, character_portrait, pixel_character
    width: Sprite width in pixels
    height: Sprite height in pixels
    seed: Base seed for reproducibility (each pose gets seed+index)
    steps: Override generation steps (higher = better quality but slower)
    save_to_file: Whether to save images to disk

Returns:
    JSON with base64 images for each pose

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYes
posesNo
presetNocharacter
widthNo
heightNo
seedNo
stepsNo
save_to_fileNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The @mcp.tool()-decorated handler function implementing the 'generate_character' tool. Generates character sprites in specified poses using AI backend, handles presets, resizing, and returns JSON with base64 images or file paths.
    @mcp.tool()
    async def generate_character(
        description: str,
        poses: List[str] = None,
        preset: str = "character",
        width: int = 256,
        height: int = 512,
        seed: Optional[int] = None,
        steps: Optional[int] = None,
        save_to_file: bool = True
    ) -> str:
        """Generate character sprites with optional multiple poses.
        
        Args:
            description: Character description (e.g., "a knight in silver armor")
            poses: List of poses to generate (e.g., ["idle", "walking", "attacking"])
            preset: Style preset to use (default: character). Options: character, character_portrait, pixel_character
            width: Sprite width in pixels
            height: Sprite height in pixels
            seed: Base seed for reproducibility (each pose gets seed+index)
            steps: Override generation steps (higher = better quality but slower)
            save_to_file: Whether to save images to disk
        
        Returns:
            JSON with base64 images for each pose
        """
        if poses is None:
            poses = ["idle"]
    
        desc_lower = description.lower()
        if preset == "character" and any(
            k in desc_lower
            for k in (
                "top-down",
                "top down",
                "topdown",
                "overhead",
                "stardew",
            )
        ):
            preset = "topdown_character"
        
        preset_config = get_preset(preset)
        gen_steps = steps or preset_config.steps
     
        render_width = width
        render_height = height
        should_downscale = (width < preset_config.default_width) or (height < preset_config.default_height)
        if should_downscale:
            render_width = preset_config.default_width
            render_height = preset_config.default_height
         
        characters = []
        for i, pose in enumerate(poses):
            prompt = f"{description}, {pose} pose"
            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=render_width,
                height=render_height,
                seed=gen_seed,
                steps=gen_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, width, height, resample=resample)
            
            char_data = {
                "index": i,
                "pose": pose,
                "image_base64": image_to_base64(image_bytes),
                "width": width,
                "height": height
            }
            
            if save_to_file:
                output_dir = ensure_directory(OUTPUT_DIR / "characters")
                fname = generate_filename(prefix=f"char_{pose}")
                file_path = output_dir / fname
                file_path.write_bytes(image_bytes)
                char_data["file_path"] = str(file_path)
            
            characters.append(char_data)
        
        return json.dumps({
            "success": True,
            "description": description,
            "count": len(characters),
            "characters": characters
        }, indent=2)
Behavior2/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 mentions that images can be saved to disk and that higher steps improve quality but slow down generation, which adds some context. However, it lacks critical behavioral details such as rate limits, authentication requirements, file formats, error conditions, or performance characteristics, leaving significant gaps for an AI agent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and appropriately sized, with a clear purpose statement followed by parameter explanations and return information. Every sentence adds value, though the 'Returns' section could be slightly more detailed (e.g., specifying JSON structure). It's front-loaded with the core functionality, making it efficient for quick understanding.

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 complexity (8 parameters, no annotations, but with an output schema), the description is largely complete. It covers all parameters thoroughly, explains the return format ('JSON with base64 images for each pose'), and includes behavioral notes like quality-speed trade-offs. The output schema reduces the need to detail return values, but minor gaps remain in usage guidelines and full behavioral transparency.

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?

The description adds substantial meaning beyond the input schema, which has 0% description coverage. It explains each parameter's purpose with examples (e.g., 'description: Character description (e.g., "a knight in silver armor")'), clarifies defaults and options (e.g., 'preset: Style preset to use (default: character). Options: character, character_portrait, pixel_character'), and details behavioral aspects like seed reproducibility ('each pose gets seed+index'). This fully compensates for the schema's lack of descriptions.

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 character sprites with optional multiple poses.' It specifies the verb ('generate'), resource ('character sprites'), and scope ('with optional multiple poses'), distinguishing it from sibling tools like generate_sprite or generate_character_animations by focusing specifically on character generation with pose variations.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like generate_sprite or generate_character_animations, nor does it specify prerequisites, use cases, or exclusions. The only contextual hint is 'optional multiple poses,' which is insufficient for distinguishing among similar generation tools.

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