Skip to main content
Glama
yunwoong7
by yunwoong7

inpainting

Edit specific areas of an image by applying text prompts to mask and inpaint designated regions, enabling targeted modifications while preserving image integrity.

Instructions

Inpaint a specific part of an image using a text mask prompt.

Args:
    image_path: File path of the original image
    prompt: Text prompt for the area to be inpainted
    mask_prompt: Text prompt for specifying the area to be masked (e.g., "window", "car")
    negative_prompt: Text prompt for excluding attributes from generation
    height: Output image height (pixels)
    width: Output image width (pixels)
    cfg_scale: Image matching degree for the prompt (1-20)
    open_browser: Whether to open the image in the browser after generation
    
Returns:
    Dict: Dictionary containing the file path of the inpainted image

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cfg_scaleNo
heightNo
image_pathYes
mask_promptYes
negative_promptNo
open_browserNo
promptYes
widthNo

Implementation Reference

  • The main handler function for the 'inpainting' tool. It reads the input image, encodes it to base64, constructs a JSON payload with inpainting parameters for the Bedrock model, generates the image, saves it using image_storage utilities, and returns the saved image path.
    async def inpainting(
            image_path: str,
            prompt: str,
            mask_prompt: str,
            negative_prompt: str = "",
            height: int = 512,
            width: int = 512,
            cfg_scale: float = 8.0,
            open_browser: bool = True,
            output_path: str = None,
    ) -> Dict[str, Any]:
        """
        Inpaint a specific part of an image using a text mask prompt.
        
        Args:
            image_path: File path of the original image
            prompt: Text prompt for the area to be inpainted
            mask_prompt: Text prompt for specifying the area to be masked (e.g., "window", "car")
            negative_prompt: Text prompt for excluding attributes from generation
            height: Output image height (pixels)
            width: Output image width (pixels)
            cfg_scale: Image matching degree for the prompt (1-20)
            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 inpainted image
        """
        try:
            # Read image file and encode to base64
            with open(image_path, "rb") as image_file:
                input_image = base64.b64encode(image_file.read()).decode('utf8')
    
            body = json.dumps({
                "taskType": "INPAINTING",
                "inPaintingParams": {
                    "text": prompt,
                    "negativeText": negative_prompt,
                    "image": input_image,
                    "maskPrompt": mask_prompt
                },
                "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, open_browser=open_browser, output_path=output_path)
    
            # Generate result
            result = {
                "image_path": image_info["image_path"],
                "message": f"Inpainting completed successfully. Saved location: {image_info['image_path']}"
            }
    
            return result
    
        except Exception as e:
            raise McpError(f"Error occurred while inpainting: {str(e)}")
  • Location where the inpainting tool is imported and registered with the MCP server (registration is currently commented out).
    # mcp.add_tool(inpainting)
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. It mentions the 'open_browser' behavior which is useful, but fails to describe important aspects like whether this is a read-only or destructive operation, what permissions are needed, whether it modifies the original file, rate limits, or error conditions. For an 8-parameter image manipulation tool, this leaves significant gaps.

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 statement, Args, Returns) and front-loads the core functionality. Most sentences earn their place, though the Returns section could be slightly more detailed given there's no output schema. The formatting with bullet-like sections enhances readability.

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 an 8-parameter image manipulation tool with no annotations and no output schema, the description provides adequate but incomplete coverage. The parameter explanations are strong, but missing behavioral context (permissions, side effects) and the return value description is minimal ('Dict: Dictionary containing the file path'). Given the complexity, more detail on output structure and behavioral implications would be beneficial.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates well by providing clear explanations for all 8 parameters in the Args section. Each parameter gets a brief but meaningful description that adds value beyond the schema's titles (e.g., explaining 'cfg_scale' as 'Image matching degree for the prompt (1-20)' and giving examples for 'mask_prompt'). The only minor gap is that 'image_path' could specify expected formats.

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 the tool's purpose with specific verbs ('inpaint a specific part of an image') and resources ('image', 'text mask prompt'), distinguishing it from siblings like 'background_removal' or 'outpainting' which involve different image manipulation operations. The opening sentence provides a concise yet complete statement of function.

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 like 'outpainting' or 'image_variation', nor does it mention any prerequisites or constraints. While the purpose is clear, there's no context about appropriate use cases or comparisons with sibling 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