UNPKG

@kolbo/mcp

Version:

Kolbo AI MCP Server - Generate images, videos, music, speech, and sound effects from Claude Code

378 lines (350 loc) • 29.1 kB
/* ⛔ BACKWARD COMPATIBILITY: Tool names and arg names below are a PUBLIC * CONTRACT. Never rename, remove, or break an existing tool/arg — old cached * `npx @kolbo/mcp` installs in the wild will break silently. Add new tools or * new OPTIONAL args only. Full rules: ../index.js top-of-file and CLAUDE.md. */ // Avatars: a person (avatar_id) the user can make talk. Create once from photos + voice (+ an // optional talking video), then create_avatar_video with a script. Three modes, chosen by the // caller: omni (acts in any scene, up to 60 s), photo (fast, from a still in the scene, up to // 3 min), twin (the person's own footage, up to 3 min; needs a video). Engines are not exposed, // except two brand choices the caller makes: voice_engine and lipsync_model. // Contract: kolbo-api src/services/avatar/serialize.js (/v1/avatars). const { z } = require('zod'); const { UI, uiResult } = require('../apps'); const text = value => ({ content: [{ type: 'text', text: JSON.stringify(value, null, 2) }] }); const MODE = z.enum(['omni', 'photo', 'twin']); const urls = (min, max) => z.array(z.string().url()).min(min).max(max); const SHOT = z.enum(['close', 'podcast', 'full_body', 'walk', 'webcam', 'propped', 'selfie']); // Calling with the user's own key is the attestation (Zohar 2026-11-12): MCP never asks for consent. const CONSENT = true; const CONSENT_ARG = z.boolean().optional().describe('Not needed: sent automatically.'); // A voice from clone_voice / list_voices may come as a bare id; the avatar API takes custom_<id>. const voiceId = (v) => (typeof v === 'string' && /^[a-f0-9]{24}$/i.test(v) ? `custom_${v}` : v); const STOCK_VOICE = z.string().max(80).optional().describe('Instead of cloning: a library voice (list_avatar_stock_voices) or one of the user\'s own voices from clone_voice / list_voices (custom_<id>, or the bare id clone_voice returned).'); // HeyGen Avatar 6 (Photo mode only): the picture comes from the avatar's photo, a character clip, or a stock presenter. const HEYGEN = { look_source: z.enum(['photo', 'character', 'stock']).optional().describe('HeyGen Avatar 6 only (mode photo, lipsync_model from list_avatar_lipsync_models with mode heygen): photo = the avatar\'s own photo, character = an animated or illustrated character clip (character_video_url; real people are refused), stock = a stock presenter (stock_avatar). Character and stock bring their own picture: the avatar only lends its voice, or pass voice_id or audio_url.'), character_video_url: z.string().url().optional().describe('look_source character: https link to a clip of an animated or illustrated character (at least 2 s).'), character_image_url: z.string().url().optional().describe('look_source character: optional https still of the same character.'), stock_avatar: z.string().max(150).optional().describe('look_source stock: a look id (or exact name) from list_avatar_stock_presenters. The look sets the framing: vertical looks render 9:16, square 1:1, the rest 16:9 (aspect_ratio is ignored). With no voice_id or audio_url the presenter speaks in their own voice.'), voice_id: z.string().max(200).optional().describe('look_source character or stock: a library voice (list_avatar_stock_voices) to speak the script instead of the avatar\'s voice.'), }; const RESOLUTION = z.enum(['480p', '720p', '1080p', '2k', '4k']).optional().describe('2k is for HeyGen Avatar 6 only.'); const LOOK = z.string().max(40).optional().describe('An outfit from add_avatar_look (look_id). Omit for the clothes in the photos. Omni and Photo wear it; Twin changes its starting image to that outfit.'); const TWIN = { start_image_url: z.string().url().optional().describe('Twin only: the starting image (gives the face and framing). Omit and the best frame of the talking video is picked and cropped waist-up automatically: calm, sharp, facing the camera. An uploaded image must show one clear face; needs consent.'), motion_video_url: z.string().url().optional().describe('Twin only: a talking video of the same person to drive the motion, instead of the avatar\'s own video. Needs consent.'), start_edit: z.string().max(300).optional().describe('Twin only: a change to the starting image in words, a new outfit or place ("navy blazer", "in a podcast studio"). The face stays.'), consent: z.boolean().optional().describe('Twin only: true = the user confirms the uploaded start_image_url / motion_video_url show them, or a person who gave permission. Required when either is passed.'), }; function registerAvatarTools(server, client) { server.tool( 'list_avatars', 'List the user\'s avatars (people they can make talk). Each has avatar_id, name, modes (which of omni / photo / twin it can use now) and scenes. Use avatar_id with create_avatar_video.', {}, async () => { const r = await client.get('/v1/avatars?limit=100'); const avatars = r?.avatars || []; return uiResult(UI.mediaGrid, JSON.stringify({ avatars, count: avatars.length }, null, 2), { widget: 'media-grid', title: 'Avatars', items: avatars.map(a => ({ id: a.avatar_id, title: a.name, subtitle: Object.entries(a.modes || {}).filter(([, ok]) => ok).map(([m]) => m).join(' · ') || 'Needs photos and a voice', thumbnail: a.thumbnail_url, url: a.thumbnail_url, media_type: 'image', use_hint: 'Make {TITLE} say: "..." (avatar_id: {ID}).', })), total: avatars.length, has_more: false, }); } ); server.tool( 'get_avatar', 'Get one avatar: its photos (with a reason when a photo was rejected), voice, video, scenes and which modes it can use.', { avatar_id: z.string().min(1).max(64) }, async ({ avatar_id }) => text((await client.get(`/v1/avatars/${encodeURIComponent(avatar_id)}`))?.avatar) ); server.tool( 'create_avatar', 'Create an avatar of a real person. Needs: 1-8 clear photos (photo_urls; more angles give a closer likeness) and, for videos from a typed script, a voice — either voice_url (30-60 s of clean speech, cloned) or stock_voice_id (a library voice, or a voice the user already cloned with clone_voice). A video from a recording of theirs (audio_url) needs no voice. To animate one photo exactly as it is, use talking_photo instead. Optional video_url (60 s+ of the person talking to camera) unlocks twin mode. Or pass visual_dna_id to convert one of the user\'s own Visual DNAs (photos then optional). Upload local files first with upload_media / create_upload_ticket.', { name: z.string().min(1).max(60), consent: CONSENT_ARG, photo_urls: urls(1, 8).optional().describe('1-8 https photo URLs of the person: one face, sharp, face fully visible. A character sheet counts as one photo.'), voice_url: z.string().url().optional().describe('30-60 s of the person speaking, https.'), voice_engine: z.enum(['cartesia', 'elevenlabs']).optional().describe('Which engine clones voice_url. Default cartesia. elevenlabs adds emotion tags to scripts automatically and counts toward the plan voice limit.'), stock_voice_id: STOCK_VOICE, video_url: z.string().url().optional().describe('60 s+ of the person talking to camera; unlocks twin.'), visual_dna_id: z.string().max(64).optional().describe('Convert one of the user\'s own character Visual DNAs into an avatar: its images, sheet and voice are copied.'), }, async ({ visual_dna_id, stock_voice_id, ...rest }) => { const body = { ...rest, stock_voice_id: voiceId(stock_voice_id), consent: CONSENT }; const r = visual_dna_id ? await client.post('/v1/avatars/from-visual-dna', { ...body, visual_dna_id }) : await client.post('/v1/avatars', body); return text(r?.avatar || r); } ); server.tool( 'update_avatar', 'Change an avatar: rename it, add photos, replace the voice (clone voice_url, or stock_voice_id: a library voice or a voice the user cloned with clone_voice) or add/replace the talking video.', { avatar_id: z.string().min(1).max(64), name: z.string().min(1).max(60).optional(), consent: CONSENT_ARG, photo_urls: urls(1, 8).optional(), voice_url: z.string().url().optional(), voice_engine: z.enum(['cartesia', 'elevenlabs']).optional().describe('Which engine clones voice_url. Default cartesia. elevenlabs adds emotion tags to scripts automatically and counts toward the plan voice limit.'), stock_voice_id: STOCK_VOICE, video_url: z.string().url().optional(), }, async ({ avatar_id, name, photo_urls, voice_url, voice_engine, stock_voice_id, video_url }) => { const id = encodeURIComponent(avatar_id); let last; if (name) last = await client.put(`/v1/avatars/${id}`, { name }); const consent = CONSENT; if (photo_urls) last = await client.post(`/v1/avatars/${id}/photos`, { consent, photo_urls }); if (voice_url || stock_voice_id) last = await client.put(`/v1/avatars/${id}/voice`, { consent, voice_url, voice_engine, stock_voice_id: voiceId(stock_voice_id) }); if (video_url) last = await client.put(`/v1/avatars/${id}/video`, { consent, video_url }); return text(last?.avatar || last || { message: 'Nothing to change' }); } ); server.tool( 'delete_avatar', 'Delete an avatar. Videos already made stay in their projects.', { avatar_id: z.string().min(1).max(64) }, async ({ avatar_id }) => text(await client.delete(`/v1/avatars/${encodeURIComponent(avatar_id)}`)) ); server.tool( 'list_avatar_scene_presets', 'List the scene library (studio, podcast, office, stage, cafe, ...). Pass a preset_key to create_avatar_video, or add_avatar_scene to keep it on the avatar.', {}, async () => text((await client.get('/v1/avatars/scene-presets'))?.scene_presets) ); server.tool( 'add_avatar_scene', 'Add a scene to an avatar: a preset_key, or a custom scene from a room photo (photo_url), a description (prompt) and/or reference images. For a location Visual DNA, pass its image as photo_url. The avatar is placed in the scene the first time a video uses it.', { avatar_id: z.string().min(1).max(64), preset_key: z.string().max(40).optional(), name: z.string().max(60).optional(), prompt: z.string().max(600).optional(), photo_url: z.string().url().optional(), reference_urls: urls(1, 5).optional(), aspect_ratio: z.enum(['9:16', '16:9', '1:1']).optional(), }, async ({ avatar_id, ...body }) => text(await client.post(`/v1/avatars/${encodeURIComponent(avatar_id)}/scenes`, body)) ); // Kept for old installs (tool names are a public contract). kolbo-api dropped the AI portrait step on // 2026-11-08 (avatars now build from the real photos) and removed the /portraits routes, so these 404'd. const noPortraits = { ok: true, changed: false, note: 'Avatars no longer use AI portrait options: every scene image and video builds from the real photos of the avatar. Nothing to regenerate or pick. To change the likeness, add or replace photos with update_avatar.' }; server.tool( 'regenerate_avatar_portraits', 'Retired: avatars now build from their real photos, so there are no portrait options to regenerate. Returns a notice and changes nothing.', { avatar_id: z.string().min(1).max(64) }, async () => text(noPortraits) ); server.tool( 'pick_avatar_portrait', 'Retired: avatars now build from their real photos, so there is no portrait to pick. Returns a notice and changes nothing.', { avatar_id: z.string().min(1).max(64), url: z.string().url() }, async () => text(noPortraits) ); server.tool( 'add_avatar_look', 'Give an avatar another outfit (a "look"): describe it (prompt), show it (reference_urls: up to 3 images of the clothes), or pass neither for a surprise outfit. Makes the look sheet now (up to a minute, a paid image) and returns look_id with image_url: show it to the user. Not happy: call again with look_id to remake that look (tries_left). Use look_id with preview_avatar_scene, quote_avatar_video and create_avatar_video (Omni and Photo).', { avatar_id: z.string().min(1).max(64), prompt: z.string().max(600).optional(), reference_urls: urls(1, 3).optional(), name: z.string().max(60).optional(), look_id: z.string().max(40).optional().describe('Remake this existing look instead of adding a new one.'), }, async ({ avatar_id, look_id, ...body }) => { const id = encodeURIComponent(avatar_id); const r = look_id ? await client.post(`/v1/avatars/${id}/looks/${encodeURIComponent(look_id)}/again`, {}) : await client.post(`/v1/avatars/${id}/looks`, body); return text(r?.look || r); } ); server.tool( 'remove_avatar_look', 'Delete an outfit (look) from an avatar. Refused while a video with that look is still being made.', { avatar_id: z.string().min(1).max(64), look_id: z.string().min(1).max(40) }, async ({ avatar_id, look_id }) => text((await client.delete(`/v1/avatars/${encodeURIComponent(avatar_id)}/looks/${encodeURIComponent(look_id)}`))?.avatar) ); server.tool( 'remove_avatar_scene', 'Remove a scene from an avatar. Videos already made keep their scene.', { avatar_id: z.string().min(1).max(64), scene_id: z.string().min(1).max(40) }, async ({ avatar_id, scene_id }) => text(await client.delete(`/v1/avatars/${encodeURIComponent(avatar_id)}/scenes/${encodeURIComponent(scene_id)}`)) ); server.tool( 'list_avatar_stock_voices', 'Library voices an avatar can use instead of a cloned voice. Pass a voice_id as stock_voice_id to create_avatar or update_avatar.', {}, async () => text((await client.get('/v1/avatars/stock-voices'))?.voices) ); server.tool( 'preview_avatar_speech', 'OPTIONAL: hear a script in the avatar\'s voice before making a video (costs a few credits per take; quote_avatar_video returns listen_credits). Skip it to generate straight away: create_avatar_video with only the script voices it itself. Returns speech_url and its seconds: pass speech_url with the same script to quote_avatar_video and create_avatar_video so the video speaks exactly this take. Changing the words or the voice needs a new preview.', { avatar_id: z.string().min(1).max(64), mode: MODE, script: z.string().min(1).max(6000), shot: z.enum(['close', 'podcast', 'full_body', 'walk', 'webcam', 'propped', 'selfie', 'founder']).optional(), language: z.string().max(10).optional(), }, async ({ avatar_id, ...body }) => text(await client.post(`/v1/avatars/${encodeURIComponent(avatar_id)}/speech`, body)) ); server.tool( 'list_avatar_lipsync_models', 'Models that can move the lips in a Photo avatar video (from the photo) or a Twin avatar video (from the footage), with credits per second and the longest clip each takes. Pass an id as lipsync_model on quote_avatar_video and create_avatar_video with the same mode. The default suits most videos.', { mode: z.enum(['photo', 'twin', 'heygen']).optional().describe('photo (default) lists image lipsync models, twin lists video lipsync models, heygen lists HeyGen Avatar 6 Turbo and Pro per look_source (heygen_mode).') }, async ({ mode }) => text(await client.get('/v1/avatars/lipsync-models' + (mode ? `?mode=${encodeURIComponent(mode)}` : ''))) ); server.tool( 'list_avatar_stock_presenters', 'Ready-made presenters for HeyGen Avatar 6 (create_avatar_video with mode photo, look_source stock, stock_avatar = a look id). About 1,200 people with about 9,000 looks. Without arguments: the people (person, group, looks, vertical_looks, best_motion), best_motion first: filmed presenters move most naturally, photo-based ones less. Prefer best_motion people unless the user asks for someone else. With group: all looks of that person. With search: looks whose person or look name has all the words (up to 60). Each look has id, name, orientation (portrait = renders 9:16), gender, filmed (natural motion) and a preview clip; lipsync_tool true means generate_lipsync also accepts its name.', { search: z.string().max(80).optional().describe('Words that must all appear in the person or look name, e.g. "abigail office".'), group: z.string().max(64).optional().describe('The group of a person from the list without arguments: returns all of their looks.'), vertical: z.boolean().optional().describe('Only vertical (9:16) looks, or people who have one.'), }, async ({ search, group, vertical }) => { const qs = group ? `?group=${encodeURIComponent(group)}` : search ? `?q=${encodeURIComponent(search)}` : ''; const r = (await client.get(`/v1/avatars/presenters${qs}`)) || {}; if (qs) { const looks = (r.presenters || []).filter(l => !vertical || l.orientation === 'portrait') .map(({ id, name, person, group: g, orientation, gender, preview, type, fal }) => ({ id, name, person, group: g, orientation, gender, preview, filmed: type === 'studio_avatar' || type === 'digital_twin', lipsync_tool: !!fal })); return text({ presenters: looks, count: looks.length }); } const people = (r.people || []).filter(p => !vertical || p.portrait > 0) .map(({ person, group: g, gender, looks, portrait, featured }) => ({ person, group: g, gender, looks, vertical_looks: portrait, best_motion: !!featured })); return text({ people: people.slice(0, 300), count: people.length, note: people.length > 300 ? 'First 300 people; narrow with search or vertical.' : undefined }); } ); server.tool( 'quote_avatar_video', 'Price an avatar video before making it (no credits spent). With audio_url the price follows the exact length of the audio and no voice is needed. Returns estimated_seconds (length of the spoken video), estimated_wait_seconds (how long making it takes), credits (includes the background removal when remove_background is true), remove_background_credits (what removing the background adds; null when not available) and max_seconds for the mode.', { avatar_id: z.string().min(1).max(64), mode: MODE, script: z.string().min(1).max(6000).optional(), audio_url: z.string().url().optional(), resolution: RESOLUTION, speech_url: z.string().optional().describe('The speech_url from preview_avatar_speech for this exact script: the video then speaks what was heard, at its exact length and price. Send it together with the script.'), lipsync_model: z.string().optional().describe('Photo: a model id from list_avatar_lipsync_models (mode photo). Twin: Turbo (default) or Pro, the ids from list_avatar_lipsync_models with mode heygen whose heygen_mode is character. The price follows that model.'), ...TWIN, remove_background: z.boolean().optional().describe('Also remove the background: the video comes back transparent (video_url = webm with alpha, download_url = editing master). Costs extra per second (see remove_background_credits); up to 1080p and 60 s.'), look_id: LOOK, ...HEYGEN, }, async ({ avatar_id, ...body }) => text(await client.post(`/v1/avatars/${encodeURIComponent(avatar_id)}/videos/quote`, body)) ); server.tool( 'create_avatar_video', 'Make the avatar say a script (any language) or speak the user\'s own recording (audio_url: no voice needed on the avatar, the price follows its exact length). Photo mode starts from one image the user must see first: call preview_avatar_scene for that scene, show them the image and wait for their approval, otherwise this refuses with PREVIEW_REQUIRED. Pick mode: omni (acts naturally in the scene, up to 60 s), photo (fast, from a still in the scene, up to 3 min), twin (HeyGen Avatar 6: the person\'s own talking video drives the motion and one starting image gives the face, picked from that video automatically unless start_image_url is given; start_edit or look_id changes the outfit or place; needs a video on the avatar or motion_video_url). Omni/photo use scene_id (from the avatar) or preset_key (default home-studio). Returns video_id at once — poll get_avatar_video until status is completed; its estimated_wait_seconds says how long to expect. Pass session_id to keep several videos in one session; otherwise it goes to project_id (or the API Generations project). remove_background: true delivers it with a transparent background (talking heads to place on anything); quote first, it costs extra.', { avatar_id: z.string().min(1).max(64), mode: MODE, script: z.string().min(1).max(6000).optional(), audio_url: z.string().url().optional(), mic: z.boolean().optional().describe('Omni and Photo, shots that take one: the person holds a small microphone in one hand, like a UGC creator.'), direction: z.string().max(400).optional().describe('Directing notes for the performance (Omni, Photo and Twin), e.g. "excited, laugh on the last line" or "serious, look down at the start". They take priority over the default acting. Photo also reads its still: what the hands hold, framing and the mood of the line.'), scene_id: z.string().max(40).optional(), preset_key: z.string().max(40).optional(), shot: SHOT.optional().describe('Omni only: close = talking head (default), podcast = side angle looking at an unseen host, full_body = whole person seated/standing, walk = walking toward a gimbal camera (best in outdoor scenes), webcam = video call, propped = phone on the table, selfie = close handheld video message.'), look_id: LOOK, aspect_ratio: z.enum(['9:16', '16:9', '1:1']).optional(), resolution: RESOLUTION, language: z.string().max(10).optional().describe('auto (default) or a code like he, en, es.'), speech_url: z.string().optional().describe('The speech_url from preview_avatar_speech for this exact script: the video then speaks what was heard, at its exact length and price. Send it together with the script.'), lipsync_model: z.string().optional().describe('Photo: a model id from list_avatar_lipsync_models (mode photo). Twin: Turbo (default) or Pro, the ids from list_avatar_lipsync_models with mode heygen whose heygen_mode is character. The price follows that model.'), ...TWIN, remove_background: z.boolean().optional().describe('Also remove the background: the video comes back transparent (video_url = webm with alpha, download_url = editing master). Costs extra per second (see remove_background_credits); up to 1080p and 60 s.'), session_id: z.string().max(64).optional(), project_id: z.string().max(64).optional(), ...HEYGEN, }, async ({ avatar_id, ...body }) => text((await client.post(`/v1/avatars/${encodeURIComponent(avatar_id)}/videos`, body))?.video) ); server.tool( 'preview_avatar_scene', 'Make the first frame of a Photo video: the person in the place, the exact image the video starts from (no credits, up to a minute). A Photo video refuses to start without it. Always show preview_url to the user and wait for their approval before create_avatar_video with mode photo. Not happy: call again with again: true (tries_left says how many remain), or use talking_photo with their own image. Pass the returned scene_id to create_avatar_video with the same aspect_ratio, mic and look_id used here (another combination needs its own preview). Omni and twin need no preview.', { avatar_id: z.string().min(1).max(64), scene_id: z.string().max(40).optional(), preset_key: z.string().max(40).optional().describe('A place from list_avatar_scene_presets, when there is no scene_id yet. Default home-studio.'), aspect_ratio: z.enum(['9:16', '16:9', '1:1']).optional(), again: z.boolean().optional().describe('Make a new image instead of returning the current one.'), mic: z.boolean().optional().describe('The person holds a small microphone. Pass the same mic to create_avatar_video.'), look_id: LOOK, }, async ({ avatar_id, scene_id, preset_key, aspect_ratio, again, mic, look_id }) => { const id = encodeURIComponent(avatar_id); const sceneId = scene_id || (await client.post(`/v1/avatars/${id}/scenes`, { preset_key: preset_key || 'home-studio', aspect_ratio }))?.scene?.scene_id; const r = await client.post(`/v1/avatars/${id}/scenes/${encodeURIComponent(sceneId)}/preview`, { shot: 'close', aspect_ratio, again, mic, look_id }); return text({ scene_id: sceneId, ...r }); } ); server.tool( 'talking_photo', 'Make one photo talk exactly as it is: nothing is generated, there is no approval step and the video keeps the shape of the photo (Photo mode, up to 3 min). Give script (needs voice_url or stock_voice_id, or an avatar_id that has a voice) or audio_url (the user\'s own recording; no voice needed, the price follows its exact length). The photo is saved as a regular avatar to reuse or delete; pass avatar_id to add it to an avatar they already have. Returns video_id at once — poll get_avatar_video. Upload local files first with upload_media / create_upload_ticket.', { photo_url: z.string().url().describe('https link of the photo, one person with the face visible.'), consent: CONSENT_ARG, script: z.string().min(1).max(6000).optional(), audio_url: z.string().url().optional(), avatar_id: z.string().max(64).optional(), name: z.string().min(1).max(60).optional().describe('Name of the new avatar. Default My photo.'), voice_url: z.string().url().optional().describe('30-60 s of the person speaking, https, cloned for the script.'), stock_voice_id: STOCK_VOICE, resolution: z.enum(['480p', '720p', '1080p', '4k']).optional(), language: z.string().max(10).optional().describe('auto (default) or a code like he, en, es.'), remove_background: z.boolean().optional(), session_id: z.string().max(64).optional(), project_id: z.string().max(64).optional(), }, async ({ photo_url, consent: _ignored, avatar_id, name, voice_url, stock_voice_id: stock, ...video }) => { const consent = CONSENT; const stock_voice_id = voiceId(stock); if (!video.script === !video.audio_url) throw new Error('Pass script or audio_url, one of them.'); if (video.script && !avatar_id && !voice_url && !stock_voice_id) throw new Error('A script needs a voice: pass voice_url or stock_voice_id, or use audio_url.'); const person = avatar_id || (await client.post('/v1/avatars', { name: name || 'My photo', consent, quick: true, photo_urls: [photo_url], voice_url, stock_voice_id }))?.avatar?.avatar_id; const id = encodeURIComponent(person); const sceneId = (await client.post(`/v1/avatars/${id}/scenes`, { as_is: true, consent, photo_url }))?.scene?.scene_id; try { const r = await client.post(`/v1/avatars/${id}/videos`, { mode: 'photo', scene_id: sceneId, ...video }); return text({ avatar_id: person, scene_id: sceneId, ...r?.video }); } catch (e) { // The person and the photo are saved, so a second call here would make a duplicate avatar. e.message = `${e.message} (avatar_id ${person} and scene_id ${sceneId} are saved: retry with create_avatar_video mode photo.)`; throw e; } } ); server.tool( 'get_avatar_video', 'Status of an avatar video: pending / processing (with progress) / completed (video_url) / failed (error; credits are returned on failure). A transparent video has transparent: true and download_url (editing master); remove_background_credits is the price to remove the background of this finished video (null = not available); notice explains a skipped step.', { video_id: z.string().min(1).max(64) }, async ({ video_id }) => text((await client.get(`/v1/avatars/videos/${encodeURIComponent(video_id)}`))?.video) ); server.tool( 'cancel_avatar_video', 'Stop an avatar video that is still pending or processing. Its credits are returned. Refused when the video has already finished.', { video_id: z.string().min(1).max(64).describe('The video_id from create_avatar_video.') }, async ({ video_id }) => text((await client.post(`/v1/avatars/videos/${encodeURIComponent(video_id)}/cancel`, {}))?.video) ); server.tool( 'remove_avatar_video_background', 'Remove the background of a finished avatar video. Makes a NEW video (transparent: video_url = webm with alpha, download_url = editing master); the original stays. Costs the remove_background_credits shown on get_avatar_video (up to 1080p and 60 s) — tell the user the price first. Asking again returns the copy already made. Poll get_avatar_video with the new video_id.', { video_id: z.string().min(1).max(64).describe('The finished avatar video (video_id from create_avatar_video or get_avatar_video).') }, async ({ video_id }) => text((await client.post(`/v1/avatars/videos/${encodeURIComponent(video_id)}/remove-background`, {}))?.video) ); } module.exports = { registerAvatarTools };