Skip to main content
Glama
yunwoong7
by yunwoong7

outpainting

Extend images by generating outpainting content using text prompts and masks. Define output dimensions, control generation precision, and exclude unwanted attributes for tailored visual expansions.

Instructions

Expand the image to create an outpainting.

Args:
    image_path: File path of the original image
    mask_image_path: File path of the mask image
    prompt: Text describing the content to be generated in the outpainting area
    negative_prompt: Text specifying attributes to exclude from generation
    outpainting_mode: Outpainting mode (DEFAULT or PRECISE)
    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 outpainted image

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cfg_scaleNo
heightNo
image_pathYes
mask_image_pathYes
negative_promptNo
outpainting_modeNoDEFAULT
promptYes
widthNo

Implementation Reference

  • The main handler function for the 'outpainting' tool. It validates inputs, encodes images to base64, constructs a JSON payload for the Bedrock API (taskType: OUTPAINTING), calls generate_image, saves the result, and returns the image path.
    async def outpainting(
            image_path: str,
            mask_image_path: str,
            prompt: str,
            negative_prompt: str = "",
            outpainting_mode: str = "DEFAULT",
            height: int = 512,
            width: int = 512,
            cfg_scale: float = 8.0,
            output_path: str = None,
    ) -> Dict[str, Any]:
        """
        Expand the image to create an outpainting.
        
        Args:
            image_path: File path of the original image
            mask_image_path: File path of the mask image
            prompt: Text describing the content to be generated in the outpainting area
            negative_prompt: Text specifying attributes to exclude from generation
            outpainting_mode: Outpainting mode (DEFAULT or PRECISE)
            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 outpainted image
        """
        try:
            # Validate outpainting mode
            if outpainting_mode not in ["DEFAULT", "PRECISE"]:
                raise ImageError("outpainting_mode must be 'DEFAULT' or 'PRECISE'.")
    
            # Read image file and encode to base64
            with open(image_path, "rb") as image_file:
                input_image = base64.b64encode(image_file.read()).decode('utf8')
    
            with open(mask_image_path, "rb") as mask_file:
                input_mask_image = base64.b64encode(mask_file.read()).decode('utf8')
    
            body = json.dumps({
                "taskType": "OUTPAINTING",
                "outPaintingParams": {
                    "text": prompt,
                    "negativeText": negative_prompt,
                    "image": input_image,
                    "maskImage": input_mask_image,
                    "outPaintingMode": outpainting_mode
                },
                "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"Outpainting completed successfully. Saved location: {image_info['image_path']}"
            }
    
            return result
    
        except Exception as e:
            raise McpError(f"Error occurred while outpainting: {str(e)}")
  • Registration of the outpainting tool in the MCP server (currently commented out).
    # mcp.add_tool(outpainting)
  • Import of the outpainting handler function into the server module.
    from .tools.outpainting import outpainting
  • Input validation for the outpainting_mode parameter, enforcing 'DEFAULT' or 'PRECISE'.
    # Validate outpainting mode
    if outpainting_mode not in ["DEFAULT", "PRECISE"]:
        raise ImageError("outpainting_mode must be 'DEFAULT' or 'PRECISE'.")
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While it implies a generative/mutation operation ('expand', 'create'), it doesn't disclose important behavioral traits: whether this is a destructive operation, what permissions are needed, whether there are rate limits, what happens if generation fails, or what the typical processing time might be. The description adds minimal behavioral context beyond the basic operation.

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. It begins with a clear purpose statement, then provides organized parameter documentation in bullet-like format. Every sentence earns its place by either stating the purpose or explaining parameters. It could be slightly more concise by combining some parameter explanations, but overall it's efficient.

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?

Given the tool's complexity (8 parameters, generative operation) and lack of both annotations and output schema, the description is moderately complete. It thoroughly documents parameters but lacks behavioral context and output details. The return value is minimally described ('Dictionary containing the file path'), but without an output schema, more detail about the response structure would be helpful for a complex tool like this.

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 detailed parameter documentation. It explains all 8 parameters with clear semantic meaning beyond just their names: 'File path of the original image', 'Text describing the content to be generated', 'Prompt matching degree (1-20)', etc. This adds significant value over the bare schema.

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: 'Expand the image to create an outpainting.' This specifies the verb ('expand') and resource ('image'), and distinguishes it from sibling tools like 'inpainting' (which modifies existing areas) or 'text_to_image' (which creates from scratch). However, it doesn't explicitly contrast with all siblings, such as 'image_variation'.

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 when outpainting is appropriate compared to inpainting, image_variation, or other image manipulation tools. There are no usage prerequisites, exclusions, or named alternatives provided.

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