Skip to main content
Glama

face_swap_photo

Swap faces between photos by providing a target photo and source face image. This tool enables face replacement in images for creative or practical applications.

Instructions

Swap a face onto a photo. Provide a target photo and a source face image.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
target_image_urlYesURL or local path to the target photo (receives the new face)
source_face_urlYesURL or local path to the source face image
nameNoOptional name for the project

Implementation Reference

  • Handler function that executes the face_swap_photo tool - calls the Magic Hour API to create a face swap photo job with the target and source images, returns the project ID and status.
    async ({ target_image_url, source_face_url, name }) => {
      try {
        const result = await client.v1.faceSwapPhoto.create({
          assets: {
            targetFilePath: target_image_url,
            faceSwapMode: "all-faces",
            sourceFilePath: source_face_url,
          },
          name: name,
        });
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(
                {
                  id: result.id,
                  credits_charged: result.creditsCharged,
                  status: "queued",
                  message:
                    "Face swap photo job submitted. Use get_image_project_status to check progress.",
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            { type: "text" as const, text: `Error: ${error.message}` },
          ],
          isError: true,
        };
      }
    }
  • src/index.ts:158-172 (registration)
    Tool registration with name 'face_swap_photo', description, and input schema using zod validation for target_image_url, source_face_url, and optional name.
    server.tool(
      "face_swap_photo",
      "Swap a face onto a photo. Provide a target photo and a source face image.",
      {
        target_image_url: z
          .string()
          .describe("URL or local path to the target photo (receives the new face)"),
        source_face_url: z
          .string()
          .describe("URL or local path to the source face image"),
        name: z
          .string()
          .optional()
          .describe("Optional name for the project"),
      },

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/andrianthan/magic-hour-mcp'

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