analyze_image
Analyze images with AI to extract descriptions, identify objects, and answer questions about visual content using Google's Gemini Pro Vision technology.
Instructions
Analyze an image using Gemini 2.5 Pro Vision
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| imageData | Yes | Base64 encoded image data | |
| prompt | No | Text prompt to describe what to analyze in the image | Describe this image |
Implementation Reference
- src/index.ts:149-179 (handler)The main handler function that executes the analyze_image tool. It processes base64-encoded image data and an optional prompt, uses the Gemini model for vision analysis, and returns the generated text description.private async handleImageAnalysis(args: any) { const { imageData, prompt = "Describe this image" } = args; // Convert base64 to proper format for Gemini const imagePart = { inlineData: { data: imageData, mimeType: "image/jpeg", // Adjust based on your needs }, }; const result = await this.model.generateContent({ contents: [ { role: "user", parts: [{ text: prompt }, imagePart], }, ], }); const response = result.response; const text = response.text(); return { content: [ { type: "text", text: text, }, ], };
- src/index.ts:73-91 (registration)Registration of the analyze_image tool in the ListToolsRequestSchema handler, including name, description, and input schema.{ name: "analyze_image", description: "Analyze an image using Gemini 2.5 Pro Vision", inputSchema: { type: "object", properties: { imageData: { type: "string", description: "Base64 encoded image data", }, prompt: { type: "string", description: "Text prompt to describe what to analyze in the image", default: "Describe this image", }, }, required: ["imageData"], }, },
- src/index.ts:76-90 (schema)Input schema definition for the analyze_image tool, specifying base64 imageData as required and optional prompt.inputSchema: { type: "object", properties: { imageData: { type: "string", description: "Base64 encoded image data", }, prompt: { type: "string", description: "Text prompt to describe what to analyze in the image", default: "Describe this image", }, }, required: ["imageData"], },
- src/index.ts:104-105 (registration)Dispatch/registration of the analyze_image handler in the CallToolRequestSchema switch statement.case "analyze_image": return await this.handleImageAnalysis(args);