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
| Name | Required | Description | Default |
|---|---|---|---|
| target_image_url | Yes | URL or local path to the target photo (receives the new face) | |
| source_face_url | Yes | URL or local path to the source face image | |
| name | No | Optional name for the project |
Implementation Reference
- src/index.ts:173-210 (handler)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"), },