Skip to main content
Glama
ilhankilic

YaparAI MCP Server

by ilhankilic

remove_background

Remove the background from an image using AI. Upload an image and receive a version with the background removed, ideal for product photos and portraits.

Instructions

Remove the background from an image using AI.

Upload an image and get back a version with the background removed. Works great for product photos, portraits, and any image where you need a clean cutout. Cost: ~2 credits.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
image_urlYesURL of the image to process
output_formatNoBackground replacement — "transparent" (PNG with alpha) or "white" (white background)transparent

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function that implements the 'remove_background' tool logic. It calls YaparAIClient.generate() with mode 'editor_bg_remove', passes image_url and output_format, then waits for the result and returns the processed image URL.
    async def remove_background(
        image_url: str,
        output_format: Literal["transparent", "white"] = "transparent",
    ) -> dict:
        """
        Remove the background from an image using AI.
    
        Upload an image and get back a version with the background removed.
        Works great for product photos, portraits, and any image where you
        need a clean cutout.
        Cost: ~2 credits.
    
        Args:
            image_url: URL of the image to process
            output_format: Background replacement — "transparent" (PNG with alpha)
                           or "white" (white background)
    
        Returns:
            Dict with image_url (processed image), job_id, credits_used,
            and balance_remaining.
        """
        client = YaparAIClient()
        job = await client.generate({
            "type": "image",
            "mode": "editor_bg_remove",
            "image_url": image_url,
            "output_format": output_format,
        })
    
        result = await client.wait_for_result(job["job_id"], timeout=60)
        return {
            "status": "success",
            "image_url": result.get("result_url"),
            "job_id": result.get("job_id"),
            "credits_used": job.get("credits_used"),
            "balance_remaining": job.get("balance_remaining"),
        }
  • Input schema for remove_background: expects image_url (str) and optional output_format limited to 'transparent' or 'white' literal types.
    async def remove_background(
        image_url: str,
        output_format: Literal["transparent", "white"] = "transparent",
  • Registration of remove_background as an MCP tool via mcp.tool(remove_background) on line 130 of the server.
    mcp.tool(remove_background)
  • Import statement for remove_background from yaparai.tools.edit in the server module.
    from yaparai.tools.edit import (
        transform_image,
        remove_background,
        swap_face,
    )
  • The YaparAIClient.generate() helper used by remove_background to start the background removal job, plus wait_for_result() to poll for completion.
    async def generate(self, request: dict) -> dict:
        """Start a generation job."""
        return await self._request("POST", "/v1/public/generate", json=request)
    
    async def get_job(self, job_id: str) -> dict:
        """Get job status and result."""
        return await self._request("GET", f"/v1/public/jobs/{job_id}")
    
    async def get_balance(self) -> dict:
        """Get credit balance."""
        return await self._request("GET", "/v1/public/balance")
    
    async def get_models(self) -> dict:
        """List available models and their credit costs."""
        return await self._request("GET", "/v1/public/models")
    
    async def wait_for_result(
        self,
        job_id: str,
        timeout: int = 120,
        poll_interval: int = 3,
    ) -> dict:
        """Poll job status until completed or timeout."""
        elapsed = 0
        while elapsed < timeout:
            job = await self.get_job(job_id)
            status = job.get("status", "")
            if status == "succeeded":
                return job
            if status == "failed":
                error = job.get("error_message") or job.get("error") or "Unknown error"
                raise RuntimeError(f"Generation failed: {error}")
            await asyncio.sleep(poll_interval)
            elapsed += poll_interval
        raise TimeoutError(
            f"Job {job_id} is still processing after {timeout}s. "
            f"Use get_job_status('{job_id}') to check later."
        )
Behavior3/5

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

No annotations provided, so description carries full burden. It mentions cost (~2 credits) and outcome, but does not disclose error conditions, size limits, or rate limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Description is concise with 4 lines, front-loads the core purpose, and includes relevant use cases and cost without extraneous text.

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

Completeness4/5

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

Has output schema. Covers purpose, use cases, and cost adequately for a simple tool, though missing details on image format/max size.

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?

Schema coverage is 100%, so baseline 3. Description adds no extra parameter meaning beyond what the schema already describes (format options).

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 states 'Remove the background from an image using AI' with specific examples like product photos and portraits, clearly differentiating it from sibling tools such as swap_face or transform_image.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for cutouts ('Works great for product photos, portraits...') but lacks explicit guidance on when not to use or comparisons to alternatives among many image-related siblings.

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

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/ilhankilic/yaparai-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server