Skip to main content
Glama
ilhankilic

YaparAI MCP Server

by ilhankilic

swap_face

Replace a face in any image with a face from another image using AI. Provide target and source image URLs to perform the swap while preserving the background.

Instructions

Swap a face in an image using AI.

Provide a target image and a source face image. The AI replaces the face in the target image with the face from the source image while keeping the rest of the image intact. Cost: ~6 credits.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
image_urlYesTarget image URL (the image where the face will be replaced)
face_urlYesSource face image URL (the face to use for swapping)
promptNoOptional additional instructions for the face swap

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function `swap_face` that executes the face swap tool. It accepts image_url, face_url, and optional prompt, sends a request to the AI API with mode 'editor_face_swap', waits for the result, and returns the result URL along with job metadata.
    async def swap_face(
        image_url: str,
        face_url: str,
        prompt: str = "",
    ) -> dict:
        """
        Swap a face in an image using AI.
    
        Provide a target image and a source face image. The AI replaces the
        face in the target image with the face from the source image while
        keeping the rest of the image intact.
        Cost: ~6 credits.
    
        Args:
            image_url: Target image URL (the image where the face will be replaced)
            face_url: Source face image URL (the face to use for swapping)
            prompt: Optional additional instructions for the face swap
    
        Returns:
            Dict with image_url (result image), job_id, credits_used,
            and balance_remaining.
        """
        client = YaparAIClient()
        job = await client.generate({
            "type": "image",
            "mode": "editor_face_swap",
            "prompt": prompt,
            "image_url": image_url,
            "face_url": face_url,
        })
    
        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"),
        }
  • Registration of swap_face as an MCP tool via `mcp.tool(swap_face)`. This makes the face swap function available as an MCP tool in the server.
    mcp.tool(swap_face)
  • Import of swap_face from yaparai.tools.edit into the server module, enabling its registration as an MCP tool.
    from yaparai.tools.edit import (
        transform_image,
        remove_background,
        swap_face,
    )
  • Function signature and docstring define the input schema: image_url (str, required), face_url (str, required), prompt (str, optional, default ''). Return dict schema includes status, image_url, job_id, credits_used, balance_remaining.
    async def swap_face(
        image_url: str,
        face_url: str,
        prompt: str = "",
    ) -> dict:
  • The YaparAIClient import that swap_face depends on for making API calls. Used to create a client instance that handles API communication.
    from yaparai.client import YaparAIClient
Behavior3/5

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

With no annotations provided, the description carries the full burden but only mentions the cost (~6 credits) and the fact that the rest of the image stays intact. It does not disclose potential failure modes, image format requirements, or whether the operation is safe (non-destructive). Annotations would help, but the description provides minimal behavioral context.

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?

The description is concise (four sentences) and front-loaded with the core purpose. Every sentence contributes value: operation summary, required inputs, behavior promise, and cost. No redundant or filler content.

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?

The description adequately explains the tool's operation and mentions cost, but omits details like expected output format (though an output schema exists), image size limits, or prerequisite access. It is sufficient for basic use but could be more complete for edge cases.

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 description coverage is 100%, so each parameter already has a clear description. The tool description adds no extra information about parameters beyond the schema (only a cost note). Hence, it meets the baseline but does not exceed it.

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 swaps a face in an image using AI, specifying the target and source images. It distinguishes itself from siblings like 'remove_background' and 'virtual_try_on' by focusing on face replacement, making the purpose unmistakable.

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 explains the tool's function but does not provide explicit guidance on when to use it versus alternatives such as 'virtual_try_on' or 'transform_image'. It implies usage for face swapping but lacks exclusions or context for choosing other 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

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