Skip to main content
Glama
maoxiaoke

MCP Media Processing Server

by maoxiaoke

convert-image

Transform image files into different formats using the MCP Media Processing Server. Specify input path, desired output format, and optional output filename or path for efficient conversion.

Instructions

Convert image to different format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputPathYesAbsolute path to input image file
outputFilenameNoOutput filename (only used if outputPath is not provided)
outputFormatYesDesired output format (e.g., jpg, png, webp, gif)
outputPathNoOptional absolute path for output file. If not provided, file will be saved in Downloads folder

Implementation Reference

  • The asynchronous handler function that executes the image conversion logic using ImageMagick's 'convert' command. It validates paths, constructs the output filename, runs the conversion, and returns success or error messages.
    async ({ inputPath, outputFormat, outputPath, outputFilename }) => {
      try {
        await checkImageMagick();
        const absoluteInputPath = await getAbsolutePath(inputPath);
        const inputFileName = absoluteInputPath.split('/').pop()?.split('.')[0] || 'output';
        const defaultFilename = outputFilename || `${inputFileName}_converted.${outputFormat}`;
        const finalOutputPath = await getOutputPath(outputPath, defaultFilename);
    
        const command = `convert "${absoluteInputPath}" "${finalOutputPath}"`;
        await execSync(command);
    
        return {
          content: [
            {
              type: "text",
              text: `Image successfully converted and saved to: ${finalOutputPath}`,
            },
          ],
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: "text",
              text: `Error converting image: ${errorMessage}`,
            },
          ],
        };
      }
    }
  • Zod schema defining the input parameters for the convert-image tool.
    {
      inputPath: z.string().describe("Absolute path to input image file"),
      outputFormat: z.string().describe("Desired output format (e.g., jpg, png, webp, gif)"),
      outputPath: z.string().optional().describe("Optional absolute path for output file. If not provided, file will be saved in Downloads folder"),
      outputFilename: z.string().optional().describe("Output filename (only used if outputPath is not provided)")
    },
  • src/index.ts:323-363 (registration)
    The server.tool registration call that defines the tool name, description, input schema, and handler function for 'convert-image'. Note: excerpt abbreviated for handler.
    server.tool(
      "convert-image",
      "Convert image to different format",
      {
        inputPath: z.string().describe("Absolute path to input image file"),
        outputFormat: z.string().describe("Desired output format (e.g., jpg, png, webp, gif)"),
        outputPath: z.string().optional().describe("Optional absolute path for output file. If not provided, file will be saved in Downloads folder"),
        outputFilename: z.string().optional().describe("Output filename (only used if outputPath is not provided)")
      },
      async ({ inputPath, outputFormat, outputPath, outputFilename }) => {
        try {
          await checkImageMagick();
          const absoluteInputPath = await getAbsolutePath(inputPath);
          const inputFileName = absoluteInputPath.split('/').pop()?.split('.')[0] || 'output';
          const defaultFilename = outputFilename || `${inputFileName}_converted.${outputFormat}`;
          const finalOutputPath = await getOutputPath(outputPath, defaultFilename);
    
          const command = `convert "${absoluteInputPath}" "${finalOutputPath}"`;
          await execSync(command);
    
          return {
            content: [
              {
                type: "text",
                text: `Image successfully converted and saved to: ${finalOutputPath}`,
              },
            ],
          };
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : String(error);
          return {
            content: [
              {
                type: "text",
                text: `Error converting image: ${errorMessage}`,
              },
            ],
          };
        }
      }
    );
Behavior1/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 but provides minimal information. It doesn't mention whether this operation is destructive to the original file, what permissions are needed, potential rate limits, error conditions, or what happens when conversion fails. The description only states what the tool does at a high level without behavioral details.

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 at just four words, with zero wasted language. It's front-loaded with the core purpose and contains no unnecessary elaboration. Every word earns its place in communicating the essential 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?

For a file manipulation tool with no annotations and no output schema, the description is inadequate. It doesn't explain what the tool returns, what happens on success/failure, file size limitations, supported input formats, or quality implications of format conversion. The combination of sparse description and missing structured data leaves significant gaps for an agent trying to use this tool effectively.

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 thoroughly. The description adds no additional parameter information beyond what's in the schema - it doesn't explain parameter interactions, provide format examples beyond what's in the schema, or clarify edge cases. The baseline of 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 the resource 'image', specifying the action of changing format. It distinguishes from some siblings like resize-image or rotate-image by focusing on format conversion rather than geometric transformations, though it doesn't explicitly differentiate from all siblings like compress-image which might also involve 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 when format conversion is appropriate compared to compression (compress-image), applying effects (apply-effect), or using the more general execute-ffmpeg tool. No prerequisites, exclusions, or contextual usage information is provided.

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/maoxiaoke/mcp-media-processor'

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