Skip to main content
Glama

ask_about_youtube_video

Get answers to questions about YouTube video content or receive a general description of the video.

Instructions

Answers a question about the video or provides a general description if no question is asked.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
youtube_urlYes
questionNoQuestion about the video content. If omitted, a general description will be generated.

Implementation Reference

  • Implements the handler logic for the 'ask_about_youtube_video' tool. Parses input arguments using the schema, constructs a prompt (question-specific or general description), calls the shared Gemini API helper with the YouTube video, and handles success/error responses including Zod validation.
    case "ask_about_youtube_video": {
      // Define question variable outside try block to access in catch
      let question: string | undefined;
      try {
        // Parse and validate arguments
        const args = AskAboutYoutubeVideoInputSchema.parse(request.params.arguments);
        const { youtube_url } = args;
        question = args.question; // Assign parsed question here
    
          console.error(`[INFO] Received request for ask_about_youtube_video: ${youtube_url}`);
    
          let finalPrompt: string;
          if (question) {
            // If a question is provided, use the Q&A prompt
            console.error(`[INFO] Question: "${question}"`);
            finalPrompt = `Please answer the following question based on the provided video content:\n\nQuestion: ${question}`;
          } else {
            // If no question, use a general description prompt
            console.error(`[INFO] No question provided, generating general description.`);
            finalPrompt = "Describe this video content in detail.";
          }
    
          // Call Gemini API using the helper function
          const answerOrDescription = await callGeminiApi(finalPrompt, {
            mimeType: "video/youtube",
            fileUri: youtube_url,
          });
    
          console.error(`[INFO] Successfully generated response (answer or description).`);
          // Return success response
          return {
            content: [{ type: "text", text: answerOrDescription }],
          };
    
        } catch (error: any) {
          console.error(`[ERROR] Failed during ask_about_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 = question ? `Failed to answer the question based on the video.` : `Failed to generate description for the video.`;
          if (error.message) {
            errorMessage += ` Details: ${error.message}`;
          }
          return {
            content: [{ type: "text", text: errorMessage }],
            isError: true,
          };
        }
      }
  • Zod input schema definition for the 'ask_about_youtube_video' tool, validating youtube_url as a URL and question as optional string.
    const AskAboutYoutubeVideoInputSchema = z.object({
      youtube_url: z.string().url({ message: "Invalid YouTube URL provided." }),
      // Making question optional to handle general description requests as well
      question: z.string().optional().describe("Question about the video content. If omitted, a general description will be generated."),
    });
  • src/index.ts:76-80 (registration)
    Registers the 'ask_about_youtube_video' tool in the ListTools response, providing name, description, and converted JSON schema.
    {
      name: "ask_about_youtube_video",
      description: "Answers a question about the video or provides a general description if no question is asked.",
      inputSchema: zodToJsonSchema(AskAboutYoutubeVideoInputSchema), // Schema updated to make question optional
    },

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other 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