Skip to main content
Glama

video_recognition

Analyze and generate detailed descriptions of video content using Google Gemini AI. Specify file paths, custom prompts, and models for precise recognition.

Instructions

Analyze and describe videos using Google Gemini AI

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYesPath to the media file to analyze
modelnameNoGemini model to use for recognitiongemini-2.0-flash
promptNoCustom prompt for the recognitionDescribe this content

Implementation Reference

  • Factory function that creates the video_recognition tool object, defining its name, description, input schema reference, and the core callback handler. The handler validates the video file, uploads it to GeminiService, processes it with a prompt, and returns the recognition result or error.
    export const createVideoRecognitionTool = (geminiService: GeminiService) => {
      return {
        name: 'video_recognition',
        description: 'Analyze and describe videos using Google Gemini AI',
        inputSchema: VideoRecognitionParamsSchema,
        callback: async (args: VideoRecognitionParams): Promise<CallToolResult> => {
          try {
            log.info(`Processing video recognition request for file: ${args.filepath}`);
            log.verbose('Video recognition request', JSON.stringify(args));
            
            // Verify file exists
            if (!fs.existsSync(args.filepath)) {
              throw new Error(`Video file not found: ${args.filepath}`);
            }
            
            // Verify file is a video
            const ext = path.extname(args.filepath).toLowerCase();
            if (ext !== '.mp4' && ext !== '.mpeg' && ext !== '.mov' && ext !== '.avi' && ext !== '.webm') {
              throw new Error(`Unsupported video format: ${ext}. Supported formats are: .mp4, .mpeg, .mov, .avi, .webm`);
            }
            
            // Default prompt if not provided
            const prompt = args.prompt || 'Describe this video';
            const modelName = args.modelname || 'gemini-2.0-flash';
            
            // Upload the file - this will handle waiting for video processing
            log.info('Uploading and processing video file...');
            const file = await geminiService.uploadFile(args.filepath);
            
            // Process with Gemini
            log.info('Video processing complete, generating content...');
            const result = await geminiService.processFile(file, prompt, modelName);
            
            if (result.isError) {
              log.error(`Error in video recognition: ${result.text}`);
              return {
                content: [
                  {
                    type: 'text',
                    text: result.text
                  }
                ],
                isError: true
              };
            }
            
            log.info('Video recognition completed successfully');
            log.verbose('Video recognition result', JSON.stringify(result));
            
            return {
              content: [
                {
                  type: 'text',
                  text: result.text
                }
              ]
            };
          } catch (error) {
            log.error('Error in video recognition tool', error);
            const errorMessage = error instanceof Error ? error.message : String(error);
            
            return {
              content: [
                {
                  type: 'text',
                  text: `Error processing video: ${errorMessage}`
                }
              ],
              isError: true
            };
          }
        }
      };
    };
  • Zod schemas defining the input parameters for the video_recognition tool: filepath (required), optional prompt and modelname. VideoRecognitionParamsSchema extends the common RecognitionParamsSchema.
    export const RecognitionParamsSchema = z.object({
      filepath: z.string().describe('Path to the media file to analyze'),
      prompt: z.string().default('Describe this content').describe('Custom prompt for the recognition'),
      modelname: z.string().default('gemini-2.0-flash').describe('Gemini model to use for recognition')
    });
    
    export type RecognitionParams = z.infer<typeof RecognitionParamsSchema>;
    
    /**
     * Video recognition specific types
     */
    export const VideoRecognitionParamsSchema = RecognitionParamsSchema.extend({});
    export type VideoRecognitionParams = z.infer<typeof VideoRecognitionParamsSchema>;
  • src/server.ts:72-77 (registration)
    Registers the video_recognition tool with the MCP server by calling mcpServer.tool() with the tool's name, description, input schema shape, and callback handler.
    this.mcpServer.tool(
      videoRecognitionTool.name,
      videoRecognitionTool.description,
      videoRecognitionTool.inputSchema.shape,
      videoRecognitionTool.callback
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool analyzes and describes videos but doesn't mention critical behavioral aspects like rate limits, authentication requirements, file size limits, supported video formats, processing time, or error handling. The description is too vague about what 'analyze and describe' entails operationally.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that states the core functionality without unnecessary words. It's appropriately sized and front-loaded with the essential information, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of video analysis (which typically involves format handling, processing time, and potential errors), no annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns, how to interpret results, or any operational constraints, leaving significant gaps for an AI agent to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema, such as explaining how the prompt interacts with video analysis or model selection trade-offs. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as analyzing and describing videos using Google Gemini AI, which is specific (verb+resource) and distinguishes it from sibling tools like audio_recognition and image_recognition. However, it doesn't explicitly mention video-specific capabilities beyond the name, leaving some ambiguity about whether it handles all video formats or specific features.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus its siblings (audio_recognition, image_recognition). It doesn't mention prerequisites, limitations, or alternative scenarios, leaving the agent to infer usage based on tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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/mario-andreschak/mcp_video_recognition'

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