Enables comprehensive extraction and analysis of YouTube data including video metadata, channel statistics, playlist details, comments, transcripts, search functionality, trending videos, and engagement metrics analysis using yt-dlp.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@YouTube MCP Server Enhancedget video info for https://youtube.com/watch?v=dQw4w9WgXcQ"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
YouTube MCP Server Enhanced π
A comprehensive Micro-Conversational Processor (MCP) server for extracting and analyzing YouTube data using yt-dlp.
π Features
Core Extraction
Video Information: Metadata, statistics, engagement metrics
Channel Information: Stats, subscriber count, view count, verification status
Playlist Details: Video lists, durations, total views
Comments: Threaded comments with replies and engagement
Transcripts: Auto-generated and manual subtitles
Advanced Capabilities
YouTube Search: Search for videos, channels, and playlists
Trending Videos: Get trending content by region
Batch Processing: Extract from multiple URLs concurrently
Intelligent Caching: Configurable TTL-based caching
Automatic Retries: Exponential backoff for failed requests
Health Monitoring: Real-time extractor status and configuration
π οΈ Installation
Prerequisites
Python 3.10+
uv (required)
yt-dlp(automatically installed via uv)
β οΈ Important: This project requires
# Install uv (macOS/Linux)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or via Homebrew (macOS)
brew install uv
# Or via pip
pip install uvSetup
# Clone the repository
git clone <repository-url>
cd youtube-mcp-server-enhanced
# Install yt-dlp and all dependencies
uv add yt-dlp
uv sync
# Verify installation
uv run yt-dlp --versionβοΈ Configuration
Environment Variables (.env file)
Create a .env file in the project root to configure the server:
# Copy the example file
cp .env.example .env
# Edit with your preferred settings
nano .envExample .env configuration:
# Rate limiting (e.g., "500K" for 500KB/s, "1M" for 1MB/s)
YOUTUBE_RATE_LIMIT=500K
# Retry configuration
YOUTUBE_MAX_RETRIES=5
YOUTUBE_RETRY_DELAY=2.0
YOUTUBE_TIMEOUT=600
# Caching
YOUTUBE_ENABLE_CACHE=true
YOUTUBE_CACHE_TTL=3600
# Logging level
LOG_LEVEL=INFOMCP Client Configuration
Claude Desktop (macOS)
Add to your ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"youtube-mcp-server": {
"command": "uv",
"args": [
"run",
"--directory",
"/path/to/youtube-mcp-server-enhanced",
"python",
"-m",
"src.youtube_mcp_server.server"
],
"env": {
"YOUTUBE_RATE_LIMIT": "500K",
"YOUTUBE_MAX_RETRIES": "5",
"YOUTUBE_RETRY_DELAY": "2.0",
"YOUTUBE_TIMEOUT": "600",
"YOUTUBE_ENABLE_CACHE": "true",
"YOUTUBE_CACHE_TTL": "3600"
}
}
}
}Other MCP Clients
For other MCP clients, configure the server command as:
uv run --directory /path/to/youtube-mcp-server-enhanced python -m src.youtube_mcp_server.serverDefault Values
Rate Limit: None (uses YouTube's default)
Max Retries: 5 (increased from 3 for better reliability)
Retry Delay: 2.0 seconds (with exponential backoff)
Timeout: 600 seconds (10 minutes)
Cache TTL: 3600 seconds (1 hour)
Cache: Enabled by default
π― Available MCP Tools
Data Extraction
Tool | Description | Example |
| Extract comprehensive video metadata |
|
| Extract channel information and stats (supports multiple URL formats) |
|
| Extract playlist details and video list |
|
| Extract video comments and replies |
|
| Extract video transcripts/subtitles |
|
Search & Discovery
Tool | Description | Example |
| Search for videos, channels, or playlists |
|
| Get trending videos by region |
|
Analysis & Insights
Tool | Description | Example |
| Analyze engagement metrics with benchmarks |
|
| Search for text within video transcripts |
|
Batch Operations
Tool | Description | Example |
| Process multiple URLs concurrently |
|
System Management
Tool | Description | Example |
| Monitor extractor health and status |
|
| View current configuration |
|
| Clear all cached data |
|
MCP Prompts
Prompt | Description | Example |
| Comprehensive video analysis with optional comments/transcript |
|
| Compare engagement metrics across multiple videos |
|
π Data Models
VideoInfo
{
"metadata": {
"id": "video_id",
"title": "Video Title",
"description": "Video description...",
"uploader": "Channel Name",
"uploader_id": "channel_id",
"upload_date": "20240101",
"tags": ["tag1", "tag2"],
"categories": ["Entertainment"],
"thumbnail": "https://..."
},
"statistics": {
"view_count": 1000,
"like_count": 50,
"comment_count": 25,
"duration_seconds": 120,
"duration_string": "2:00"
},
"engagement": {
"like_to_view_ratio": 0.05,
"comment_to_view_ratio": 0.025,
"like_rate_percentage": "5.000%",
"comment_rate_percentage": "2.500%"
},
"technical": {
"age_limit": 0,
"availability": "public",
"live_status": "not_live"
}
}ChannelInfo
{
"id": "channel_id",
"name": "Channel Name",
"url": "https://youtube.com/@channel",
"description": "Channel description...",
"avatar_url": "https://...",
"banner_url": "https://...",
"verified": true,
"country": "US",
"language": "en",
"tags": ["tag1", "tag2"],
"statistics": {
"subscriber_count": 10000,
"video_count": 150,
"view_count": 500000
}
}PlaylistInfo
{
"id": "playlist_id",
"title": "Playlist Title",
"description": "Playlist description...",
"uploader": "Channel Name",
"uploader_id": "channel_id",
"video_count": 25,
"total_duration_seconds": 7200,
"total_duration_formatted": "2h 0m",
"total_views": 50000,
"videos": [
{
"video_id": "video_id",
"title": "Video Title",
"uploader": "Channel Name",
"duration": 300,
"view_count": 2000,
"playlist_index": 1
}
]
}π Usage Examples
Basic Video Analysis
# Get comprehensive video information
video_info = await get_video_info("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
# Extract video comments
comments = await get_video_comments("https://www.youtube.com/watch?v=dQw4w9WgXcQ", max_comments=50)
# Get video transcript
transcript = await get_video_transcript("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
# Search within transcript
results = await search_transcript("https://www.youtube.com/watch?v=dQw4w9WgXcQ", "never gonna")Channel and Playlist Analysis
# Get channel information
channel_info = await get_channel_info("https://www.youtube.com/@RickAstleyYT")
# Get playlist details
playlist_info = await get_playlist_info("https://www.youtube.com/playlist?list=...")Search and Discovery
# Search for videos
results = await search_youtube("Python programming tutorials", "video", 10)
# Get trending videos
trending = await get_trending_videos("US", 20)Advanced Analysis
# Analyze video engagement with benchmarks
engagement = await analyze_video_engagement("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
# Compare multiple videos
comparison = await compare_videos([
"https://youtube.com/watch?v=video1",
"https://youtube.com/watch?v=video2"
])Batch Processing
# Process multiple URLs concurrently
results = await batch_extract_urls([
"https://youtube.com/watch?v=video1",
"https://youtube.com/watch?v=video2"
], "video")β‘ Performance Features
Caching
In-Memory Cache: Configurable TTL-based caching
Cache Keys: Unique keys for each request type and parameters
Cache Management: View stats, clear cache, configure TTL
Retry Logic
Automatic Retries: Configurable retry attempts
Exponential Backoff: Increasing delay between retries
Error Handling: Graceful degradation on failures
Batch Processing
Concurrent Extraction: Process multiple URLs simultaneously using asyncio
Async Operations: Non-blocking I/O for better performance
Result Aggregation: Combined results with success/failure counts
π₯ Health Monitoring
Health Status
health = await get_extractor_health()
# Returns:
{
"health": {
"status": "healthy",
"yt_dlp_available": true,
"yt_dlp_version": "2025.6.30",
"cache": {"enabled": true, "size": 5, "ttl": 3600},
"config": {"rate_limit": "1M", "max_retries": 3, "timeout": 300}
},
"cache": {
"enabled": true,
"size": 5,
"ttl": 3600,
"keys": ["key1", "key2"],
"total_keys": 5
},
"server_version": "0.1.0",
"mcp_version": "1.0.0"
}Configuration View
config = await get_extractor_config()
# Returns current extractor settings and statusπ¨ Error Handling
Retry Strategy
Automatic Retries: Up to 5 attempts by default (configurable)
Exponential Backoff: 2s, 4s, 8s delays
Rate Limiting: 500KB/s limit with 2-second sleep intervals
Graceful Degradation: Return partial results when possible
Error Types
YouTubeExtractorError: Extraction-specific errors
InvalidURLError: Invalid YouTube URL format
RuntimeError: General execution errors
Troubleshooting
Rate Limiting Issues
If you encounter rate limiting:
Increase sleep intervals in
.env:YOUTUBE_RETRY_DELAY=3.0Lower rate limit:
YOUTUBE_RATE_LIMIT=300KReduce concurrent requests
yt-dlp Not Working
Ensure uv is installed:
uv --versionVerify yt-dlp installation:
uv run yt-dlp --versionThe server automatically uses
uv run yt-dlpif direct access fails
MCP Connection Issues
Restart your MCP client after code changes
Check logs for specific error messages
Verify environment variables are loaded correctly
π§ Development
Running the Server
β οΈ Always use
# Start the MCP server (recommended)
uv run python -m src.youtube_mcp_server.server
# Or if you have a run_server.py file
uv run python run_server.pyTesting
# Run all tests
uv run pytest tests/
# Run specific test file
uv run pytest tests/test_basic.py
# Run with coverage
uv run pytest --cov=src tests/π Use Cases
Content Analysis
Video Performance: Analyze view counts, engagement metrics
Channel Growth: Track subscriber and view count trends
Content Discovery: Find trending and popular content
Research & Analytics
Market Research: Analyze competitor channels and content
Trend Analysis: Identify trending topics and content types
Audience Insights: Understand viewer preferences and behavior
Content Management
Playlist Organization: Manage and analyze video collections
Comment Moderation: Extract and analyze user feedback
Transcript Analysis: Process and search video content
π€ Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests for new functionality
Submit a pull request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
yt-dlp: The core YouTube extraction engine
FastMCP: The MCP server framework
Pydantic: Data validation and serialization
π Support
Issues: GitHub Issues
Discussions: GitHub Discussions
Email: info@labeveryday.com
πΊοΈ Roadmap
Batch processing for multiple videos
Caching layer for improved performance
Advanced analytics (engagement analysis, benchmarks)
Rate limiting and quota management
Export functionality (JSON, CSV, etc.)
WebSocket support for real-time updates
Integration examples with popular MCP clients
Made with β€οΈ by Du'An Lightfoot
Empowering developers to extract meaningful insights from YouTube content through the Model Context Protocol.