Skip to main content
Glama
champierre

Image Analysis MCP Server

by champierre

analyze_image

Analyze image content from URLs to extract descriptions and insights using AI vision models.

Instructions

Receives an image URL and analyzes the image content using GPT-4o-mini

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageUrlYesURL of the image to analyze

Implementation Reference

  • Core handler function that performs the image analysis using OpenAI's GPT-4o-mini model. Handles both URL and base64 image inputs by constructing appropriate image_url objects for the chat completion API.
    private async analyzeImageWithGpt4(
       imageData: { type: 'url', data: string } | { type: 'base64', data: string, mimeType: string }
     ): Promise<string> {
      try {
        let imageInput: any;
        if (imageData.type === 'url') {
          imageInput = { type: 'image_url', image_url: { url: imageData.data } };
        } else {
          // Construct data URI for OpenAI API
          imageInput = { type: 'image_url', image_url: { url: `data:${imageData.mimeType};base64,${imageData.data}` } };
        }
    
        const response = await openai.chat.completions.create({
          model: 'gpt-4o-mini',
          messages: [
            {
              role: 'system',
              content: 'Analyze the image content in detail and provide an explanation in English.',
            },
            {
              role: 'user',
              content: [
                { type: 'text', text: 'Please analyze the following image and explain its content in detail.' },
                imageInput, // Use the constructed image input
              ],
            },
          ],
          max_tokens: 1000,
        });
    
        return response.choices[0]?.message?.content || 'Could not retrieve analysis results.';
      } catch (error) {
        console.error('OpenAI API error:', error);
        throw new Error(`OpenAI API error: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • src/index.ts:78-91 (registration)
    Registration of the 'analyze_image' tool in the ListToolsRequestSchema handler, including name, description, and input schema.
    {
      name: 'analyze_image',
      description: 'Receives an image URL and analyzes the image content using GPT-4o-mini',
      inputSchema: {
        type: 'object',
        properties: {
          imageUrl: {
            type: 'string',
            description: 'URL of the image to analyze',
          },
        },
        required: ['imageUrl'],
      },
    },
  • Tool dispatch handler specific to 'analyze_image': validates arguments, checks image URL accessibility, and invokes the core analysis function.
    if (toolName === 'analyze_image') {
      if (!isValidAnalyzeImageArgs(args)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid arguments for analyze_image: imageUrl (string) is required'
        );
      }
      const imageUrl = args.imageUrl;
      await this.validateImageUrl(imageUrl); // Validate URL accessibility
      analysis = await this.analyzeImageWithGpt4({ type: 'url', data: imageUrl });
  • Input schema for the 'analyze_image' tool, specifying required 'imageUrl' property.
    inputSchema: {
      type: 'object',
      properties: {
        imageUrl: {
          type: 'string',
          description: 'URL of the image to analyze',
        },
      },
      required: ['imageUrl'],
    },
  • Type guard helper function to validate arguments for 'analyze_image' tool.
    const isValidAnalyzeImageArgs = (
      args: any
    ): args is { imageUrl: string } =>
      typeof args === 'object' &&
      args !== null &&
      typeof args.imageUrl === 'string';
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 mentions the analysis uses 'GPT-4o-mini', which hints at AI-based processing, but doesn't disclose critical traits like rate limits, authentication needs, response format, error handling, or whether it's a read-only or mutating operation. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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

Conciseness4/5

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

The description is a single, efficient sentence that directly states the tool's function. It's appropriately sized and front-loaded with the core action. However, it could be slightly more structured by explicitly separating purpose from technical details, but overall it avoids waste and is easy to parse.

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 an AI-based image analysis tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the analysis returns (e.g., text description, labels, confidence scores), any limitations (e.g., image size, content restrictions), or error conditions. For a tool that likely produces rich output, this lack of context makes it inadequate for an agent to use 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?

The input schema has 100% description coverage, with the single parameter 'imageUrl' documented as 'URL of the image to analyze'. The description adds no additional meaning beyond this, such as URL format requirements, supported image types, or size limits. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, but no extra credit is earned.

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: 'analyzes the image content using GPT-4o-mini' with a specific verb ('analyzes') and resource ('image content'). It distinguishes from the sibling tool 'analyze_image_from_path' by specifying it works with URLs rather than file paths. However, it doesn't explicitly mention what kind of analysis is performed (e.g., object detection, description generation, etc.), keeping it at a 4 rather than a perfect 5.

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 alternatives. It doesn't mention the sibling tool 'analyze_image_from_path' or explain the difference between URL-based and path-based image analysis. There's no context about prerequisites, limitations, or appropriate use cases, leaving the agent with minimal usage guidance.

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

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/champierre/image-mcp-server'

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