Skip to main content
Glama
maoxiaoke

MCP Media Processing Server

by maoxiaoke

execute-ffmpeg

Process video files using custom FFmpeg commands on the MCP Media Processing Server. Specify input paths, output paths, and FFmpeg options to manage conversions, compressions, and edits efficiently.

Instructions

Execute any FFmpeg command with custom options

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputPathYesAbsolute path to input video file
optionsYesArray of FFmpeg command options (e.g. ['-c:v', 'libx264', '-crf', '23'])
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

  • The main handler function for the 'execute-ffmpeg' tool. It resolves input and output paths, constructs an FFmpeg command using fluent-ffmpeg with provided options, executes it, and returns success or error message.
    async ({ inputPath, outputPath, outputFilename, options }) => {
      try {
        const absoluteInputPath = await getAbsolutePath(inputPath);
        const finalOutputPath = await getOutputPath(outputPath, outputFilename || 'output.mp4');
    
        let command = ffmpeg(absoluteInputPath);
        
        // Add all options in pairs
        for (let i = 0; i < options.length; i += 2) {
          if (i + 1 < options.length) {
            command = command.addOption(options[i], options[i + 1]);
          }
        }
    
        command.save(finalOutputPath);
        await executeFFmpeg(command);
    
        return {
          content: [
            {
              type: "text",
              text: `Video processing completed successfully. Output saved to: ${finalOutputPath}`,
            },
          ],
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: "text",
              text: `Error processing video: ${errorMessage}`,
            },
          ],
        };
      }
    }
  • Zod schema defining the input parameters for the 'execute-ffmpeg' tool: inputPath (required), outputPath and outputFilename (optional), and options array.
    {
      inputPath: z.string().describe("Absolute path to input video 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)"),
      options: z.array(z.string()).describe("Array of FFmpeg command options (e.g. ['-c:v', 'libx264', '-crf', '23'])")
    },
  • src/index.ts:89-91 (registration)
    Registration of the 'execute-ffmpeg' tool using McpServer.tool() method, specifying the tool name and description.
    server.tool(
      "execute-ffmpeg",
      "Execute any FFmpeg command with custom options",
  • Helper function that wraps fluent-ffmpeg command execution in a Promise, resolving on 'end' event and rejecting on 'error'.
    const executeFFmpeg = (command: any): Promise<void> => {
      return new Promise((resolve, reject) => {
        command
          .on('end', () => resolve())
          .on('error', (err: Error) => reject(err))
          .run();
      });
    };
  • Helper function to convert relative input paths to absolute paths and verify file existence.
    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 the full burden of behavioral disclosure. It states 'Execute any FFmpeg command' but doesn't mention critical aspects like required permissions, whether it's read-only or destructive, error handling, rate limits, or what happens to the input file. For a powerful execution tool with zero annotation coverage, this is a significant gap.

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 purpose without any fluff. It's appropriately sized and front-loaded, with every word earning its place.

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 executing arbitrary FFmpeg commands, no annotations, and no output schema, the description is incomplete. It doesn't address safety concerns, error conditions, output behavior, or how it differs from specialized siblings. For a general-purpose execution tool in this context, more guidance is needed.

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%, so the schema already documents all four parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain FFmpeg option syntax beyond the schema's example). 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 'Execute' and the resource 'FFmpeg command with custom options', making the purpose understandable. However, it doesn't distinguish this general-purpose FFmpeg execution tool from its more specialized siblings like 'compress-video' or 'convert-video', which would require explicit differentiation to earn a 5.

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 the more specific sibling tools (e.g., compress-video, convert-video, trim-video). It lacks any context about alternatives, 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