Skip to main content
Glama

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]:

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