get_video
Fetch complete metadata for a YouTube video by providing its ID. Returns snippet, status, statistics, and duration.
Instructions
Fetch full details for one video by ID — snippet, status, statistics, duration.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| video_id | Yes | YouTube video ID (the part after v= in the URL) |
Implementation Reference
- src/tools/videos.ts:62-73 (handler)The handler function for get_video tool. Fetches video details by ID via client.getVideo() and returns the JSON result.
async (args) => { const data = await client.getVideo(args.video_id); const video = data.items[0]; if (!video) { return { content: [{ type: "text" as const, text: `Video not found: ${args.video_id}` }] }; } return { content: [ { type: "text" as const, text: JSON.stringify(video, null, 2) }, ], }; }, - src/tools/videos.ts:10-12 (schema)Input schema for get_video: takes a required video_id string field.
const getVideoSchema = { video_id: z.string().describe("YouTube video ID (the part after v= in the URL)"), }; - src/tools/videos.ts:58-61 (registration)Registration of get_video tool on the MCP server using server.tool() with name 'get_video', description, schema, and handler.
server.tool( "get_video", "Fetch full details for one video by ID — snippet, status, statistics, duration.", getVideoSchema, - src/youtube/client.ts:160-165 (helper)YouTubeClient.getVideo() method that calls the YouTube Data API /videos endpoint with snippet, status, statistics, and contentDetails parts.
getVideo(videoId: string): Promise<{ items: Video[] }> { return this.dataGet("/videos", { part: "snippet,status,statistics,contentDetails", id: videoId, }); }