MCP YouTube Extract
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
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.
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 capabilities using yt-info-extract and yt-ts-extract:
- 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
📦 Available on PyPI
This package is now available on PyPI! You can install it directly with:
Visit the package page: mcp-youtube-extract on PyPI
Installation
Quick Start (Recommended)
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:
Using uv (Development)
For development or if you prefer uv:
From source
1. Clone the repository:
2. Install in development mode:
Configuration
Environment Variables
**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_KEY: Your YouTube Data API key (optional, provides additional fallback for metadata extraction)
Getting Your YouTube API Key (Optional)
While not required, you can optionally set up a YouTube Data API key for enhanced functionality. Here's how to get one:
Step 1: Create a Google Cloud Project
1. Go to the Google Cloud Console
2. Click "Select a project" at the top of the page
3. Click "New Project" and give it a name (e.g., "MCP YouTube Extract")
4. Click "Create"
Step 2: Enable the YouTube Data API
1. In your new project, go to the API Library
2. Search for "YouTube Data API v3"
3. Click on it and then click "Enable"
Step 3: Create API Credentials
1. Go to the Credentials page
2. Click "Create Credentials" and select "API Key"
3. Your new API key will be displayed - copy it immediately
4. Click "Restrict Key" to secure it (recommended)
Step 4: Restrict Your API Key (Recommended)
1. In the API key settings, click "Restrict Key"
2. Under "API restrictions", select "Restrict key"
3. Choose "YouTube Data API v3" from the dropdown
4. Click "Save"
Step 5: Set Up Billing (Required)
1. Go to the Billing page
2. Link a billing account to your project
3. **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
- **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
Security Best Practices
- **Never commit your API key** to version control
- **Use environment variables** as shown in the configuration section