YouTube MCP Server for Claude Code
Project description
YouTube MCP Server
Connect Claude to YouTube Data API v3 - search videos, get details, fetch comments, access playlists, transcripts, and more.
Prerequisites
Before you begin, make sure you have:
| Requirement | How to Get |
|---|---|
| Python 3.10+ | Download Python or install via brew install python3 |
| YouTube API Key | Get it for free from Google Cloud Console - see API Key Setup below |
| Claude Code | Install from claude.com/code |
Important: You need a YouTube API key to use this MCP server. Without it, the server will not work. Get your API key now following the steps below before proceeding.
Table of Contents
- Prerequisites ← 1. Start here
- Features
- API Key Setup ← 2. Do this first
- Installation ← 3. Then install
- Configuration ← 4. Then configure
- Usage
- Troubleshooting
- License
Features
| Tool | Description |
|---|---|
youtube_search |
Search videos, channels, playlists with filters (duration, date, type) |
youtube_get_video |
Get detailed video metadata, statistics, thumbnails |
youtube_get_channel |
Get channel info, subscriber count, upload playlists |
youtube_get_transcript |
Retrieve actual video transcript text and segments (requires video to have captions enabled) |
youtube_get_comments |
Fetch comments for a video (with pagination) |
youtube_get_playlist |
Get playlist details and video list |
youtube_list_playlists |
List playlists for a channel |
youtube_get_analytics |
Get analytics data (requires OAuth for full data) |
API Key Setup
Do this step BEFORE installing and configuring. You need a YouTube API key to use this MCP server.
Step 1: Create a Google Cloud Project
- Go to Google Cloud Console
- Create a new project or select an existing one
Step 2: Enable YouTube Data API v3
- Navigate to APIs & Services > Library
- Search for "YouTube Data API v3"
- Click "Enable"
Step 3: Create API Credentials
- Go to APIs & Services > Credentials
- Click "Create Credentials" > "API key"
- Copy your API key
Step 4: Restrict the API Key (Recommended)
- Click "Edit" on your API key
- Under "Application restrictions", select "IP addresses"
- Add your IP address (or leave open for development)
- Under "API restrictions", select "YouTube Data API v3"
Step 5: Use Your API Key
You have two options:
Option A: Set as Environment Variable (Recommended for security)
Set YOUTUBE_API_KEY environment variable, then use ${YOUTUBE_API_KEY} in your MCP config:
Linux/Mac:
# Add to ~/.bashrc, ~/.zshrc, or ~/.profile
export YOUTUBE_API_KEY="your_api_key_here"
# Reload shell
source ~/.zshrc
Windows (PowerShell):
# Add to $PROFILE
$env:YOUTUBE_API_KEY="your_api_key_here"
# Or set permanently
[System.Environment]::SetEnvironmentVariable('YOUTUBE_API_KEY', 'your_api_key_here', 'User')
Windows (CMD):
setx YOUTUBE_API_KEY "your_api_key_here"
Option B: Put Directly in MCP Config
Paste your API key directly in ~/.claude/mcp_config.json:
{
"mcpServers": {
"youtube-mcp-server": {
"command": "python",
"args": ["-m", "src.main"],
"env": {
"YOUTUBE_API_KEY": "AIzaSyC-Your-Actual-API-Key-Here"
}
}
}
}
Security Note: Option A (environment variable) is safer as it keeps your key out of version control and config files that might be shared.
Installation
# Navigate to the project directory
cd youtube-mcp-server
# Create virtual environment and install dependencies
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Configuration
Add to your ~/.claude/mcp_config.json:
{
"mcpServers": {
"youtube-mcp-server": {
"command": "/path/to/youtube-mcp-server/.venv/bin/python",
"args": ["-m", "src.main"],
"cwd": "/path/to/youtube-mcp-server",
"env": {
"YOUTUBE_API_KEY": "${YOUTUBE_API_KEY}"
}
}
}
}
Replace /path/to/youtube-mcp-server with your actual path, e.g.:
/Users/bytedance/Documents/code/youtube-mcp-server
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
YOUTUBE_API_KEY |
Yes | - | YouTube Data API v3 key |
YOUTUBE_RATE_LIMIT |
No | 100 | Max requests per second (rate limiting) |
Usage
Restart Claude Code and ask naturally:
"Search for Python tutorials" "Summarize this video: https://youtube.com/watch?v=xxx" "Get the transcript for this video" "How many subscribers does this channel have?"
Troubleshooting
MCP Server Not Found
Error: No MCP servers configured
Solution:
- Check that
~/.claude/mcp_config.jsonexists - Verify JSON is valid (no syntax errors)
- Restart Claude Code after updating config
Python Not Found
Error: command not found: python
Solution:
- Use
python3instead ofpythonin your config - Or provide the full path to your Python executable:
which python3 # On Mac/Linux where python # On Windows
Module Not Found
Error: ModuleNotFoundError: No module named 'mcp'
Solution:
- Ensure you installed dependencies in the correct environment
- If using venv, activate it first:
source .venv/bin/activate - Reinstall dependencies:
pip install -r requirements.txt
API Key Issues
Error: 403 Forbidden - quota exceeded
Solution:
- Check your Google Cloud Console quota
- Default quota is 10,000 units per day
- Consider upgrading your plan for higher limits
Import Errors
Error: ImportError: cannot import name '...'
Solution:
- Ensure you're running from the project root directory
- Check that
cwdis set correctly in MCP config - Verify all files exist in
src/directory
Permissions Issues
Error: Permission denied when installing
Solution:
- Use a virtual environment (recommended)
- Or use
pip install --userfor user-space installation - Or use
pip install --break-system-packages(not recommended)
Transcript Not Available
Error: "No transcript available for video" or "Transcripts are disabled"
Solution:
- The video may not have captions/subtitles enabled by the creator
- Auto-generated captions may not be available yet (can take 24+ hours after upload)
- Try a different video that is known to have captions
Transcript Request Blocked
Error: "YouTube is blocking requests from your IP"
Solution: This can happen when using cloud providers or making too many requests. See the youtube-transcript-api documentation for proxy configuration options.
License
MIT License - see LICENSE file for details.
For Developers
If you want to contribute or extend this MCP server, see DEVELOPMENT.md for:
- Running tests
- Project structure
- Adding new tools
- Building and publishing to PyPI
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file youtube_connector_mcp-0.1.0.tar.gz.
File metadata
- Download URL: youtube_connector_mcp-0.1.0.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee9e0e1f09195ca5bede4275ba4d76d9dcc761f2b757b3e5c3f296e151edb06e
|
|
| MD5 |
581dd3179ccf72c491a6e8ae6efc39a7
|
|
| BLAKE2b-256 |
94d3d9bd7b44eb4325102d3fc625b47d2209519f4f2bb9c4daceb1807eed08bd
|
File details
Details for the file youtube_connector_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: youtube_connector_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb3302d3d0698a59e8abed7ce2b8fefbd4c37c8cb191f864d40ccd12dd92761a
|
|
| MD5 |
212a4f52651fcac6744b138334b943f5
|
|
| BLAKE2b-256 |
2013eb2f1b5a906c5648ae0cec2bc2923344f54f26ab7950f9cd4f2cdc54135b
|