Skip to main content
Glama
rupeedev

image-reader MCP Server

by rupeedev

resize_image

Resize images to specific dimensions and save them to new files using fit methods like cover, contain, or fill.

Instructions

Resize an image and save to a new file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYesPath to the input image file
outputYesPath to save the resized image
widthYesTarget width in pixels
heightNoTarget height in pixels (optional)
fitNoFit method: cover, contain, fill, inside, outside

Implementation Reference

  • The handler function for the 'resize_image' tool within the CallToolRequestSchema handler. It extracts arguments, validates inputs, ensures output directory exists, resizes the image using Sharp library with specified width, optional height, and fit method, saves to output file, retrieves metadata, and returns a success message or error.
    case "resize_image": {
      const { input, output, width, height, fit = "cover" } = 
        request.params.arguments as { input: string, output: string, width: number, height?: number, fit?: string };
      
      if (!input || !output || !width) {
        throw new McpError(ErrorCode.InvalidParams, "Input path, output path, and width 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));
        
        // Resize the image
        await sharp(input)
          .resize({
            width,
            height,
            fit: fit as keyof sharp.FitEnum
          })
          .toFile(output);
        
        // Get metadata of the resized image
        const metadata = await getImageMetadata(output);
        
        return {
          content: [
            {
              type: "text",
              text: `Image resized successfully:\n` +
                `- Original: ${input}\n` +
                `- Resized: ${output}\n` +
                `- New dimensions: ${metadata.width}x${metadata.height}\n` +
                `- Size: ${(metadata.size / 1024).toFixed(2)} KB`
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error resizing image: ${error instanceof Error ? error.message : String(error)}`
            }
          ],
          isError: true
        };
      }
    }
  • The input schema for the 'resize_image' tool, defined in the ListToolsRequestSchema response. Specifies required parameters (input path, output path, width) and optional (height, fit) with types and descriptions.
      name: "resize_image",
      description: "Resize an image and save to a new file",
      inputSchema: {
        type: "object",
        properties: {
          input: {
            type: "string",
            description: "Path to the input image file"
          },
          output: {
            type: "string",
            description: "Path to save the resized image"
          },
          width: {
            type: "number",
            description: "Target width in pixels"
          },
          height: {
            type: "number",
            description: "Target height in pixels (optional)"
          },
          fit: {
            type: "string",
            description: "Fit method: cover, contain, fill, inside, outside",
            enum: ["cover", "contain", "fill", "inside", "outside"]
          }
        },
        required: ["input", "output", "width"]
      }
    },
Behavior2/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 mentions that the tool 'resize an image and save to a new file', implying a mutation operation, but fails to detail critical aspects like file format support, permission requirements, error handling, or whether the original file is altered. This leaves significant gaps in understanding the tool's behavior.

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 function without unnecessary words. It is front-loaded and clear, making it easy to grasp the purpose quickly, which aligns well with conciseness standards.

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 complexity of a mutation tool with 5 parameters and no annotations or output schema, the description is insufficient. It lacks details on behavioral traits, error conditions, output expectations, and usage context, making it incomplete for effective agent invocation in a real-world scenario.

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 all parameters well-documented in the input schema. The description adds no additional meaning beyond the schema, such as explaining parameter interactions or default behaviors. However, since the schema is comprehensive, a baseline score of 3 is appropriate as the description doesn't need to compensate for gaps.

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 ('resize') and resource ('image') with the outcome ('save to a new file'), making the purpose evident. However, it doesn't differentiate from sibling tools like 'convert_format' or 'analyze_image', which might also involve image processing, so it's not fully specific to sibling context.

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 such as 'convert_format' for format changes or 'analyze_image' for analysis. It lacks any context about prerequisites, scenarios, or exclusions, leaving usage decisions unclear.

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