Skip to main content
Glama

convert_format

Convert images between JPEG, PNG, WebP, and AVIF formats with quality control for lossy compression.

Instructions

Convert image between formats (jpeg, png, webp, avif)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputPathYesPath to input image
outputPathYesPath to save converted image
formatYesTarget format
qualityNoQuality for lossy formats (1-100)

Implementation Reference

  • The handler for the 'convert_format' tool. It processes the input arguments, creates the output directory if needed, uses Sharp to convert the image to the specified format with optional quality, saves it, and returns a success message.
    case 'convert_format': {
      const { inputPath, outputPath, format, quality = 80 } = args;
      
      await fs.mkdir(path.dirname(outputPath), { recursive: true });
      
      let pipeline = sharp(inputPath);
      
      switch (format) {
        case 'jpeg':
        case 'jpg':
          pipeline = pipeline.jpeg({ quality, progressive: true });
          break;
        case 'png':
          pipeline = pipeline.png({ quality });
          break;
        case 'webp':
          pipeline = pipeline.webp({ quality });
          break;
        case 'avif':
          pipeline = pipeline.avif({ quality });
          break;
      }
      
      await pipeline.toFile(outputPath);
      
      return {
        content: [
          {
            type: 'text',
            text: `Image converted to ${format} format. Saved to: ${outputPath}`
          }
        ]
      };
    }
  • Input schema definition for the 'convert_format' tool, specifying parameters like inputPath, outputPath, format (enum), and optional quality.
    inputSchema: {
      type: 'object',
      properties: {
        inputPath: { type: 'string', description: 'Path to input image' },
        outputPath: { type: 'string', description: 'Path to save converted image' },
        format: {
          type: 'string',
          enum: ['jpeg', 'jpg', 'png', 'webp', 'avif'],
          description: 'Target format'
        },
        quality: {
          type: 'number',
          minimum: 1,
          maximum: 100,
          description: 'Quality for lossy formats (1-100)',
          default: 80
        }
      },
      required: ['inputPath', 'outputPath', 'format']
    }
  • src/index.ts:53-76 (registration)
    Registration of the 'convert_format' tool in the ListTools response, including name, description, and input schema.
    {
      name: 'convert_format',
      description: 'Convert image between formats (jpeg, png, webp, avif)',
      inputSchema: {
        type: 'object',
        properties: {
          inputPath: { type: 'string', description: 'Path to input image' },
          outputPath: { type: 'string', description: 'Path to save converted image' },
          format: {
            type: 'string',
            enum: ['jpeg', 'jpg', 'png', 'webp', 'avif'],
            description: 'Target format'
          },
          quality: {
            type: 'number',
            minimum: 1,
            maximum: 100,
            description: 'Quality for lossy formats (1-100)',
            default: 80
          }
        },
        required: ['inputPath', 'outputPath', '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. It states the tool converts images between formats but lacks details on behavioral traits: it doesn't mention whether the conversion is lossy/lossless, if it overwrites existing files, what happens on errors, or performance aspects like speed. For a mutation tool with zero annotation coverage, this is a significant gap.

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 and lists key formats. It is front-loaded with the core action and avoids unnecessary details, making it easy to parse quickly. Every word contributes to understanding the tool's function.

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 has no annotations, no output schema, and involves mutation (converting images), the description is incomplete. It doesn't cover return values, error handling, or important behavioral aspects like file overwriting. For a 4-parameter tool with siblings, more context is needed to ensure safe and correct usage.

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 parameters (inputPath, outputPath, format, quality) with descriptions and constraints. The description adds minimal value beyond the schema by listing some formats, but it doesn't explain parameter interactions or provide additional context like default behaviors. 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 verb 'convert' and resource 'image', specifying the action and target. It lists supported formats (jpeg, png, webp, avif), which helps distinguish it from siblings like resize or crop. However, it doesn't explicitly differentiate from format-related siblings like compress_image, which might also handle format changes.

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 siblings like compress_image (which might involve format conversion) or get_image_info (for checking current format), nor does it specify prerequisites such as needing valid image files. Usage is implied by the action but not explicitly defined.

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/flowy11/imagician'

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