What is A Model Context Protocol (MCP) server for YouTube operations, demonstrating core MCP concepts including tools and logging.?
MCP YouTube Extract is a fully functional MCP server that allows users to extract information from YouTube videos, including metadata and transcripts. It features comprehensive logging, robust error handling, and built-in YouTube API capabilities for extracting video information and transcripts.
Documentation
MCP YouTube Extract
A Model Context Protocol (MCP) server for YouTube operations, demonstrating core MCP concepts including tools and logging.
Features
MCP Server: A fully functional MCP server with:
Tools: Extract information from YouTube videos including metadata and transcripts
Comprehensive Logging: Detailed logging throughout the application
Error Handling: Robust error handling with fallback logic for transcripts
YouTube Integration: Built-in YouTube API capabilities:
Extract video information (title, description, channel, publish date)
Get video transcripts with intelligent fallback logic
Support for both manually created and auto-generated transcripts
📦 Available on PyPI
This package is now available on PyPI! You can install it directly with:
The easiest way to get started is to install from PyPI:
pip install mcp-youtube-extract
Or using pipx (recommended for command-line tools):
pipx install mcp-youtube-extract
This will install the latest version with all dependencies. You can then run the MCP server directly:
mcp_youtube_extract
Using uv (Development)
For development or if you prefer uv:
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone and install the project
git clone https://github.com/sinjab/mcp_youtube_extract.git
cd mcp_youtube_extract
# Install dependencies (including dev dependencies)
uv sync --dev
# Set up your API key for development
cp .env.example .env\n\n# Edit .env and add your YouTube API key
From source
Clone the repository:
git clone https://github.com/sinjab/mcp_youtube_extract.git
cd mcp_youtube_extract
Install in development mode:
uv sync --dev
Configuration# Environment Variables
For development, create a .env file in the project root with your YouTube API key:
YOUTUBE_API_KEY=your_youtube_api_key_here
For production, set the environment variable directly in your system:
export YOUTUBE_API_KEY=your_youtube_api_key_here
Required:
YOUTUBE_API_KEY: Your YouTube Data API key (required for video metadata)
Getting Your YouTube API Key
To use this MCP server, you'll need a YouTube Data API key. Here's how to get one:
Note: YouTube Data API has a free tier of 10,000 units per day, which is typically sufficient for most use cases
API Key Usage Limits
Free Tier: 10,000 units per day
Cost: $5 per 1,000 units after free tier
Typical Usage:
Getting video info: ~1 unit per request
Getting transcripts: ~1 unit per request
Most users stay well within the free tier
Security Best Practices
Never commit your API key to version control
Use environment variables as shown in the configuration section
Restrict your API key to only the YouTube Data API
Monitor usage in the Google Cloud Console
Usage# Running the MCP Server
Using PyPI Installation (Recommended)
pip install mcp-youtube-extract
# Run the server
mcp_youtube_extract
Using Development Setup
uv run mcp_youtube_extract
# Or directly
python -m mcp_youtube_extract.server
Running Tests
uv run pytest
# Run specific pytest test
uv run pytest tests/test_with_api_key.py
# Run tests with coverage
uv run pytest --cov=src/mcp_youtube_extract --cov-report=term-missing
Note: The tests/ directory contains 4 files:
test_context_fix.py - Pytest test for context API fallback functionality
test_with_api_key.py - Pytest test for full functionality with API key
test_youtube_unit.py - Unit tests for core YouTube functionality
test_inspector.py - Standalone inspection script (not a pytest test)
Test Coverage: The project currently has 62% overall coverage with excellent coverage of core functionality: