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.0.tar.gz (13.6 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.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: youtube_trimmer_mcp-1.0.0.tar.gz
  • Upload date:
  • Size: 13.6 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.0.tar.gz
Algorithm Hash digest
SHA256 dcfa913295f02b87c7025e301c97ffedd2171113de0cdb91f6991d2c63a1c197
MD5 22ae66a86f418c67d1735cac30a534de
BLAKE2b-256 1640ac4255595985b3febce2f42e82629f4205c64e378c5252f75e6e915f6244

See more details on using hashes here.

Provenance

The following attestation bundles were made for youtube_trimmer_mcp-1.0.0.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for youtube_trimmer_mcp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce9988d7b1a60723a30de22352be25d5fea12f46248e2418a5ca1bfc9ef2f38c
MD5 3df3240aa2da42f359b0f25adfc97835
BLAKE2b-256 caf2dd5d3076ffe4d205c5f278870729bb67ae15dff30f8b2ee614653f64f54d

See more details on using hashes here.

Provenance

The following attestation bundles were made for youtube_trimmer_mcp-1.0.0-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