analyze_image
Analyze image content using Google's Gemini Pro Vision AI to extract descriptions, identify objects, or answer questions about visual data.
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 handler function that executes the analyze_image tool. It processes base64 encoded image data and an optional prompt, constructs the content for Gemini's generateContent method using inlineData, generates the analysis, and returns the text response.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 ListTools response, including name, description, and input schema definition.{ 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:104-105 (registration)Dispatch case in the CallToolRequestSchema handler that routes analyze_image calls to the handleImageAnalysis method.case "analyze_image": return await this.handleImageAnalysis(args);
- src/index.ts:76-90 (schema)Input schema for the analyze_image tool defining parameters imageData (base64 string, 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"], },