delete_video
Delete an ad video permanently to remove it from your Meta Ads library. Note: this action is irreversible.
Instructions
Delete an ad video. This action is irreversible.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| video_id | Yes | Video ID to delete |
Implementation Reference
- src/tools/videos.ts:78-85 (handler)The async handler function that executes the delete_video tool logic. It calls client.delete with the video_id and returns success/failure.
async ({ video_id }) => { try { const { data, rateLimit } = await client.delete(`/${video_id}`); return { content: [{ type: "text" as const, text: JSON.stringify({ success: true, ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } - src/tools/videos.ts:75-77 (schema)Zod schema defining the input parameter: video_id (string).
{ video_id: z.string().describe("Video ID to delete"), }, - src/tools/videos.ts:72-86 (registration)Registration of the delete_video tool on the MCP server using server.tool() with name, description, schema, and handler.
server.tool( "delete_video", "Delete an ad video. This action is irreversible.", { video_id: z.string().describe("Video ID to delete"), }, async ({ video_id }) => { try { const { data, rateLimit } = await client.delete(`/${video_id}`); return { content: [{ type: "text" as const, text: JSON.stringify({ success: true, ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); - src/index.ts:57-57 (registration)Call site where registerVideoTools is invoked, registering all video tools including delete_video.
registerVideoTools(server, client); - src/tools/videos.ts:5-87 (helper)The registerVideoTools function that registers all video-related tools (list, upload, get, delete) on the server.
export function registerVideoTools(server: McpServer, client: AdsClient): void { // ─── list_videos ─────────────────────────────────────────── server.tool( "list_videos", "List ad videos uploaded to the ad account.", { fields: z.string().optional().describe("Comma-separated fields to return"), limit: z.number().optional().default(25).describe("Number of results (default 25)"), after: z.string().optional().describe("Pagination cursor for next page"), }, async ({ fields, limit, after }) => { try { const params: Record<string, unknown> = {}; if (fields) params.fields = fields; if (limit) params.limit = limit; if (after) params.after = after; const { data, rateLimit } = await client.get(`${client.accountPath}/advideos`, params); return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); // ─── upload_video ────────────────────────────────────────── server.tool( "upload_video", "Upload an ad video from a public URL. Returns video ID for use in ad creatives.", { file_url: z.string().describe("Public URL of the video to upload"), title: z.string().optional().describe("Video title"), description: z.string().optional().describe("Video description"), }, async ({ file_url, title, description }) => { try { const params: Record<string, unknown> = { file_url }; if (title) params.title = title; if (description) params.description = description; const { data, rateLimit } = await client.post(`${client.accountPath}/advideos`, params); return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); // ─── get_video ───────────────────────────────────────────── server.tool( "get_video", "Get details of a specific ad video by ID.", { video_id: z.string().describe("Video ID"), fields: z.string().optional().describe("Comma-separated fields to return"), }, async ({ video_id, fields }) => { try { const params: Record<string, unknown> = {}; if (fields) params.fields = fields; const { data, rateLimit } = await client.get(`/${video_id}`, params); return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); // ─── delete_video ────────────────────────────────────────── server.tool( "delete_video", "Delete an ad video. This action is irreversible.", { video_id: z.string().describe("Video ID to delete"), }, async ({ video_id }) => { try { const { data, rateLimit } = await client.delete(`/${video_id}`); return { content: [{ type: "text" as const, text: JSON.stringify({ success: true, ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); }