Skip to main content
Glama
yunwoong7
by yunwoong7

image_variation

Create variations of input images while preserving core content. Adjust parameters like similarity strength, dimensions, and prompts to customize output. Ideal for generating creative edits or adapting visuals.

Instructions

Generate a new variation of the input image while maintaining its content.

Args:
    image_paths: List of file paths of the original images (1-5)
    prompt: Text for generating a variation image (optional)
    negative_prompt: Text specifying attributes to exclude from generation
    similarity_strength: Similarity between the original image and the generated image (0.2-1.0)
    height: Output image height (pixels)
    width: Output image width (pixels)
    cfg_scale: Prompt matching degree (1-20)
    
Returns:
    Dict: Dictionary containing the file path of the variation image

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cfg_scaleNo
heightNo
image_pathsYes
negative_promptNo
promptNo
similarity_strengthNo
widthNo

Implementation Reference

  • The main handler function for the 'image_variation' tool. It validates inputs, encodes images to base64, constructs a JSON payload for the Bedrock 'generate_image' call with taskType 'IMAGE_VARIATION', generates the image, saves it, and returns the path.
    async def image_variation(
            image_paths: List[str],
            prompt: str = "",
            negative_prompt: str = "",
            similarity_strength: float = 0.7,
            height: int = 512,
            width: int = 512,
            cfg_scale: float = 8.0,
            output_path: str = None,
    ) -> Dict[str, Any]:
        """
        Generate a new variation of the input image while maintaining its content.
        
        Args:
            image_paths: List of file paths of the original images (1-5)
            prompt: Text for generating a variation image (optional)
            negative_prompt: Text specifying attributes to exclude from generation
            similarity_strength: Similarity between the original image and the generated image (0.2-1.0)
            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
            
        Returns:
            Dict: Dictionary containing the file path of the variation image
        """
        try:
            # Validate image paths
            if len(image_paths) < 1 or len(image_paths) > 5:
                raise ImageError("image_paths list must contain 1-5 images.")
    
            if similarity_strength < 0.2 or similarity_strength > 1.0:
                raise ImageError("similarity_strength must be between 0.2 and 1.0.")
    
            # Read image files and encode to base64
            encoded_images = []
            for img_path in image_paths:
                with open(img_path, "rb") as image_file:
                    encoded_images.append(base64.b64encode(image_file.read()).decode('utf8'))
    
            body = json.dumps({
                "taskType": "IMAGE_VARIATION",
                "imageVariationParams": {
                    "text": prompt,
                    "negativeText": negative_prompt,
                    "images": encoded_images,
                    "similarityStrength": similarity_strength,
                },
                "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 variation completed successfully. Saved location: {image_info['image_path']}"
            }
    
            return result
    
        except Exception as e:
            raise McpError(f"Error occurred while image variation: {str(e)}")
  • The registration of the image_variation tool with the MCP server (currently commented out). The tool is imported earlier at line 10.
    # mcp.add_tool(image_variation)
  • Import of the image_variation handler function in the server file.
    from .tools.image_variation import image_variation
  • Function signature providing the input schema via type hints and defaults, used by MCP for tool schema.
    async def image_variation(
            image_paths: List[str],
            prompt: str = "",
            negative_prompt: str = "",
            similarity_strength: float = 0.7,
            height: int = 512,
            width: int = 512,
            cfg_scale: float = 8.0,
            output_path: str = None,
    ) -> Dict[str, Any]:
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions the tool 'generates' variations, implying creation/mutation, but doesn't disclose behavioral traits like whether it overwrites files, requires specific permissions, has rate limits, or what happens with invalid inputs. The description adds minimal behavioral context beyond the basic action.

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 clear sections (purpose, Args, Returns) and uses bullet-like formatting. Every sentence earns its place, though the parameter explanations could be slightly more concise. The front-loaded purpose statement is effective.

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 mutation tool with no annotations and no output schema, the description provides good parameter semantics but lacks crucial behavioral context. It doesn't explain the return value format beyond 'Dictionary containing the file path', nor does it cover error conditions, side effects, or usage constraints relative to siblings.

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?

With 0% schema description coverage, the description fully compensates by providing clear semantic explanations for all 7 parameters. Each parameter gets a brief but meaningful description that adds value beyond the schema's titles (e.g., 'Similarity between the original image and the generated image' for similarity_strength, 'Prompt matching degree' for cfg_scale).

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 the tool's purpose: 'Generate a new variation of the input image while maintaining its content.' This specifies the verb ('generate'), resource ('variation of the input image'), and key constraint ('maintaining its content'). However, it doesn't explicitly differentiate from sibling tools like 'inpainting' or 'outpainting' which also modify images.

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. With siblings like 'text_to_image', 'inpainting', and 'outpainting' available, there's no indication of when image variation is preferred over these other image generation or modification 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

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