Skip to main content
Glama

convert_image

Convert images between PNG, JPEG, GIF, WebP, and ICO formats with adjustable quality settings for JPEG and WebP files.

Instructions

Convert an image to a different format (PNG, JPEG, GIF, WebP, or ICO).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
input_pathYesAbsolute path to the source image file
output_formatYesTarget format
qualityNoJPEG/WebP quality (1-100, default 90)
output_pathNoWhere to save the output (defaults to same directory as input)

Implementation Reference

  • index.js:99-129 (handler)
    The implementation of the 'convert_image' tool using MCP SDK and sharp for image processing.
    server.tool(
      "convert_image",
      "Convert an image to a different format (PNG, JPEG, GIF, WebP, or ICO).",
      {
        input_path: z.string().describe("Absolute path to the source image file"),
        output_format: z.enum(["png", "jpeg", "gif", "webp", "ico"]).describe("Target format"),
        quality: z.number().int().min(1).max(100).optional().describe("JPEG/WebP quality (1-100, default 90)"),
        output_path: z.string().optional().describe("Where to save the output (defaults to same directory as input)"),
      },
      async ({ input_path, output_format, quality = 90, output_path }) => {
        try {
          await fs.access(input_path);
          let outPath;
          if (output_format === "ico") {
            outPath = resolveOutputPath(input_path, "ico", output_path);
            const icoBuffer = await encodeIco(input_path);
            await fs.writeFile(outPath, icoBuffer);
          } else {
            outPath = resolveOutputPath(input_path, output_format === "jpeg" ? "jpg" : output_format, output_path);
            let pipeline = sharp(input_path).toFormat(output_format, { quality });
            await pipeline.toFile(outPath);
          }
          const stat = await fs.stat(outPath);
          return {
            content: [{ type: "text", text: JSON.stringify({ success: true, output_path: outPath, size_bytes: stat.size }) }],
          };
        } catch (err) {
          return { isError: true, content: [{ type: "text", text: `Error: ${err.message}` }] };
        }
      }
    );
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions format conversion but doesn't address important behavioral aspects like whether the original file is preserved, what happens with unsupported formats, error handling, or performance characteristics. The description is minimal and lacks operational context.

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 extremely concise - a single sentence that directly states the tool's function. There's zero waste or unnecessary elaboration. It's front-loaded with the core purpose and efficiently lists the supported formats.

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?

For a tool with 4 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns, how errors are handled, or provide context about the conversion process. The agent would need to guess about important operational details.

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%, providing good documentation for all parameters. The description adds minimal value beyond the schema - it lists the format options but doesn't explain tradeoffs between formats or when to use quality parameter. Baseline 3 is appropriate when 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 tool's purpose: converting images between specified formats (PNG, JPEG, GIF, WebP, ICO). It uses a specific verb ('convert') and resource ('image'), but doesn't explicitly differentiate from sibling tools like 'convert_and_resize' or 'resize_image' which suggests overlapping functionality.

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?

No guidance is provided on when to use this tool versus alternatives like 'convert_and_resize' or 'resize_image'. The description only states what the tool does, not when it's appropriate or when other tools might be better suited.

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/sonic0002/imagic-mcp'

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