delete_video
Permanently delete a YouTube video by ID. Requires exact title confirmation to prevent irreversible removal of the wrong video.
Instructions
Permanently delete a video. Requires confirm_video_title to match the video's current title exactly — guards against deleting the wrong video by ID. Deletion is irreversible.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| video_id | Yes | Video ID to delete. | |
| confirm_video_title | Yes | Exact current title of the video. Must match what YouTube returns to proceed — prevents accidental deletion of the wrong video. |
Implementation Reference
- src/tools/videos.ts:80-108 (handler)The handler function that executes the delete_video tool logic. It fetches the video to verify the title matches confirm_video_title (as a safety check), then calls client.deleteVideo() to permanently delete it.
async (args) => { const current = await client.getVideo(args.video_id); const video = current.items[0]; if (!video) { return { content: [ { type: "text" as const, text: `Video not found: ${args.video_id}`, }, ], }; } const actualTitle = video.snippet?.title ?? ""; if (actualTitle !== args.confirm_video_title) { throw new Error( `confirm_video_title mismatch. Expected exact title "${actualTitle}", got "${args.confirm_video_title}". Aborting delete.`, ); } await client.deleteVideo(args.video_id); return { content: [ { type: "text" as const, text: `Deleted video ${args.video_id} ("${actualTitle}").`, }, ], }; }, - src/tools/videos.ts:14-21 (schema)Input schema for delete_video, requiring a video_id string and a confirm_video_title string that must match the actual video title to prevent accidental deletion.
const deleteVideoSchema = { video_id: z.string().describe("Video ID to delete."), confirm_video_title: z .string() .describe( "Exact current title of the video. Must match what YouTube returns to proceed — prevents accidental deletion of the wrong video.", ), }; - src/tools/videos.ts:76-109 (registration)Registration of the delete_video tool via server.tool() with name 'delete_video', description, schema, and handler.
server.tool( "delete_video", "Permanently delete a video. Requires confirm_video_title to match the video's current title exactly — guards against deleting the wrong video by ID. Deletion is irreversible.", deleteVideoSchema, async (args) => { const current = await client.getVideo(args.video_id); const video = current.items[0]; if (!video) { return { content: [ { type: "text" as const, text: `Video not found: ${args.video_id}`, }, ], }; } const actualTitle = video.snippet?.title ?? ""; if (actualTitle !== args.confirm_video_title) { throw new Error( `confirm_video_title mismatch. Expected exact title "${actualTitle}", got "${args.confirm_video_title}". Aborting delete.`, ); } await client.deleteVideo(args.video_id); return { content: [ { type: "text" as const, text: `Deleted video ${args.video_id} ("${actualTitle}").`, }, ], }; }, ); - src/server.ts:47-47 (registration)Registration call in the main server setup that wires up all video tools including delete_video via registerVideoTools.
registerVideoTools(s, youtube); - src/youtube/client.ts:172-176 (helper)The YouTube API client method that performs the actual HTTP DELETE request to YouTube's Data API v3 /videos endpoint.
deleteVideo(videoId: string): Promise<void> { const url = new URL(`${DATA_API}/videos`); url.searchParams.set("id", videoId); return this.request<void>(url.toString(), { method: "DELETE" }); }