Skip to main content
Glama
maoxiaoke

MCP Media Processing Server

by maoxiaoke

rotate-image

Rotate an image by a specified angle in degrees using the MCP Media Processing Server. Input the image path and rotation angle, and optionally set an output path or filename for the rotated image.

Instructions

Rotate image by specified degrees

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
degreesYesRotation angle in degrees
inputPathYesAbsolute path to input image file
outputFilenameNoOutput filename (only used if outputPath is not provided)
outputPathNoOptional absolute path for output file. If not provided, file will be saved in Downloads folder

Implementation Reference

  • Executes image rotation using ImageMagick 'convert' command with -rotate option. Handles path resolution, output path generation, command execution, and error handling.
    async ({ inputPath, degrees, outputPath, outputFilename }) => {
      try {
        await checkImageMagick();
        const absoluteInputPath = await getAbsolutePath(inputPath);
        const inputFileName = absoluteInputPath.split('/').pop()?.split('.')[0] || 'output';
        const extension = absoluteInputPath.split('.').pop() || 'png';
        const defaultFilename = outputFilename || `${inputFileName}_rotated.${extension}`;
        const finalOutputPath = await getOutputPath(outputPath, defaultFilename);
    
        const command = `convert "${absoluteInputPath}" -rotate ${degrees} "${finalOutputPath}"`;
        await execSync(command);
    
        return {
          content: [
            {
              type: "text",
              text: `Image successfully rotated and saved to: ${finalOutputPath}`,
            },
          ],
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: "text",
              text: `Error rotating image: ${errorMessage}`,
            },
          ],
        };
      }
    }
  • Zod schema defining input parameters for the rotate-image tool: inputPath, degrees, optional outputPath and outputFilename.
    {
      inputPath: z.string().describe("Absolute path to input image file"),
      degrees: z.number().describe("Rotation angle in degrees"),
      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:421-462 (registration)
    Registers the 'rotate-image' tool with the MCP server, providing name, description, input schema, and handler function.
    server.tool(
      "rotate-image",
      "Rotate image by specified degrees",
      {
        inputPath: z.string().describe("Absolute path to input image file"),
        degrees: z.number().describe("Rotation angle in degrees"),
        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, degrees, outputPath, outputFilename }) => {
        try {
          await checkImageMagick();
          const absoluteInputPath = await getAbsolutePath(inputPath);
          const inputFileName = absoluteInputPath.split('/').pop()?.split('.')[0] || 'output';
          const extension = absoluteInputPath.split('.').pop() || 'png';
          const defaultFilename = outputFilename || `${inputFileName}_rotated.${extension}`;
          const finalOutputPath = await getOutputPath(outputPath, defaultFilename);
    
          const command = `convert "${absoluteInputPath}" -rotate ${degrees} "${finalOutputPath}"`;
          await execSync(command);
    
          return {
            content: [
              {
                type: "text",
                text: `Image successfully rotated and saved to: ${finalOutputPath}`,
              },
            ],
          };
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : String(error);
          return {
            content: [
              {
                type: "text",
                text: `Error rotating image: ${errorMessage}`,
              },
            ],
          };
        }
      }
    );
  • Helper function to verify ImageMagick installation by executing 'convert -version'.
    async function checkImageMagick() {
      try {
        execSync('convert -version');
        return true;
      } catch (error) {
        throw new Error('ImageMagick is not installed. Please install it first.');
      }
    }
  • Helper to resolve relative input paths to absolute paths using process.cwd() and verify file accessibility.
    async function getAbsolutePath(inputPath: string): Promise<string> {
      if (isAbsolute(inputPath)) {
        return inputPath;
      }
      
      // FIXME: But it's not working, because the server is running in a different directory
      const absolutePath = resolve(process.cwd(), inputPath);
      
      try {
        await fs.access(absolutePath);
        return absolutePath;
      } catch (error) {
        throw new Error(`Input file not found: ${inputPath}`);
      }
    }
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 action ('rotate') but doesn't mention critical details like whether the operation modifies the original file, creates a new file, requires specific permissions, or has performance implications. This is inadequate for a mutation tool with zero annotation coverage.

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 with just one sentence ('Rotate image by specified degrees'), which is front-loaded and wastes no words. Every part of the sentence contributes to understanding the tool's purpose, making it efficient and well-structured.

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 an image manipulation tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like file handling, error conditions, or output details, leaving significant gaps for the agent to infer or guess.

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 description doesn't add any parameter semantics beyond what's already in the input schema, which has 100% coverage. It mentions 'specified degrees' but doesn't explain rotation direction, valid ranges, or how parameters interact. With high schema coverage, the baseline is 3, as 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 tool's purpose with a specific verb ('rotate') and resource ('image'), making it easy to understand what the tool does. However, it doesn't differentiate from sibling tools like 'convert-image' or 'resize-image' which might also involve image manipulation, so it doesn't fully distinguish from alternatives.

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 sibling tools like 'resize-image' or 'convert-image', nor does it specify scenarios where rotation is appropriate over other image operations. This leaves the agent without context for tool selection.

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