YouTube MCP Server
Integrates with YouTube's Data API to enable video search, detailed video information retrieval, and transcript fetching with multi-language support and async performance.
README
YouTube MCP Server
A Model Context Protocol (MCP) server that provides comprehensive YouTube integration with video search, detailed video information retrieval, and transcript fetching capabilities.
Features
- š Video Search: Search YouTube videos with pagination support
- š¹ Video Details: Get comprehensive video information including statistics, content details, and metadata
- š Transcript Fetching: Real transcript extraction with intelligent language prioritization
- š Multi-language Support: Automatic language detection and fallback for transcripts
- ā” Async Performance: Built with async/await for optimal performance
- š Input/Output Validation: Complete schema validation with detailed error reporting
Tools
1. search_videos
Search for videos on YouTube with flexible pagination.
Parameters:
query(string, required): Search query for finding videospageToken(string, optional): Token for pagination to get next/previous page results
Example:
{
"query": "python programming tutorial",
"pageToken": "CAUQAA"
}
Returns: Search results with video snippets and pagination tokens
2. get_videos
Get detailed information about specific YouTube videos.
Parameters:
ids(array, required): List of video IDs to retrieve (max 50)parts(array, optional): Parts of video data to retrieve- Available parts:
snippet,contentDetails,statistics,status,player,recordingDetails,fileDetails,processingDetails,suggestions,liveStreamingDetails,localizations,topicDetails - Default:
["snippet"]
- Available parts:
Example:
{
"ids": ["dQw4w9WgXcQ", "9bZkp7q19f0"],
"parts": ["snippet", "contentDetails", "statistics"]
}
Returns: Comprehensive video data including duration, view counts, like counts, descriptions, and more
3. get_video_transcript
Extract video transcripts with intelligent language handling.
Parameters:
videoId(string, required): YouTube video IDlanguage(string, optional): Preferred language code (e.g., 'en', 'es', 'fr')
Language Priority:
- Requested language (if specified)
- English (fallback)
- Manual transcripts (preferred over auto-generated)
- Any available transcript
Example:
{
"videoId": "dQw4w9WgXcQ",
"language": "en"
}
Returns: Transcript with text segments, precise timestamps, and language metadata
Installation
Prerequisites
- YouTube Data API v3 Key:
- Visit Google Cloud Console
- Create a new project or select an existing one
- Enable YouTube Data API v3
- Create credentials (API Key)
- Copy the API key for configuration
Setup
-
Install the server:
git clone <repository-url> cd youtube-mcp-server uv sync -
Configure environment:
cp .env.example .env # Edit .env and add your YouTube API key: # YOUTUBE_API_KEY=your_actual_api_key_here -
Test installation:
uv run python test_server.py
Claude Desktop Integration
Add to your Claude Desktop configuration:
{
"mcpServers": {
"youtube": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/yourusername/youtube-mcp-server",
"youtube-mcp-server"
],
"env": {
"YOUTUBE_API_KEY": "your_youtube_api_key_here"
}
}
}
}
Usage Examples
Basic Video Search
# Search for Python tutorials
result = await search_videos("python programming tutorial")
Get Video Details
# Get comprehensive video information
result = await get_videos(
ids=["dQw4w9WgXcQ"],
parts=["snippet", "contentDetails", "statistics"]
)
Fetch Transcript
# Get transcript in preferred language
result = await get_video_transcript("dQw4w9WgXcQ", language="en")
API Rate Limits
The YouTube Data API v3 has the following quota limits:
- Default quota: 10,000 units per day
- Search requests: 100 units each
- Video details: 1 unit per video
- Transcript requests: No additional quota cost (uses separate API)
Typical usage:
- Video search + details: ~110 units (allows ~90 searches/day)
- Transcript fetching: No quota impact
Development
Project Structure
youtube-mcp-server/
āāā youtube_mcp_server/
ā āāā __init__.py
ā āāā __main__.py
ā āāā server.py # MCP server implementation
ā āāā handlers.py # Tool function implementations
ā āāā tools.json # Tool schema definitions
āāā test_cases.json # Comprehensive test cases
āāā test_server.py # Test suite with schema validation
āāā main.py # Development entry point
āāā pyproject.toml # Project configuration
āāā README.md
Running Tests
# Run comprehensive test suite
uv run python test_server.py
# Run the server locally
uv run python main.py
Adding Features
- Define tool schema in
youtube_mcp_server/tools.json - Implement function in
youtube_mcp_server/handlers.py - Update mapping in
TOOL_FUNCTIONS - Add test cases in
test_cases.json - Run tests to validate
Error Handling
The server provides comprehensive error handling:
- š API Key Issues: Clear messages for missing/invalid YouTube API keys
- š Quota Management: Informative messages about API quota limits
- ā Input Validation: Detailed validation errors for incorrect parameters
- š Network Resilience: Graceful handling of connection issues
- š Schema Validation: Full input/output validation with detailed error messages
Technical Details
Dependencies
- MCP Framework:
mcp>=1.6.0for Model Context Protocol support - Google API Client:
google-api-python-client>=2.0.0for YouTube Data API - Transcript API:
youtube-transcript-api>=0.6.0for transcript extraction - Environment:
python-dotenv>=1.0.0for configuration management - Validation:
jsonschema>=4.0.0for schema validation
Performance
- Async Architecture: All operations use async/await for optimal performance
- Connection Pooling: Efficient HTTP connection management
- Error Recovery: Automatic retry logic for transient failures
- Schema Caching: Tool schemas loaded once at startup
Security
- Environment Variables: API keys stored securely in environment
- Input Sanitization: All inputs validated against strict schemas
- Rate Limiting: Built-in respect for YouTube API rate limits
- Error Isolation: Detailed error messages without exposing internals
Contributing
- Fork the repository
- Create a feature branch
- Implement your changes with tests
- Ensure all tests pass:
uv run python test_server.py - Submit a pull request
License
MIT License - see LICENSE file for details.
Support
- Documentation: Check test cases in
test_cases.jsonfor usage examples - Validation: Run
uv run python test_server.pyto validate your setup - API Reference: YouTube Data API v3 Documentation
- Issues: Open GitHub issues for bugs or feature requests
Built with ā¤ļø using the Model Context Protocol framework.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.