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.
Metadata
Release files for youtube-trimmer-mcp 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| youtube_trimmer_mcp-1.0.3.tar.gz | 13.7 kB | With provenance | Details for youtube_trimmer_mcp-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| youtube_trimmer_mcp-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for youtube_trimmer_mcp-1.0.3-py3-none-any.whl |
Total release size: 25.3 kB
Release files / youtube_trimmer_mcp-1.0.3.tar.gz
| Download URL | youtube_trimmer_mcp-1.0.3.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
02d8ea77a867f6b555ee0b1e38e251059111d6738ddaa3999e5b7494aa40caa6
|
|
BLAKE2b-256 checksum How to use checksums |
afb4945ae01d6ec2d892cef1f8f52f566f8280be4b82e5537b3ee81993d6e91d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 5, 2025.
Transparency logRelease files / youtube_trimmer_mcp-1.0.3-py3-none-any.whl
| Download URL | youtube_trimmer_mcp-1.0.3-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d7629e094658f28a3e159be7e66c51fa9ff75c0b5e4f2b0e3574f6b5d14ee716
|
|
BLAKE2b-256 checksum How to use checksums |
8c48fdf7ac3e224c36a92301cbbb10ce31663fc488b7d7140e79de8d6295c341
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 5, 2025.
Transparency logSecurity for youtube-trimmer-mcp 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for youtube_trimmer_mcp-1.0.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 5, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.