Skip to main content
Glama
yunwoong7
by yunwoong7

background_removal

Remove image backgrounds automatically to isolate subjects. Input an image path and receive a cleaned image file, enhancing focus on the main content for editing or design purposes.

Instructions

Remove the background of an image automatically.

Args:
    image_path: File path of the original image
    ctx: MCP context
    
Returns:
    Dict: Dictionary containing the file path of the image with the background removed

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
image_pathYes

Implementation Reference

  • The handler function that implements the background removal logic: reads input image, encodes to base64, sends to Bedrock API with BACKGROUND_REMOVAL task, saves output image, returns path and message.
    async def background_removal(
            image_path: str,
            output_path: str = None,
            ctx: Context = None,
    ) -> Dict[str, Any]:
        """
        Remove the background of an image automatically.
        
        Args:
            image_path: File path of the original image, Please use the actual local file path where the image is stored.
            output_path: Absolute path to save the image
            ctx: MCP context
            
        Returns:
            Dict: Dictionary containing the file path of the image with the background removed
        """
        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": "BACKGROUND_REMOVAL",
                "backgroundRemovalParams": {
                    "image": input_image,
                }
            })
    
            # 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"Background removed successfully. Saved location: {image_info['image_path']}"
            }
    
            return result
    
        except Exception as e:
            raise McpError(f"Error occurred while removing background: {str(e)}")
  • Registers the background_removal tool with the FastMCP server instance.
    mcp.add_tool(background_removal)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While it states the tool 'automatically' removes backgrounds, it doesn't disclose important behavioral traits: what permissions or authentication might be needed, whether the operation is destructive to the original file, what formats are supported, whether there are rate limits, or what happens if the background removal fails. For a tool that modifies images, this represents significant gaps in behavioral transparency.

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 appropriately concise with three clear sections: purpose statement, parameters, and return value. Each sentence earns its place, though the 'ctx: MCP context' parameter documentation adds little value since it's not in the actual schema. The structure is front-loaded with the core purpose first, making it easy to understand quickly.

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

Completeness2/5

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

Given the tool's complexity (image processing with potential side effects), the complete lack of annotations, no output schema, and minimal parameter documentation, the description is insufficiently complete. It doesn't explain what 'automatically' means in practice, doesn't describe the return dictionary structure beyond mentioning it contains a file path, and provides no context about error conditions or limitations. For an image manipulation tool with behavioral implications, this represents significant incompleteness.

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

Parameters3/5

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

The description adds minimal parameter semantics beyond what the schema provides. It mentions 'image_path: File path of the original image' which slightly clarifies the schema's 'Image Path' title, but with 0% schema description coverage and only 1 parameter, the description doesn't provide format requirements, path conventions, or supported image types. The baseline for 0% coverage with 1 parameter would be higher if the description compensated more effectively.

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 with a specific verb ('Remove') and resource ('background of an image'), making it immediately understandable. It distinguishes itself from siblings like 'inpainting' or 'outpainting' by focusing specifically on background removal rather than general image editing. However, it doesn't explicitly differentiate from all siblings in the description text itself.

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 'inpainting' and 'outpainting' that might also involve background manipulation, there's no indication of when background_removal is the appropriate choice versus those other tools. The description lacks any 'when to use' or 'when not to use' context.

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