Uses Google Cloud Console for authentication and credential management to access YouTube Data API v3 through OAuth 2.0.
Enables interaction with YouTube content through tools for video search, retrieval of video information and transcripts, channel statistics, comment analysis, trending videos discovery, generating educational flashcards and quizzes from video content, and comprehensive video summarization.
YouTube MCP Server
Model Contex Protocol (MCP) server that enables AI models to interact with YouTube content through a standardized interface. This server provides a set of tools for video search, content analysis, comment processing, and more.
š Features
š Video Search & Discovery
Search YouTube videos
Get trending videos
Find related content
Channel information
š Content Analysis
Detailed video information
Channel statistics
Video transcripts
Comprehensive summaries
š¬ Social Features
Comment retrieval
Comment analysis
User interaction data
š Quick Start
Prerequisites
1. Installing Python
macOS:
Linux (Ubuntu/Debian):
Windows:
Download Python installer from python.org
Run the installer
Check "Add Python to PATH" during installation
Open Command Prompt and verify:
2. Installing uv
macOS/Linux:
Windows (PowerShell):
Alternative Installation Methods:
Using pip (if you prefer):
3. Setting Up Google Cloud Credentials
Create a Google Cloud Project:
# Go to Google Cloud Console https://console.cloud.google.com # Click on "Select a Project" at the top # Click "New Project" # Name it (e.g., "youtube-mcp-server") # Click "Create"Enable YouTube Data API:
# In the Google Cloud Console: # 1. Go to "APIs & Services" > "Library" # 2. Search for "YouTube Data API v3" # 3. Click "Enable"Create OAuth 2.0 Credentials:
# In the Google Cloud Console: # 1. Go to "APIs & Services" > "Credentials" # 2. Click "Create Credentials" > "OAuth client ID" # 3. Select "Desktop app" as application type # 4. Name it (e.g., "YouTube MCP Client") # 5. Click "Create"Download and Store Credentials:
# 1. After creating credentials, click "Download JSON" # 2. Rename the downloaded file to 'credentials.json' # 3. Move it to your project root: mv ~/Downloads/client_secret_*.json ./credentials.json # Verify the file exists and has correct permissions ls -l credentials.json # Should show -rw------- (readable only by you)First-time Authentication:
# Run the server once to authenticate python mcp_videos.py # This will: # 1. Open your browser # 2. Ask you to sign in to Google # 3. Grant permissions to the application # 4. Create a token.pickle file (automatically ignored by git)
ā ļø Important Security Notes:
Never commit
credentials.jsonortoken.pickleto gitKeep your credentials secure and don't share them
If credentials are compromised:
Go to Google Cloud Console
Delete the compromised credentials
Create new credentials
Update your local
credentials.json
Installation
Clone the repository:
Create and activate a virtual environment:
Install dependencies using uv:
Set up YouTube API credentials:
Go to Google Cloud Console
Create a new project
Enable YouTube Data API v3
Create credentials (OAuth 2.0 Client ID)
Download the credentials and save as
client_secrets.json
Development Setup
For development, you might want to install additional tools:
Configuration
Create a
.envfile in the project root:
Verify your setup:
š ļø Usage
Starting the Server
Available Tools
Search Videos
Get Video Info
Get Channel Details
Get Video Comments
Get Trending Videos
Get Related Videos
Summarize Video
Generate Video Flash Cards
This tool generates educational flash cards from video content:
Creates different types of cards (Fill in the blank, Q&A, Definition)
Includes timestamps for video reference
Categorizes cards by type and difficulty
Provides card statistics
Example usage:
Card Types:
Fill in the blank: Tests recall of specific terms or concepts
Q&A: Questions about key points in the video
Definition: Explains important concepts
Difficulty Levels:
Easy: Basic recall and understanding
Medium: Application of concepts
Hard: Complex concepts and relationships
Generate Video Quiz
This tool generates a comprehensive quiz from video content:
Creates multiple choice questions
Generates true/false statements
Includes fill-in-the-blank questions
Uses video metadata, transcript, and description
Provides answers and explanations
Example usage:
Quiz Features:
Multiple Choice Questions
Based on video content
Includes video metadata
Tests understanding of key concepts
True/False Questions
Tests factual knowledge
Based on video statistics
Verifies understanding of claims
Fill in the Blank
Tests recall of specific terms
Uses transcript content
Focuses on key concepts
Quiz Format:
The quiz tool:
Generates exactly 10 questions
Mixes different question types
Includes video context
Provides immediate feedback
Uses video metadata for questions
Incorporates transcript content
Tests different levels of understanding
š Architecture
The project follows a modular architecture:
š§ Development
Project Structure
Adding New Tools
Create a new async function in
mcp_videos.pyDecorate it with
@mcp.tool()Implement the tool logic
Add appropriate error handling
Update documentation
š API Documentation
Response Formats
Video Format
Channel Format
Comment Format
š¤ Contributing
Fork the repository
Create a feature branch
Commit your changes
Push to the branch
Create a Pull Request
š License
This project is licensed under the MIT License - see the LICENSE file for details.
š Acknowledgments
FastMCP for the MCP framework
YouTube Data API for the API
All contributors and users of this project
š Support
For support, please:
Check the documentation
Open an issue
Contact the maintainers
š Updates
Stay updated with the project:
š Security
Handling Sensitive Data
ā ļø IMPORTANT: Never commit sensitive files to the repository:
token.pickleclient_secrets.json.envfilesAny other credential files
These files are automatically ignored by .gitignore, but if you accidentally commit them:
Remove them from git tracking:
Revoke and regenerate any exposed credentials
Update your local
.envfile with new credentialsNever share or expose these files publicly
Best Practices
Always use environment variables for sensitive data
Keep credentials in
.envfile (already in.gitignore)Regularly rotate API keys and tokens
Use OAuth 2.0 for authentication
Monitor GitHub's secret scanning alerts
š„ļø Claude Desktop Setup
1. Install Claude Desktop
Download Claude Desktop:
Visit Claude Desktop
Download the appropriate version for your OS:
macOS:
.dmgfileWindows:
.exeinstallerLinux:
.AppImageor.debpackage
Install the Application:
# macOS # 1. Open the .dmg file # 2. Drag Claude to Applications folder # 3. Open from Applications # Windows # 1. Run the .exe installer # 2. Follow the installation wizard # 3. Launch from Start Menu # Linux (Ubuntu/Debian) sudo dpkg -i claude-desktop_*.deb # For .deb package # OR chmod +x Claude-*.AppImage # For AppImage ./Claude-*.AppImage
2. Configure MCP Client
Open Claude Desktop Settings:
Click on the gear icon (āļø) or
Use keyboard shortcut:
macOS:
Cmd + ,Windows/Linux:
Ctrl + ,
Add MCP Configuration:
Navigate to "MCP Settings" or "Advanced Settings"
Add the following configuration:
{ "mcpServers": { "youtube_videos": { "command": "uv", "args": [ "--directory", "<your base directory>/youtube-mcp-server", "run", "mcp_videos.py" ] } } }Replace Path:
Replace
<your base directory>with your actual project pathExample for different OS:
// macOS/Linux "/Users/username/Documents/youtube-mcp-server" // Windows "C:\\Users\\username\\Documents\\youtube-mcp-server"
Verify Configuration:
# Test the MCP server path cd "<your base directory>/youtube-mcp-server" uv run mcp_videos.py
3. Using Claude with MCP
Start Claude Desktop
Connect to MCP Server:
The server should start automatically
You'll see a connection status indicator
Available tools will be listed in the interface
Test the Connection:
# Try a simple command get_videos("python programming", max_results=5)
Troubleshooting MCP Connection
Server Won't Start:
# Check if the path is correct pwd # Should show your project directory # Verify Python environment which python # Should point to your virtual environment # Check uv installation uv --versionConnection Issues:
Verify the server is running
Check the configuration path
Ensure all dependencies are installed
Check the logs in Claude Desktop
Common Errors:
# Path not found # Solution: Use absolute path in configuration # Permission denied # Solution: Check file permissions chmod +x mcp_videos.py # Module not found # Solution: Verify virtual environment source .venv/bin/activate # or appropriate activation command