get-youtube-transcript
Extract transcripts from YouTube videos with options for timestamps and language preferences to support content analysis and accessibility.
Instructions
Extract transcripts from YouTube videos with optional parameters for timestamps and language preferences.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| videoUrl | Yes | URL of the YouTube video | |
| includeTimestamps | No | Whether to include timestamps | |
| timestampsToCombine | No | Number of timestamps to combine | |
| preferredLanguage | No | Preferred language code |
Implementation Reference
- src/index.ts:35-63 (handler)Handler function that proxies the request to Dumpling AI's get-youtube-transcript API endpoint, authenticates with API key, and returns the transcript data as JSON string.async ({ videoUrl, includeTimestamps, timestampsToCombine, preferredLanguage, }) => { const apiKey = process.env.DUMPLING_API_KEY; if (!apiKey) throw new Error("DUMPLING_API_KEY not set"); const response = await fetch( `${NWS_API_BASE}/api/v1/get-youtube-transcript`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ videoUrl, includeTimestamps, timestampsToCombine, preferredLanguage, }), } ); if (!response.ok) throw new Error(`Failed: ${response.status} ${await response.text()}`); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; }
- src/index.ts:20-34 (schema)Zod schema defining the input parameters for the get-youtube-transcript tool.videoUrl: z.string().url().describe("URL of the YouTube video"), includeTimestamps: z .boolean() .optional() .default(true) .describe("Whether to include timestamps"), timestampsToCombine: z .number() .optional() .describe("Number of timestamps to combine"), preferredLanguage: z .string() .optional() .describe("Preferred language code"), },
- src/index.ts:16-64 (registration)MCP server.tool registration for the get-youtube-transcript tool, including description, input schema, and inline handler.server.tool( "get-youtube-transcript", "Extract transcripts from YouTube videos with optional parameters for timestamps and language preferences.", { videoUrl: z.string().url().describe("URL of the YouTube video"), includeTimestamps: z .boolean() .optional() .default(true) .describe("Whether to include timestamps"), timestampsToCombine: z .number() .optional() .describe("Number of timestamps to combine"), preferredLanguage: z .string() .optional() .describe("Preferred language code"), }, async ({ videoUrl, includeTimestamps, timestampsToCombine, preferredLanguage, }) => { const apiKey = process.env.DUMPLING_API_KEY; if (!apiKey) throw new Error("DUMPLING_API_KEY not set"); const response = await fetch( `${NWS_API_BASE}/api/v1/get-youtube-transcript`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ videoUrl, includeTimestamps, timestampsToCombine, preferredLanguage, }), } ); if (!response.ok) throw new Error(`Failed: ${response.status} ${await response.text()}`); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } );