Skip to main content
Glama

trim_video

Cut video clips to specific start and end times or durations using FFmpeg processing. Specify input/output paths and timing parameters to extract segments.

Instructions

Trim a video to a specific duration

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputPathYesPath to the input video file
outputPathYesPath for the output video file
startTimeNoStart time (format: HH:MM:SS.mmm or seconds)
durationNoDuration (format: HH:MM:SS.mmm or seconds)
endTimeNoEnd time (format: HH:MM:SS.mmm or seconds)

Implementation Reference

  • Main execution logic for trim_video tool: validates input/output paths, handles startTime, duration or endTime, builds FFmpeg command with stream copy (-c copy) for efficient trimming without re-encoding, executes via runFFmpegCommand, and returns completion message.
    case "trim_video": {
      const inputPath = validatePath(String(args?.inputPath), true);
      const outputPath = validatePath(String(args?.outputPath));
      const startTime = String(args?.startTime || "0");
      const duration = String(args?.duration || "");
      const endTime = String(args?.endTime || "");
      
      await ensureDirectoryExists(outputPath);
      
      let command = `-i "${inputPath}" -ss ${startTime}`;
      if (duration) {
        command += ` -t ${duration}`;
      } else if (endTime) {
        command += ` -to ${endTime}`;
      }
      command += ` -c copy "${outputPath}" -y`;
      
      const result = await runFFmpegCommand(command);
      
      return {
        content: [{
          type: "text",
          text: `Video trimming completed: ${inputPath} → ${outputPath}\n\n${result}`
        }]
      };
    }
  • Tool schema definition: name, description, and inputSchema specifying properties for inputPath (required), outputPath (required), and optional startTime, duration, endTime as strings.
    {
      name: "trim_video",
      description: "Trim a video to a specific duration",
      inputSchema: {
        type: "object",
        properties: {
          inputPath: {
            type: "string",
            description: "Path to the input video file"
          },
          outputPath: {
            type: "string",
            description: "Path for the output video file"
          },
          startTime: {
            type: "string",
            description: "Start time (format: HH:MM:SS.mmm or seconds)"
          },
          duration: {
            type: "string",
            description: "Duration (format: HH:MM:SS.mmm or seconds)"
          },
          endTime: {
            type: "string",
            description: "End time (format: HH:MM:SS.mmm or seconds)"
          }
        },
        required: ["inputPath", "outputPath"]
      }
    },
  • src/index.ts:46-50 (registration)
    Registers trim_video tool schema by including it in the toolDefinitions array returned for ListToolsRequest.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: toolDefinitions
      };
    });
  • src/index.ts:56-68 (registration)
    Registers the general tool call handler that dispatches 'trim_video' calls to the specific handleToolCall implementation in handlers.ts.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      try {
        return await handleToolCall(request.params.name, request.params.arguments);
      } catch (error: any) {
        console.error("Tool execution error:", error.message);
        return {
          content: [{
            type: "text",
            text: `Error: ${error.message}`
          }]
        };
      }
    });
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. It states the tool trims videos but doesn't mention whether this is a destructive operation, what permissions are needed, file format limitations, or error conditions. For a mutation tool with zero annotation coverage, 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?

The description is a single, efficient sentence that gets straight to the point with no wasted words. It's appropriately sized for a straightforward tool and front-loads the core functionality.

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 editing tool with 5 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns, error handling, format requirements, or how it differs from similar tools. The agent would struggle to use this effectively without additional context.

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 the schema already documents all 5 parameters thoroughly. The description adds no additional parameter information beyond what's in the schema, but doesn't need to compensate for gaps. This meets the baseline for high schema coverage.

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 'Trim a video to a specific duration' clearly states the action (trim) and resource (video), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'trim_audio' or 'extract_frames', which would require more specificity about video-only focus.

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 'extract_frames' or 'trim_audio'. It doesn't mention prerequisites, constraints, or typical use cases, leaving the agent with minimal 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

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/sworddut/mcp-ffmpeg-helper'

If you have feedback or need assistance with the MCP directory API, please join our Discord server