Skip to main content
Glama
rupeedev

image-reader MCP Server

by rupeedev

convert_format

Convert images between formats like JPEG, PNG, WebP, AVIF, TIFF, and GIF with configurable quality settings for different use cases.

Instructions

Convert an image to a different format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYesPath to the input image file
outputYesPath to save the converted image
formatYesTarget format: jpeg, png, webp, avif, tiff, etc.
qualityNoQuality level (1-100, for formats that support it)

Implementation Reference

  • The handler for the 'convert_format' tool. It validates input parameters, ensures the input file exists, creates the output directory, uses Sharp to process the image conversion based on the target format with quality settings, saves the converted image, retrieves its metadata, and returns a success message with details or an error message.
    case "convert_format": {
      const { input, output, format, quality = 80 } = 
        request.params.arguments as { input: string, output: string, format: string, quality?: number };
      
      if (!input || !output || !format) {
        throw new McpError(ErrorCode.InvalidParams, "Input path, output path, and format are required");
      }
      
      if (!fs.existsSync(input)) {
        throw new McpError(ErrorCode.InvalidRequest, `Input image not found: ${input}`);
      }
      
      try {
        // Create output directory if it doesn't exist
        await fsExtra.ensureDir(path.dirname(output));
        
        // Convert the image
        let processor = sharp(input);
        
        // Apply format-specific options
        switch (format.toLowerCase()) {
          case 'jpeg':
          case 'jpg':
            processor = processor.jpeg({ quality });
            break;
          case 'png':
            processor = processor.png({ quality: Math.floor(quality / 100 * 9) });
            break;
          case 'webp':
            processor = processor.webp({ quality });
            break;
          case 'avif':
            processor = processor.avif({ quality });
            break;
          case 'tiff':
            processor = processor.tiff({ quality });
            break;
          case 'gif':
            processor = processor.gif();
            break;
          default:
            throw new McpError(ErrorCode.InvalidParams, `Unsupported format: ${format}`);
        }
        
        await processor.toFile(output);
        
        // Get metadata of the converted image
        const metadata = await getImageMetadata(output);
        
        return {
          content: [
            {
              type: "text",
              text: `Image converted successfully:\n` +
                `- Original: ${input}\n` +
                `- Converted: ${output}\n` +
                `- Format: ${metadata.format}\n` +
                `- Dimensions: ${metadata.width}x${metadata.height}\n` +
                `- Size: ${(metadata.size / 1024).toFixed(2)} KB`
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error converting image: ${error instanceof Error ? error.message : String(error)}`
            }
          ],
          isError: true
        };
      }
    }
  • The input schema definition for the 'convert_format' tool, specifying required parameters (input, output, format) and optional quality, listed in the ListTools response.
      name: "convert_format",
      description: "Convert an image to a different format",
      inputSchema: {
        type: "object",
        properties: {
          input: {
            type: "string",
            description: "Path to the input image file"
          },
          output: {
            type: "string",
            description: "Path to save the converted image"
          },
          format: {
            type: "string",
            description: "Target format: jpeg, png, webp, avif, tiff, etc.",
            enum: ["jpeg", "png", "webp", "avif", "tiff", "gif"]
          },
          quality: {
            type: "number",
            description: "Quality level (1-100, for formats that support it)"
          }
        },
        required: ["input", "output", "format"]
      }
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool converts an image format but lacks details on permissions, side effects (e.g., file overwriting), error handling, or performance aspects. For a mutation tool with zero annotation coverage, this is a significant gap, scoring a 2.

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 directly states the tool's purpose without unnecessary words. It is front-loaded and wastes no space, making it highly concise and well-structured, earning a 5.

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 tool's complexity (format conversion with 4 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects, usage context, or output details, leaving gaps for an AI agent to understand full tool behavior. This inadequacy scores a 2.

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?

Schema description coverage is 100%, so the schema already documents all four parameters (input, output, format, quality) with descriptions and an enum for format. The description adds no additional parameter semantics beyond what the schema provides, such as usage examples or constraints. Baseline 3 is appropriate when the schema does the heavy lifting.

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 action ('convert') and resource ('an image'), specifying the transformation to a different format. It distinguishes from siblings like 'analyze_image' (analysis vs. conversion) and 'resize_image' (size change vs. format change), though it doesn't explicitly name these alternatives. The purpose is specific but lacks explicit sibling differentiation, warranting a 4.

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 like 'analyze_image' or 'resize_image'. It implies usage for format conversion but offers no context on prerequisites, exclusions, or specific scenarios. This minimal guidance is insufficient for informed tool selection, scoring a 2.

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/rupeedev/mcp-image-reader'

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