Skip to main content
Glama

summarize_youtube_video

Generate concise summaries of YouTube videos by inputting a URL. Choose from short, medium, or long summary lengths to quickly extract key insights and save time.

Instructions

Generates a summary of a given YouTube video URL using Gemini Vision API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
summary_lengthNoDesired summary length: 'short', 'medium', or 'long' (default: 'medium').medium
youtube_urlYes

Implementation Reference

  • The main execution logic for the 'summarize_youtube_video' tool. It validates input arguments using the schema, constructs a tailored prompt based on the desired summary length, invokes the Gemini Vision API via the helper function with the YouTube URL as video input, and returns the generated summary or handles errors appropriately.
    case "summarize_youtube_video": { try { // Parse and validate arguments const args = SummarizeYoutubeVideoInputSchema.parse(request.params.arguments); const { youtube_url, summary_length } = args; const length = summary_length || 'medium'; // Use default if not provided console.error(`[INFO] Received request to summarize YouTube URL: ${youtube_url} (Length: ${length})`); // Construct the prompt for Gemini API const finalPrompt = `Please summarize this video. Aim for a ${length} length summary.`; // Call Gemini API using the helper function const summary = await callGeminiApi(finalPrompt, { mimeType: "video/youtube", fileUri: youtube_url, }); console.error(`[INFO] Successfully generated summary.`); // Return success response return { content: [{ type: "text", text: summary }], }; } catch (error: any) { console.error(`[ERROR] Failed during summarize_youtube_video tool execution:`, error); // Handle Zod validation errors if (error instanceof z.ZodError) { return { content: [{ type: "text", text: `Invalid input: ${JSON.stringify(error.errors)}` }], isError: true, }; } // Handle generic errors let errorMessage = `Failed to generate summary for the video.`; if (error.message) { errorMessage += ` Details: ${error.message}`; } return { content: [{ type: "text", text: errorMessage }], isError: true, }; } }
  • Zod input schema definition for the 'summarize_youtube_video' tool, validating the required YouTube URL and optional summary length enum.
    // --- 3a. Input Schema for summarize_youtube_video --- const SummaryLengthEnum = z.enum(['short', 'medium', 'long']).default('medium'); const SummarizeYoutubeVideoInputSchema = z.object({ youtube_url: z.string().url({ message: "Invalid YouTube URL provided." }), summary_length: SummaryLengthEnum.optional().describe("Desired summary length: 'short', 'medium', or 'long' (default: 'medium')."), });
  • src/index.ts:69-74 (registration)
    Tool registration in the ListTools response, specifying the name, description, and input schema for 'summarize_youtube_video'.
    // Replaced describe_youtube_video with summarize_youtube_video { name: "summarize_youtube_video", description: "Generates a summary of a given YouTube video URL using Gemini Vision API.", inputSchema: zodToJsonSchema(SummarizeYoutubeVideoInputSchema), },
  • Shared helper function that performs the actual Gemini API call for video analysis, used by the 'summarize_youtube_video' handler and other tools. It sends the prompt and YouTube video URI to the model and handles various error cases.
    async function callGeminiApi(prompt: string, fileData: { mimeType: string; fileUri: string }): Promise<string> { try { const result = await geminiModel.generateContent([ prompt, { fileData }, ]); const response = result.response; return response.text(); } catch (error: any) { console.error(`[ERROR] Gemini API call failed:`, error); // Attempt to provide more specific error info based on message content // (Since GoogleGenerativeAIError type seems unavailable for direct check) if (error instanceof Error) { // Check for common messages indicating client-side issues (API key, quota, etc.) // This part might need refinement based on actual observed error messages. if (error.message.includes('API key') || error.message.includes('permission denied')) { throw new Error(`Authentication/Authorization Error with Gemini API: ${error.message}`); } else if (error.message.includes('quota')) { throw new Error(`Gemini API quota likely exceeded: ${error.message}`); } else if (error.message.toLowerCase().includes('invalid')) { // Generic check for invalid inputs throw new Error(`Invalid input likely provided to Gemini API: ${error.message}`); } else if (error.message.includes('500') || error.message.includes('server error') || error.message.includes('network issue')) { // Guessing based on common error patterns for server/network issues throw new Error(`Gemini API server error or network issue: ${error.message}`); } // Re-throw generic error if specific checks don't match throw new Error(`Gemini API Error: ${error.message}`); } // Re-throw if it's not an Error instance for some reason throw error; // Keep original error if not an Error instance } }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/minbang930/Youtube-Vision-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server