Skip to main content

Download and trim YouTube videos with MCP (Model Context Protocol) server support

Project description

YouTube Trimmer

A command-line tool that downloads YouTube videos, trims them to a specific timeframe, and saves the clip. Now with MCP (Model Context Protocol) server support for natural language interaction!

Features

  • 📺 Download and trim YouTube videos to specific timeframes
  • ⚡ Fast, lossless trimming using FFmpeg (no re-encoding)
  • 🤖 MCP Server for natural language interaction
  • 📊 Get video information without downloading
  • 🔧 Both CLI and programmatic interfaces

Prerequisites

Dependency Purpose Installation (Ubuntu) Installation (macOS) Installation (Windows)
Python ≥ 3.8 Runtime sudo apt install python3 brew install python Download from python.org
FFmpeg Video trimming sudo apt install ffmpeg brew install ffmpeg Download the static build and add to PATH

Installation

🚀 Super Easy Installation (Recommended)

The easiest way to install is directly from PyPI:

# Install the complete package with MCP support
pip install youtube-trimmer-mcp

That's it! The package will be available globally with all dependencies.

Alternative Installation Methods

From Source (Development)

# Clone the repository
git clone https://github.com/manuelgomez/youtube-trimmer-mcp.git
cd youtube-trimmer-mcp

# Install in development mode
pip install -e ".[dev]"

Using pipx (Isolated Installation)

# Install in isolated environment (recommended for CLI tools)
pipx install youtube-trimmer-mcp

Usage

1. Command Line Interface

Trim a video:

youtube-trimmer trim <youtube_url> -s <start_time> -e <end_time> [-o output.mp4] [--keep-temp]

Get video information:

youtube-trimmer info <youtube_url>

Start MCP server:

youtube-trimmer mcp-server

2. MCP Server (NEW!) 🚀

The YouTube Trimmer now supports the Model Context Protocol, allowing you to trim videos using natural language through any MCP-compatible client!

Starting the MCP Server

# Using the CLI command
youtube-trimmer mcp-server

# Or using the direct entry point
youtube-trimmer-mcp

MCP Client Configuration

Add this to your MCP client configuration (e.g., in Claude Desktop):

{
  "mcpServers": {
    "youtube-trimmer": {
      "command": "youtube-trimmer-mcp",
      "args": [],
      "env": {}
    }
  }
}

Alternative configuration using the module:

{
  "mcpServers": {
    "youtube-trimmer": {
      "command": "python",
      "args": ["-m", "youtube_trimmer.mcp_server"],
      "env": {}
    }
  }
}

MCP Tools Available

  • trim_youtube_video: Download and trim YouTube videos
  • get_youtube_video_info: Get video information without downloading
  • convert_timestamp_to_seconds: Convert timestamps to seconds
  • download_full_youtube_video: Download complete videos

Arguments and Options:

  • <youtube_url>: Any normal or shortened YouTube link
  • -s, --start: Start timestamp (HH:MM:SS[.ms] format)
  • -e, --end: End timestamp (HH:MM:SS[.ms] format)
  • -o, --output: Output filename (auto-generated if not provided)
  • --keep-temp: Keep the full downloaded file
  • --quiet: Suppress most output

Examples:

CLI Examples:

# Trim from 1 minute to 2 minutes
youtube-trimmer trim "https://www.youtube.com/watch?v=dQw4w9WgXcQ" -s 1:00 -e 2:00

# Get video information
youtube-trimmer info "https://www.youtube.com/watch?v=dQw4w9WgXcQ"

# Custom output filename
youtube-trimmer trim "https://www.youtube.com/watch?v=dQw4w9WgXcQ" -s 1:00 -e 2:00 -o my_clip.mp4

MCP Natural Language Examples:

With the MCP server running, you can use natural language:

Project Structure

YotubeTrimmer/
├─ src/
│  └─ youtube_trimmer/
│     ├─ __init__.py          # Package initialization
│     ├─ core.py              # Core trimming functionality  
│     ├─ cli.py               # Command-line interface
│     └─ mcp_server.py        # MCP server for natural language
├─ setup.py                   # Package setup
├─ pyproject.toml            # Modern Python packaging
├─ requirements.txt          # Dependencies
└─ README.md                 # This file

Development

Running Tests

# Install in development mode
pip install -e ".[mcp]"

# Test the CLI
youtube-trimmer trim "https://www.youtube.com/watch?v=jNQXAC9IVRw" -s 0:00 -e 0:05

# Test the MCP server
youtube-trimmer mcp-server

Notes

  • Timestamp formats: SS, MM:SS, or HH:MM:SS[.ms]
  • Uses FFmpeg's copy mode (fast and lossless)
  • Auto-generates output filenames from video title and timestamps
  • MCP server runs on stdio for seamless integration

Legal Notice

Downloading YouTube videos may violate YouTube's Terms of Service. This tool is for educational purposes only. Users are responsible for how they use this software.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

youtube_trimmer_mcp-1.0.3.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

youtube_trimmer_mcp-1.0.3-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file youtube_trimmer_mcp-1.0.3.tar.gz.

File metadata

  • Download URL: youtube_trimmer_mcp-1.0.3.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for youtube_trimmer_mcp-1.0.3.tar.gz
Algorithm Hash digest
SHA256 02d8ea77a867f6b555ee0b1e38e251059111d6738ddaa3999e5b7494aa40caa6
MD5 59f4da8e0e9cd3d6601d0c33605c9b7b
BLAKE2b-256 afb4945ae01d6ec2d892cef1f8f52f566f8280be4b82e5537b3ee81993d6e91d

See more details on using hashes here.

Provenance

The following attestation bundles were made for youtube_trimmer_mcp-1.0.3.tar.gz:

Publisher: publish-to-pypi.yml on manugomez95/YoutubeTrimmerMCP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file youtube_trimmer_mcp-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for youtube_trimmer_mcp-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d7629e094658f28a3e159be7e66c51fa9ff75c0b5e4f2b0e3574f6b5d14ee716
MD5 589c23688dea7d4de94f462d26113ac6
BLAKE2b-256 8c48fdf7ac3e224c36a92301cbbb10ce31663fc488b7d7140e79de8d6295c341

See more details on using hashes here.

Provenance

The following attestation bundles were made for youtube_trimmer_mcp-1.0.3-py3-none-any.whl:

Publisher: publish-to-pypi.yml on manugomez95/YoutubeTrimmerMCP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page