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:
- "Trim the YouTube video at https://youtube.com/watch?v=abc123 from 1:30 to 2:45"
- "Get information about this YouTube video: https://youtube.com/watch?v=xyz789"
- "Download the first 30 seconds of https://youtube.com/watch?v=example"
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, orHH: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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcfa913295f02b87c7025e301c97ffedd2171113de0cdb91f6991d2c63a1c197
|
|
| MD5 |
22ae66a86f418c67d1735cac30a534de
|
|
| BLAKE2b-256 |
1640ac4255595985b3febce2f42e82629f4205c64e378c5252f75e6e915f6244
|
Provenance
The following attestation bundles were made for youtube_trimmer_mcp-1.0.0.tar.gz:
Publisher:
publish-to-pypi.yml on manugomez95/YoutubeTrimmerMCP
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
youtube_trimmer_mcp-1.0.0.tar.gz -
Subject digest:
dcfa913295f02b87c7025e301c97ffedd2171113de0cdb91f6991d2c63a1c197 - Sigstore transparency entry: 230369465
- Sigstore integration time:
-
Permalink:
manugomez95/YoutubeTrimmerMCP@556f8e71d695c33985d2f047fbbeafbe6c1f95af -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/manugomez95
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@556f8e71d695c33985d2f047fbbeafbe6c1f95af -
Trigger Event:
release
-
Statement type:
File details
Details for the file youtube_trimmer_mcp-1.0.0-py3-none-any.whl.
File metadata
- Download URL: youtube_trimmer_mcp-1.0.0-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce9988d7b1a60723a30de22352be25d5fea12f46248e2418a5ca1bfc9ef2f38c
|
|
| MD5 |
3df3240aa2da42f359b0f25adfc97835
|
|
| BLAKE2b-256 |
caf2dd5d3076ffe4d205c5f278870729bb67ae15dff30f8b2ee614653f64f54d
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
youtube_trimmer_mcp-1.0.0-py3-none-any.whl -
Subject digest:
ce9988d7b1a60723a30de22352be25d5fea12f46248e2418a5ca1bfc9ef2f38c - Sigstore transparency entry: 230369466
- Sigstore integration time:
-
Permalink:
manugomez95/YoutubeTrimmerMCP@556f8e71d695c33985d2f047fbbeafbe6c1f95af -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/manugomez95
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@556f8e71d695c33985d2f047fbbeafbe6c1f95af -
Trigger Event:
release
-
Statement type: