Skip to main content
Glama
yunwoong7
by yunwoong7

color_guided_generation

Create custom images using a specified color palette and text prompts with the AWS Nova Canvas MCP Server. Adjust dimensions, exclude unwanted attributes, and optionally reference an image for precise visual output.

Instructions

Generate an image using a specified color palette.

Args:
    prompt: Text describing the image to be generated
    colors: List of color codes (1-10 hex color codes, e.g., "#ff8080")
    reference_image_path: File path of the reference image (optional)
    negative_prompt: Text specifying attributes to exclude from generation
    height: Output image height (pixels)
    width: Output image width (pixels)
    cfg_scale: Prompt matching degree (1-20)
    ctx: MCP context
    
Returns:
    Dict: Dictionary containing the file path of the generated image

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cfg_scaleNo
colorsYes
heightNo
negative_promptNo
promptYes
reference_image_pathNo
widthNo

Implementation Reference

  • The core handler function implementing the color_guided_generation tool. It validates inputs, prepares the request body for COLOR_GUIDED_GENERATION task type, generates the image using Bedrock, saves it, and returns the image path.
    async def color_guided_generation(
            prompt: str,
            colors: List[str],
            reference_image_path: Optional[str] = None,
            negative_prompt: str = "",
            height: int = 512,
            width: int = 512,
            cfg_scale: float = 8.0,
            output_path: str = None,
            ctx: Context = None,
    ) -> Dict[str, Any]:
        """
        Generate an image using a specified color palette.
        
        Args:
            prompt: Text describing the image to be generated
            colors: List of color codes (1-10 hex color codes, e.g., "#ff8080")
            reference_image_path: File path of the reference image (optional)
            negative_prompt: Text specifying attributes to exclude from generation
            height: Output image height (pixels)
            width: Output image width (pixels)
            cfg_scale: Prompt matching degree (1-20)
            output_path: Absolute path to save the image
            ctx: MCP context
            
        Returns:
            Dict: Dictionary containing the file path of the generated image
        """
        try:
            # Validate color list
            if len(colors) < 1 or len(colors) > 10:
                raise ImageError("colors list must contain 1-10 color codes.")
    
            # Validate color codes
            for color in colors:
                if not color.startswith("#") or len(color) != 7:
                    raise ImageError(f"Invalid color code: {color}. Hex color codes must be in the format '#rrggbb'.")
    
            params = {
                "text": prompt,
                "negativeText": negative_prompt,
                "colors": colors
            }
    
            # If reference image exists, add it
            if reference_image_path:
                with open(reference_image_path, "rb") as image_file:
                    input_image = base64.b64encode(image_file.read()).decode('utf8')
                    params["referenceImage"] = input_image
    
            body = json.dumps({
                "taskType": "COLOR_GUIDED_GENERATION",
                "colorGuidedGenerationParams": params,
                "imageGenerationConfig": {
                    "numberOfImages": 1,
                    "height": height,
                    "width": width,
                    "cfgScale": cfg_scale
                }
            })
    
            # Generate image
            image_bytes = generate_image(body)
    
            # Save image
            image_info = save_image(image_bytes, output_path=output_path)
    
            # Generate result
            result = {
                "image_path": image_info["image_path"],
                "message": f"Image generated successfully using color palette. Saved location: {image_info['image_path']}"
            }
    
            return result
    
        except Exception as e:
            raise McpError(f"Error occurred while generating image using color palette: {str(e)}")
  • Registers the color_guided_generation tool with the FastMCP server instance.
    mcp.add_tool(color_guided_generation)
  • Imports the color_guided_generation handler function for registration.
    from .tools.color_guided_generation import color_guided_generation
  • Function signature defining the input schema/parameters for the tool, including prompt, colors list, dimensions, etc., and output as dict with image_path.
    async def color_guided_generation(
            prompt: str,
            colors: List[str],
            reference_image_path: Optional[str] = None,
            negative_prompt: str = "",
            height: int = 512,
            width: int = 512,
            cfg_scale: float = 8.0,
            output_path: str = None,
            ctx: Context = None,
    ) -> Dict[str, Any]:
Behavior2/5

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

With no annotations provided, the description carries full burden but provides minimal behavioral context. It mentions the tool generates images but doesn't disclose computational requirements, quality expectations, generation time, rate limits, or authentication needs. The return format is mentioned but without details about error conditions or file format.

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 with a clear purpose statement followed by organized parameter explanations. Every sentence adds value, though the 'ctx: MCP context' parameter explanation is minimal. The structure helps an agent understand the tool's interface efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 7-parameter image generation tool with no annotations and no output schema, the description provides good parameter coverage but lacks important behavioral context. It doesn't explain what happens when generation fails, file format of outputs, or performance characteristics. The return statement is minimal ('Dict containing file path') without error handling details.

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 provides excellent parameter semantics despite 0% schema description coverage. It explains each parameter's purpose clearly: 'prompt' describes the image, 'colors' specifies hex codes with quantity guidance, 'reference_image_path' is optional, 'negative_prompt' excludes attributes, 'height/width' are pixel dimensions, and 'cfg_scale' controls prompt matching degree. 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.

Purpose4/5

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

The description clearly states 'Generate an image using a specified color palette' which is a specific verb+resource combination. It distinguishes from siblings like 'text_to_image' by emphasizing color guidance, but doesn't explicitly contrast with other image generation siblings like 'image_variation' or 'inpainting'.

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 on when to use this tool versus alternatives like 'text_to_image' or 'image_variation' is provided. The description only states what the tool does, not when it's appropriate versus other image generation methods available in the sibling tool list.

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