Skip to main content
Glama
itrimble

Image Viewer MCP

by itrimble

image-info

Extract and view detailed metadata from image files without processing the full image data, enabling quick access to essential information for analysis or verification.

Instructions

Get detailed information about an image file without loading the full image data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imagePathYesPath to the image file (supports ~ for home directory)

Implementation Reference

  • Registration and inline handler for the 'image-info' MCP tool. Handles input validation with Zod schema, calls loadImage helper, and formats response as JSON text content.
    server.tool(
        "image-info",
        "Get detailed information about an image file without loading the full image data",
        {
            imagePath: z.string().describe("Path to the image file (supports ~ for home directory)"),
        },
        async ({ imagePath }) => {
            try {
                const imageInfo = await imageViewer.loadImage(imagePath);
                
                return {
                    content: [
                        {
                            type: "text",
                            text: JSON.stringify({
                                name: imageInfo.name,
                                path: imageInfo.path,
                                size: imageInfo.size,
                                sizeKB: Math.round(imageInfo.size / 1024),
                                mimeType: imageInfo.mimeType
                            }, null, 2),
                        },
                    ],
                };
            } catch (error) {
                return {
                    content: [
                        {
                            type: "text",
                            text: `Error getting image info: ${error instanceof Error ? error.message : 'Unknown error'}`,
                        },
                    ],
                };
            }
        }
    );
  • TypeScript interface defining the ImageInfo structure used by the loadImage function and returned in image-info tool responses.
    export interface ImageInfo {
        path: string;
        name: string;
        size: number;
        mimeType: string;
        base64Data: string;
    }
  • Core helper function that resolves image path, validates file type, reads file stats and content, encodes to base64, and returns ImageInfo object. Called by image-info handler.
    export async function loadImage(imagePath: string): Promise<ImageInfo> {
        // Resolve the path to handle ~ and relative paths
        const resolvedPath = path.resolve(imagePath.replace(/^~/, process.env.HOME || ''));
        
        if (!fs.existsSync(resolvedPath)) {
            throw new Error(`Image file not found: ${resolvedPath}`);
        }
    
        if (!isImageFile(resolvedPath)) {
            throw new Error(`File is not a supported image type: ${resolvedPath}`);
        }
    
        const stats = fs.statSync(resolvedPath);
        const imageData = fs.readFileSync(resolvedPath);
        const base64Data = imageData.toString('base64');
        
        return {
            path: resolvedPath,
            name: path.basename(resolvedPath),
            size: stats.size,
            mimeType: getMimeType(resolvedPath),
            base64Data: base64Data
        };
    }
  • Helper function to check if a file has a supported image extension, used in loadImage.
    export function isImageFile(filePath: string): boolean {
        const ext = path.extname(filePath).toLowerCase();
        return SUPPORTED_EXTENSIONS.includes(ext);
    }
  • Helper function to determine MIME type from file extension, used in loadImage.
    export function getMimeType(filePath: string): string {
        const ext = path.extname(filePath).toLowerCase();
        switch (ext) {
            case '.jpg':
            case '.jpeg':
                return 'image/jpeg';
            case '.png':
                return 'image/png';
            case '.gif':
                return 'image/gif';
            case '.bmp':
                return 'image/bmp';
            case '.webp':
                return 'image/webp';
            case '.svg':
                return 'image/svg+xml';
            default:
                return 'application/octet-stream';
        }
    }
Behavior3/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 helpfully indicates this is a read-only operation that extracts metadata rather than displaying the image, which is valuable context. However, it doesn't mention potential error conditions (e.g., invalid file paths, unsupported formats), performance characteristics, or what 'detailed information' specifically includes, leaving some behavioral aspects unclear.

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 immediately communicates the core purpose and key constraint. Every word earns its place - 'Get detailed information' establishes the action, 'about an image file' specifies the resource, and 'without loading the full image data' provides crucial differentiation. No wasted words or unnecessary elaboration.

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

Completeness3/5

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

For a single-parameter tool with good schema coverage but no annotations and no output schema, the description provides adequate but incomplete context. It clearly states what the tool does and its key constraint, but doesn't explain what 'detailed information' includes in the return value or address potential behavioral aspects like error handling. Given the simplicity of the tool, this is minimally viable but could be more complete.

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 schema description coverage is 100%, with the single parameter 'imagePath' well-documented in the schema. The description doesn't add any additional parameter semantics beyond what's already in the schema (which explains path format and home directory support). This meets the baseline of 3 when schema coverage is high and no parameter details are in the description.

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 ('Get detailed information') and resource ('about an image file'), with the important constraint 'without loading the full image data' that distinguishes it from potential siblings like 'display-image' which likely shows the image. It goes beyond just restating the name 'image-info' by explaining what kind of information is retrieved and how.

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

Usage Guidelines4/5

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

The description provides clear context about when to use this tool ('without loading the full image data'), suggesting it's for metadata extraction rather than visualization. However, it doesn't explicitly mention when NOT to use it or name specific alternatives like 'display-image' or 'list-images' from the sibling list, which would be needed for a perfect score.

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/itrimble/image-viewer-mcp'

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