Skip to main content
Glama
mario-andreschak

MCP Image Recognition Server

describe_image

Generate detailed descriptions of images using base64-encoded data. Ideal for uploaded images in chat conversations, providing accurate analysis via advanced vision APIs.

Instructions

Describe an image from base64-encoded data. Use for images directly uploaded to chat.

Best for: Images uploaded to the current conversation where no public URL exists.
Not for: Local files on your computer or images with public URLs.

Args:
    image: Base64-encoded image data
    prompt: Optional prompt to guide the description

Returns:
    str: Detailed description of the image

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYes
promptNoPlease describe this image in detail.

Implementation Reference

  • Main handler for the MCP 'describe_image' tool. Validates input, calls process_image_with_ocr, sanitizes and returns the description.
    @mcp.tool()
    async def describe_image(
        image: str, prompt: str = "Please describe this image in detail."
    ) -> str:
        """Describe the contents of an image using vision AI.
    
        Args:
            image: Image data and MIME type
            prompt: Optional prompt to use for the description.
    
        Returns:
            str: Detailed description of the image
        """
        try:
            logger.info(f"Processing image description request with prompt: {prompt}")
            logger.debug(f"Image data length: {len(image)}")
    
            # Validate image data
            if not validate_base64_image(image):
                raise ValueError("Invalid base64 image data")
    
            result = await process_image_with_ocr(image, prompt)
            if not result:
                raise ValueError("Received empty response from processing")
    
            logger.info("Successfully processed image")
            return sanitize_output(result)
        except ValueError as e:
            logger.error(f"Input error: {str(e)}")
            raise
        except Exception as e:
            logger.error(f"Error describing image: {str(e)}", exc_info=True)
            raise
  • Core helper function that invokes the vision client (Anthropic or OpenAI) to describe the image and optionally appends OCR text.
    async def process_image_with_ocr(image_data: str, prompt: str) -> str:
        """Process image with both vision AI and OCR.
    
        Args:
            image_data: Base64 encoded image data
            prompt: Prompt for vision AI
    
        Returns:
            str: Combined description from vision AI and OCR
        """
        # Get vision AI description
        client = get_vision_client()
    
        # Handle both sync (Anthropic) and async (OpenAI) clients
        if isinstance(client, OpenAIVision):
            description = await client.describe_image(image_data, prompt)
        else:
            description = client.describe_image(image_data, prompt)
    
        # Check for empty or default response
        if not description or description == "No description available.":
            raise ValueError("Vision API returned empty or default response")
    
        # Handle OCR if enabled
        ocr_enabled = os.getenv("ENABLE_OCR", "false").lower() == "true"
        if ocr_enabled:
            try:
                # Convert base64 to PIL Image
                image_bytes = base64.b64decode(image_data)
                image = Image.open(io.BytesIO(image_bytes))
    
                # Extract text with OCR required flag
                if ocr_text := extract_text_from_image(image, ocr_required=True):
                    description += (
                        f"\n\nAdditionally, this is the output of tesseract-ocr: {ocr_text}"
                    )
            except OCRError as e:
                # Propagate OCR errors when OCR is enabled
                logger.error(f"OCR processing failed: {str(e)}")
                raise ValueError(f"OCR Error: {str(e)}")
            except Exception as e:
                logger.error(f"Unexpected error during OCR: {str(e)}")
                raise
    
        return sanitize_output(description)
  • The @mcp.tool() decorator registers the describe_image function as an MCP tool.
    @mcp.tool()
Behavior4/5

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

With no annotations provided, the description carries the full burden. It effectively communicates the tool's behavior: it describes images, requires base64-encoded data, accepts an optional prompt for guidance, and returns a detailed description. However, it doesn't mention potential limitations like image size constraints, processing time, or error conditions.

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 well-structured and front-loaded with the core purpose, followed by usage guidelines and parameter explanations. Every sentence adds value without redundancy, making it efficient and easy to parse.

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

Completeness4/5

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

For a tool with 2 parameters, no annotations, and no output schema, the description provides strong coverage of purpose, usage, and parameter semantics. It could be more complete by mentioning return format details or potential errors, but it adequately supports tool selection and invocation given the context.

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

Parameters4/5

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

The description adds meaningful context beyond the schema's 0% coverage. It explains that 'image' expects 'Base64-encoded image data' and 'prompt' is 'Optional prompt to guide the description', clarifying the purpose of each parameter. The schema only provides titles and types without this semantic information.

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

Purpose5/5

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

The description clearly states the specific action ('Describe an image') and resource ('from base64-encoded data'), distinguishing it from sibling tools that handle files or URLs. It explicitly mentions the use case for 'images directly uploaded to chat'.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use ('Best for: Images uploaded to the current conversation where no public URL exists') and when not to use ('Not for: Local files on your computer or images with public URLs'), with clear alternatives implied through sibling tool names.

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-image-recognition'

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