Skip to main content
Glama
maoxiaoke

MCP Media Processing Server

by maoxiaoke

compress-video

Reduce video file size while maintaining quality by compressing videos using a customizable quality setting. Save output to a specified path or default folder with the MCP Media Processing Server.

Instructions

Compress video file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputPathYesAbsolute path to input video 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
qualityNoCompression quality (1-51, lower is better quality but larger file)

Implementation Reference

  • The handler function that implements the core logic for compressing a video file using fluent-ffmpeg with libx264 codec and CRF quality control.
    async ({ inputPath, quality, outputPath, outputFilename }) => {
      try {
        const absoluteInputPath = await getAbsolutePath(inputPath);
        const inputFileName = absoluteInputPath.split('/').pop()?.split('.')[0] || 'output';
        const defaultFilename = outputFilename || `${inputFileName}_compressed.mp4`;
        const finalOutputPath = await getOutputPath(outputPath, defaultFilename);
    
        const command = ffmpeg(absoluteInputPath)
          .videoCodec('libx264')
          .addOption('-crf', quality.toString())
          .save(finalOutputPath);
    
        await executeFFmpeg(command);
    
        return {
          content: [
            {
              type: "text",
              text: `Video successfully compressed and saved to: ${finalOutputPath}`,
            },
          ],
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: "text",
              text: `Error compressing video: ${errorMessage}`,
            },
          ],
        };
      }
    }
  • Zod schema defining the input parameters and validation for the compress-video tool.
    {
      inputPath: z.string().describe("Absolute path to input video file"),
      quality: z.number().min(1).max(51).default(23).describe("Compression quality (1-51, lower is better quality but larger file)"),
      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:181-224 (registration)
    The server.tool call that registers the compress-video tool with the MCP server, including name, description, schema, and handler.
    server.tool(
      "compress-video",
      "Compress video file",
      {
        inputPath: z.string().describe("Absolute path to input video file"),
        quality: z.number().min(1).max(51).default(23).describe("Compression quality (1-51, lower is better quality but larger file)"),
        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, quality, outputPath, outputFilename }) => {
        try {
          const absoluteInputPath = await getAbsolutePath(inputPath);
          const inputFileName = absoluteInputPath.split('/').pop()?.split('.')[0] || 'output';
          const defaultFilename = outputFilename || `${inputFileName}_compressed.mp4`;
          const finalOutputPath = await getOutputPath(outputPath, defaultFilename);
    
          const command = ffmpeg(absoluteInputPath)
            .videoCodec('libx264')
            .addOption('-crf', quality.toString())
            .save(finalOutputPath);
    
          await executeFFmpeg(command);
    
          return {
            content: [
              {
                type: "text",
                text: `Video successfully compressed and saved to: ${finalOutputPath}`,
              },
            ],
          };
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : String(error);
          return {
            content: [
              {
                type: "text",
                text: `Error compressing video: ${errorMessage}`,
              },
            ],
          };
        }
      }
    );
  • Utility function to execute FFmpeg commands as a Promise, used by compress-video and other video processing tools.
    const executeFFmpeg = (command: any): Promise<void> => {
      return new Promise((resolve, reject) => {
        command
          .on('end', () => resolve())
          .on('error', (err: Error) => reject(err))
          .run();
      });
    };
  • Helper to resolve relative input paths to absolute paths and verify file existence, used in compress-video.
    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?

With no annotations provided, the description carries full burden for behavioral disclosure. 'Compress video file' implies a mutation operation that creates a new file, but it doesn't specify whether the original file is modified, what formats are supported, error handling, or performance characteristics. This is a significant gap for a tool with destructive potential.

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 maximally concise with just three words that directly convey the core functionality. There's zero wasted language, and it's perfectly front-loaded with the essential information.

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 video compression tool with no annotations and no output schema, the description is insufficient. It doesn't address what compression algorithm is used, supported formats, whether the operation is lossy/lossless, expected output characteristics, or error conditions. The agent would need to guess about important behavioral aspects.

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 adds no parameter information beyond what's already in the schema, which has 100% coverage with clear descriptions for all 4 parameters. The baseline score of 3 reflects adequate schema documentation, but the description doesn't enhance understanding of parameter relationships or practical usage.

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 'Compress video file' clearly states the verb ('compress') and resource ('video file'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'trim-video' or 'convert-video' that also operate on video files, which prevents a perfect score.

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 like 'trim-video' or 'convert-video'. There's no mention of prerequisites, use cases, or exclusions, leaving the agent to infer usage from the tool name alone.

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