Skip to main content
Glama
maoxiaoke

MCP Media Processing Server

by maoxiaoke

convert-video

Transform video files into various formats using the MCP Media Processing Server. Specify input path, desired format, and optional output details for efficient conversion.

Instructions

Convert video to different format

Input Schema

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

Implementation Reference

  • Handler function that converts video to specified format using fluent-ffmpeg. Resolves paths, sets output, executes FFmpeg, handles errors.
    },
    async ({ inputPath, outputFormat, outputPath, outputFilename }) => {
      try {
        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 = ffmpeg(absoluteInputPath)
          .toFormat(outputFormat)
          .save(finalOutputPath);
    
        await executeFFmpeg(command);
    
        return {
          content: [
            {
              type: "text",
              text: `Video successfully converted and saved to: ${finalOutputPath}`,
            },
          ],
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: "text",
              text: `Error converting video: ${errorMessage}`,
            },
          ],
        };
      }
    }
  • Zod schema defining input parameters for the convert-video tool.
    {
      inputPath: z.string().describe("Absolute path to input video file"),
      outputFormat: z.string().describe("Desired output format (e.g., mp4, mkv, avi)"),
      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:137-179 (registration)
    Registration of the 'convert-video' tool using server.tool() with name, description, schema, and handler.
    server.tool(
      "convert-video",
      "Convert video to different format",
      {
        inputPath: z.string().describe("Absolute path to input video file"),
        outputFormat: z.string().describe("Desired output format (e.g., mp4, mkv, avi)"),
        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 {
          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 = ffmpeg(absoluteInputPath)
            .toFormat(outputFormat)
            .save(finalOutputPath);
    
          await executeFFmpeg(command);
    
          return {
            content: [
              {
                type: "text",
                text: `Video successfully converted and saved to: ${finalOutputPath}`,
              },
            ],
          };
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : String(error);
          return {
            content: [
              {
                type: "text",
                text: `Error converting video: ${errorMessage}`,
              },
            ],
          };
        }
      }
    );
  • Helper function to execute FFmpeg commands asynchronously, used by convert-video.
    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 input path to absolute path and check existence, used in convert-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 but offers minimal behavioral insight. It mentions conversion but doesn't disclose performance characteristics (e.g., processing time, resource usage), error conditions, or what happens to the original file. For a tool that likely involves file I/O and processing, this is inadequate.

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?

Extremely concise with a single sentence that directly states the tool's purpose. No wasted words or unnecessary elaboration, making it easy to parse quickly.

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 conversion tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns, potential side effects, or how it interacts with sibling tools. The agent would need to infer too much from minimal information.

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 parameters are well-documented in the schema. The description adds no additional parameter context beyond implying format conversion, which is already covered by the 'outputFormat' parameter description. Baseline 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.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Convert video to different format' states the basic action (convert) and resource (video), but it's vague about scope and doesn't distinguish from sibling tools like 'convert-image' or 'trim-video'. It lacks specificity about what conversion entails beyond format change.

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 on when to use this tool versus alternatives like 'compress-video', 'trim-video', or 'execute-ffmpeg'. The description provides no context about use cases, prerequisites, or exclusions, leaving the agent to guess based on tool names 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