MCP YouTube Extract

by sinjab

Not rated
GitHub

About

Extracts information from YouTube videos and channels using the YouTube Data API.

Details

Author
sinjab
Categories
Web Scraping, Other

Setup

Install MCP YouTube Extract in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/sinjab/mcp_youtube_extract

Follow the installation instructions in the repository README, then restart your MCP client.

A Model Context Protocol (MCP) server for YouTube operations, demonstrating core MCP concepts including tools and logging.

✨ No API Key Required!Works out of the box using yt-info-extract for video metadata and yt-ts-extract for transcripts.

- 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

- Extract video information (title, description, channel, publish date, view count)
- Get video transcripts with intelligent fallback logic
- Support for both manually created and auto-generated transcripts
- No API key required for basic functionality

This package is now available on PyPI! You can install it directly with:

Visit the package page:mcp-youtube-extract on PyPI

The easiest way to get started is to install from PyPI:

Or using pipx (recommended for command-line tools):

This will install the latest version with all dependencies. You can then run the MCP server directly:

# Install uv if you haven't already 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 # Edit .env and add your YouTube API key
git clone https://github.com/sinjab/mcp_youtube_extract.git cd mcp_youtube_extract

No configuration required!The server works out of the box using yt-info-extract for metadata extraction.

Optional:For enhanced functionality, you can optionally set a YouTube API key:

# Optional YouTube API Configuration YOUTUBE_API_KEY=your_youtube_api_key_here

- YOUTUBE_API_KEY: Your YouTube Data API key (optional, provides additional fallback for metadata extraction)

While not required, you can optionally set up a YouTube Data API key for enhanced functionality. Here's how to get one:
- Go to the
Google Cloud Console
- Click "Select a project" at the top of the page
- Click "New Project" and give it a name (e.g., "MCP YouTube Extract")
- Click "Create"
- In your new project, go to the
API Library
- Search for "YouTube Data API v3"
- Click on it and then click "Enable"
- Go to the
Credentials page
- Click "Create Credentials" and select "API Key"
- Your new API key will be displayed - copy it immediately
- Click "Restrict Key" to secure it (recommended)

Step 4: Restrict Your API Key (Recommended)

- In the API key settings, click "Restrict Key" - Under "API restrictions", select "Restrict key" - Choose "YouTube Data API v3" from the dropdown - Click "Save" - Go to the
Billing page - Link a billing account to your project - Note: YouTube Data API has a free tier of 10,000 units per day, which is typically sufficient for most use cases

- Free Tier: 10,000 units per day
- Cost: $5 per 1,000 units after free tier
- Note: API key is only used as a fallback when yt-info-extract fails
- Most users won't need an API key as yt-info-extract handles most requests

- Never commit your API keyto version control
- Use environment variablesas shown in the configuration section
- Restrict your API keyto only the YouTube Data API
- Monitor usagein the Google Cloud Console

# Install from PyPI pip install mcp-youtube-extract # Run the server mcp_youtube_extract
# Using uv uv run mcp_youtube_extract # Or directly python -m mcp_youtube_extract.server
# Run all pytest 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: Thetests/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 testsfor 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:

- youtube.py: 81% coverage (core business logic)
- logger.py: 73% coverage (logging utilities)
- server.py: 22% coverage (MCP protocol handling)
- __init__.py: 100% coverage (package initialization)

Thetest_inspector.pyfile is a standalone script that connects to the MCP server and validates its functionality:

# Run the inspection script to test server connectivity and functionality uv run python tests/test_inspector.py

- Connect to the MCP server
- List available tools, resources, and prompts
- Test theget_yt_video_infotool with a sample video
- Validate that the server is working correctly

The server provides one main tool:get_yt_video_info

This tool takes a YouTube video ID and returns:

- Video metadata (title, description, channel, publish date, view count) via yt-info-extract
- Video transcript (with fallback logic for different transcript types) via yt-ts-extract

# Extract video ID from YouTube URL: https://www.youtube.com/watch?v=dQw4w9WgXcQ video_id = "dQw4w9WgXcQ" result = get_yt_video_info(video_id)

To use this MCP server with a client, add the following configuration to your client's settings:

{ "mcpServers": { "mcp_youtube_extract": { "command": "mcp_youtube_extract" } } }
{ "mcpServers": { "mcp_youtube_extract": { "command": "mcp_youtube_extract", "env": { "YOUTUBE_API_KEY": "your_youtube_api_key" } } } }
{ "mcpServers": { "mcp_youtube_extract": { "command": "uv", "args": [ "--directory", "<your-project-directory>", "run", "mcp_youtube_extract" ] } } }
{ "mcpServers": { "mcp_youtube_extract": { "command": "uv", "args": [ "--directory", "<your-project-directory>", "run", "mcp_youtube_extract" ], "env": { "YOUTUBE_API_KEY": "your_youtube_api_key" } } } }
mcp_youtube_extract/ ├── src/ │ └── mcp_youtube_extract/ │ ├── __init__.py │ ├── server.py # MCP server implementation │ ├── google_api.py # yt-info-extract integration │ ├── transcript_api.py # yt-ts-extract integration │ ├── youtube.py # Unified API facade │ └── logger.py # Logging configuration ├── tests/ │ ├── __init__.py │ ├── test_context_fix.py # Context API fallback tests │ ├── test_inspector.py # Server inspection tests │ ├── test_with_api_key.py # Full functionality tests │ └── test_youtube_unit.py # Unit tests for core functionality ├── logs/ # Application logs ├── .env # Environment variables (create from .env.example) ├── .gitignore # Git ignore rules (includes coverage files) ├── pyproject.toml ├── LICENSE # MIT License └── README.md

The project uses a comprehensive testing approach:
- Unit Tests(test_youtube_unit.py): Test core YouTube functionality with mocked yt-info-extract
- Integration Tests(test_context_fix.py,test_with_api_key.py): Test full server functionality
- Manual Validation(test_inspector.py): Interactive server inspection tool

The project includes robust error handling:

- Graceful extraction failures: Returns appropriate error messages instead of crashing
- Multiple fallback strategies: yt-info-extract provides automatic fallback between YouTube Data API, yt-dlp, and pytubefix
- Transcript fallback logic: Multiple strategies for transcript retrieval via yt-ts-extract
- Consistent error responses: Standardized error message format
- Comprehensive logging: Detailed logs for debugging and monitoring

# Install build dependencies uv add --dev hatch # Build the package uv run hatch build

This project is licensed under the MIT License - see theLICENSEfile for details.

Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch (git checkout -b feature/amazing-feature)
- Commit your changes (git commit -m 'Add some amazing feature')
- Push to the branch (git push origin feature/amazing-feature)
- Open a Pull Request

If you encounter any issues or have questions, please:
- Check the
existing issues
- Create a new issue with detailed information about your problem
- Include logs and error messages when applicable

Give your AI the ability to read the web. Fetches URLs as clean markdown with 9 fallback strategies. Handles tweets, YouTube, arXiv, PDFs, and regular pages.

Retrieves transcripts from YouTube videos for content analysis and processing.

YouTube transcript API for AI agents - pay per successful transcript via x402 (USDC on Base); failed videos are never charged

Remote MCP that scrapes customer comments and reviews from Reddit, YouTube, Amazon, TikTok, app stores, and 25+ other platforms, then turns them into ad angles and customer language for marketers.

AI-powered Business Helper that analyzes thousands of YouTube videos to extract precise insights, timestamps, and actionable strategies. Instantly find the most relevant moments from podcasts, interviews, and lectures—turning long-form content into targeted business intelligence.

100% Free AI audio and video transcription with speaker diarization and YouTube support.

Turn any video — YouTube, Instagram, TikTok, Loom, direct URLs, or local files — into transcripts, key frames, OCR text, and metadata for AI agents.

Turn long videos into viral vertical shorts and publish them to TikTok, Instagram and YouTube: AI moment detection, 9:16 reframing, captions and dubbing.

YouTube growth toolkit for AI agents - research keywords, analyze channels, audit videos, pull transcripts, and more to find what works on YouTube.

AI post-production for audio and video — transcribe, summarize, find clips, cut horizontal or 9:16 vertical clips, publish to YouTube. Per-job pricing, no account.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.