Skip to main content
Glama
misbahsy

Video & Audio Editing MCP Server

by misbahsy

trim_video

Remove unwanted sections from a video by specifying exact start and end times, and save the trimmed output to a designated file path. Ideal for precise video editing.

Instructions

Trims a video to the specified start and end times.

Args: video_path: The path to the input video file. output_video_path: The path to save the trimmed video file. start_time: The start time for trimming (HH:MM:SS or seconds). end_time: The end time for trimming (HH:MM:SS or seconds). Returns: A status message indicating success or failure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
end_timeYes
output_video_pathYes
start_timeYes
video_pathYes

Implementation Reference

  • server.py:42-75 (handler)
    The main handler function for the 'trim_video' MCP tool. It uses FFmpeg to trim the video from start_time to end_time, first trying to copy codecs without re-encoding, falling back to re-encoding if necessary. Returns a success or error message.
    @mcp.tool()
    def trim_video(video_path: str, output_video_path: str, start_time: str, end_time: str) -> str:
        """Trims a video to the specified start and end times.
    
        Args:
            video_path: The path to the input video file.
            output_video_path: The path to save the trimmed video file.
            start_time: The start time for trimming (HH:MM:SS or seconds).
            end_time: The end time for trimming (HH:MM:SS or seconds).
        Returns:
            A status message indicating success or failure.
        """
        try:
            input_stream = ffmpeg.input(video_path, ss=start_time, to=end_time)
            # Attempt to copy codecs to avoid re-encoding if possible
            output_stream = input_stream.output(output_video_path, c='copy') 
            output_stream.run(capture_stdout=True, capture_stderr=True)
            return f"Video trimmed successfully (codec copy) to {output_video_path}"
        except ffmpeg.Error as e:
            error_message_copy = e.stderr.decode('utf8') if e.stderr else str(e)
            try:
                # Fallback to re-encoding if codec copy fails
                input_stream_recode = ffmpeg.input(video_path, ss=start_time, to=end_time)
                output_stream_recode = input_stream_recode.output(output_video_path)
                output_stream_recode.run(capture_stdout=True, capture_stderr=True)
                return f"Video trimmed successfully (re-encoded) to {output_video_path}"
            except ffmpeg.Error as e_recode:
                error_message_recode = e_recode.stderr.decode('utf8') if e_recode.stderr else str(e_recode)
                return f"Error trimming video. Copy attempt: {error_message_copy}. Re-encode attempt: {error_message_recode}"
        except FileNotFoundError:
            return f"Error: Input video file not found at {video_path}"
        except Exception as e:
            return f"An unexpected error occurred: {str(e)}"
  • server.py:42-42 (registration)
    The @mcp.tool() decorator registers the trim_video function as an MCP tool.
    @mcp.tool()
  • The function signature and docstring define the input schema (video_path, output_video_path, start_time, end_time as strings) and output (str status message).
    def trim_video(video_path: str, output_video_path: str, start_time: str, end_time: str) -> str:
        """Trims a video to the specified start and end times.
    
        Args:
            video_path: The path to the input video file.
            output_video_path: The path to save the trimmed video file.
            start_time: The start time for trimming (HH:MM:SS or seconds).
            end_time: The end time for trimming (HH:MM:SS or seconds).
        Returns:
            A status message indicating success or failure.
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 lacks critical behavioral details. It mentions a status message return but doesn't specify if the tool is destructive (e.g., overwrites output files), has performance implications, or requires specific permissions. This is inadequate for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (Args, Returns) and front-loaded purpose. It's appropriately sized, though the parameter explanations are slightly verbose; every sentence adds value, making it efficient overall.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 0% schema coverage, and no output schema, the description does a fair job by detailing parameters and return type. However, for a video processing tool with potential side effects, it lacks completeness in behavioral aspects like error handling or format constraints.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant value beyond the schema, which has 0% coverage. It explains each parameter's purpose (e.g., 'video_path: The path to the input video file') and provides format hints for time values ('HH:MM:SS or seconds'), compensating well for the schema's lack of descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

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

The description clearly states the specific action ('Trims a video') and the resource ('a video'), distinguishing it from sibling tools like 'change_video_speed' or 'concatenate_videos' by focusing on time-based trimming. It's precise and not a tautology of the tool name.

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 prerequisites (e.g., file existence, format compatibility) or compare it to siblings like 'remove_silence' for similar time-based operations, leaving usage context unclear.

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/misbahsy/video-audio-mcp'

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