Skip to main content
Glama
yunwoong7
by yunwoong7

text_to_image

Convert text prompts into high-quality images with customizable dimensions, negative prompts, and configuration settings. Ideal for visual content creation and prototyping.

Instructions

Generate an image from a text prompt. After generation, you can use the show_image tool to view the thumbnail.

Args:
    prompt: Text prompt for generating an image (maximum 1024 characters)
    negative_prompt: Text prompt for excluding attributes from generation (maximum 1024 characters)
    height: Image height (pixels)
    width: Image width (pixels)
    num_images: Number of images to generate (maximum 4)
    cfg_scale: Image matching degree for the prompt (1-20)
    seed: Seed value for image generation
    open_browser: Whether to open the image in the browser after generation
    
Returns:
    Dict: Dictionary containing the file path of the generated image and the thumbnail image

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cfg_scaleNo
heightNo
negative_promptNo
num_imagesNo
open_browserNo
promptYes
seedNo
widthNo

Implementation Reference

  • The main handler function for the text_to_image tool, which generates images from text prompts using AWS Bedrock and handles validation, generation, and saving.
    async def text_to_image(
            prompt: str,
            negative_prompt: str = "",
            height: int = 1024,
            width: int = 1024,
            num_images: int = 1,
            cfg_scale: float = 8.0,
            seed: int = 0,
            open_browser: bool = True,
            output_path: str = None,
    ) -> Dict[str, Any]:
        """
        Generate an image from a text prompt. If a color palette is specified, use the color_guided_generation tool first.
        
        Args:
            prompt: Text prompt for generating an image (maximum 1024 characters)
            negative_prompt: Text prompt for excluding attributes from generation (maximum 1024 characters)
            height: Image height (pixels)
            width: Image width (pixels)
            num_images: Number of images to generate (maximum 4)
            cfg_scale: Image matching degree for the prompt (1-20)
            seed: Seed value for image generation
            open_browser: Whether to open the image in the browser after generation
            output_path: Absolute path to save the image
            
        Returns:
            Dict: Dictionary containing the file path of the generated image and the thumbnail image
        """
        try:
            # Validate prompt length
            if len(prompt) > 1024:
                raise ImageError("Prompt cannot exceed 1024 characters.")
            if len(negative_prompt) > 1024:
                raise ImageError("Negative prompt cannot exceed 1024 characters.")
    
            if num_images < 1 or num_images > 4:
                raise ImageError("num_images must be between 1 and 4.")
    
            body = json.dumps({
                "taskType": "TEXT_IMAGE",
                "textToImageParams": {
                    "text": prompt,
                    "negativeText": negative_prompt
                },
                "imageGenerationConfig": {
                    "numberOfImages": num_images,
                    "height": height,
                    "width": width,
                    "cfgScale": cfg_scale,
                    "seed": seed
                }
            })
    
            # Generate image
            image_bytes = generate_image(body)
    
            # Save image
            image_info = save_image(image_bytes, open_browser=open_browser, output_path=output_path)
    
            # Generate result
            result = {
                "image_path": image_info["image_path"],
                "message": f"Image generated successfully. Saved location: {image_info['image_path']}"
            }
    
            return result
    
        except Exception as e:
            raise McpError(f"Error occurred while generating image: {str(e)}")
  • Registration of the text_to_image tool with the FastMCP server instance.
    mcp.add_tool(text_to_image, 
                 "text_to_image", 
                 """Generate an image from a text prompt using aws nova canvas model. 
                 If a color palette is specified, use the color_guided_generation tool first.""")
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 the tool generates images and mentions the show_image follow-up, but lacks details about behavioral traits like rate limits, authentication needs, generation time, supported image formats, or what happens when limits are exceeded (e.g., maximum character counts). The description doesn't contradict any annotations since none exist.

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 appropriately sized. It starts with the core purpose, provides a usage tip, then details all parameters with clear explanations, and ends with return information. Every sentence adds value with no redundancy or fluff.

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 (8 parameters, no annotations, no output schema), the description does well by explaining all parameters and mentioning the return format. However, it could be more complete by addressing behavioral aspects like generation constraints, error conditions, or format details. The lack of output schema means the description should ideally explain return values more thoroughly.

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 schema description coverage is 0%, so the description must compensate fully. It successfully adds meaning for all 8 parameters beyond the schema's basic titles, providing character limits for prompts, pixel ranges for dimensions, numerical ranges for cfg_scale and num_images, and explanations for seed and open_browser. This significantly enhances understanding beyond the minimal 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 'Generate an image from a text prompt' which is a specific verb+resource combination. It distinguishes from sibling tools like background_removal, color_guided_generation, and image_variation by focusing on text-to-image generation rather than image manipulation or variation.

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

Usage Guidelines4/5

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

The description provides clear context by mentioning 'After generation, you can use the show_image tool to view the thumbnail,' which gives a next-step recommendation. However, it doesn't explicitly state when to use this tool versus alternatives like image_variation or color_guided_generation, nor does it provide exclusion criteria.

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

Related 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/yunwoong7/aws-nova-canvas-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server