Provides YouTube search capabilities with rich metadata including video titles, channels, view counts, duration, and publication dates. Supports multi-language searches and returns up to 100 results per query.
YouTube MCP Server
A Model Context Protocol (MCP) server that provides YouTube search capabilities for AI assistants. Designed for remote deployment on Dedalus platform with HTTP transport.
Features
š YouTube Search: Search YouTube videos with rich metadata
š Multi-language Support: Search in any language (en, es, fr, de, etc.)
š Rich Metadata: Get video titles, channels, views, duration, and more
š Remote Ready: HTTP server mode for Dedalus deployment
š ļø Local Development: STDIO mode for testing
Quick Start
Installation
Local Testing (STDIO mode)
Remote HTTP Server (Dedalus deployment)
Deploy to Dedalus
Prerequisites
Dedalus account and CLI installed
Repository pushed to GitHub
Deployment Steps
Verify project structure:
Deploy to Dedalus:
Use in Dedalus workflows:
Available Tools
search_youtube(query, lang="en", max_results=30)
Search YouTube and return video results with metadata.
Parameters:
query
(str): Search query (e.g., "machine learning tutorial")lang
(str): Language code (default: "en")max_results
(int): Max results to return, up to 100 (default: 30)
Returns: List of dictionaries with:
video_id
: YouTube video IDvideo_title
: Full video titlechannel_id
: Channel IDchannel_name
: Channel display namechannel_link
: Channel URL pathview_count
: Formatted view count (e.g., "1.2M views")published_date
: Publish time (e.g., "2 days ago")duration
: Video duration (e.g., "10:23")
Example:
Architecture
Project Structure
How It Works
Entry Point (
pyproject.toml
): Definesmain
script that points tosrc.main:main
MCP Server (
src/main.py
): FastMCP instance with YouTube search toolSearch Logic (
src/search.py
): YouTube API integration with paginationTransport Mode: Automatically selects HTTP (remote) or STDIO (local)
Transport Modes
The server automatically selects the appropriate transport:
HTTP Mode (Production): When
PORT
environment variable is set or--port
is specifiedSTDIO Mode (Development): Default when no port is configured
Configuration
Environment Variables
PORT
: HTTP server port (default: 8080)HOST
: HTTP server host (default: 0.0.0.0)
Command-Line Arguments
Development
Running Tests
Standalone Search Script
The YouTube search functionality can also be run standalone:
Technical Details
Dependencies
mcp>=1.16.0
: Model Context Protocol SDKhttpx
: HTTP client for API requestspydantic
: Data validationpython-dotenv
: Environment variable managementua-generator
: User agent generation
YouTube API
This server uses the YouTube internal API (youtubei) for search:
No API key required
Automatic pagination handling
Rate limiting handled by YouTube
Returns up to 100 results per query
Error Handling
Graceful handling of network errors
Retry logic for transient failures
Validation of input parameters
Clear error messages
Troubleshooting
Server won't start
No search results
Check internet connection
Verify query is valid
Try with fewer max_results
Check YouTube API status
Dedalus deployment issues
Ensure
pyproject.toml
is configured correctlyVerify
main.py
exists in project rootCheck
src/main.py
has proper importsReview Dedalus deployment logs
Best Practices
Query Optimization: Use specific queries for better results
Result Limits: Start with smaller max_results for faster responses
Language Codes: Use ISO 639-1 codes (e.g., "en", "es", "fr")
Error Handling: Always handle potential errors in client code
Rate Limiting: Be mindful of request frequency
Examples
Basic Search
Multi-language Search
Channel Discovery
Contributing
This is a reference implementation for Dedalus MCP servers. Feel free to:
Report issues
Suggest improvements
Fork and customize
License
This project is provided as an example. Modify and use as needed.
Resources
Support
For issues specific to:
Dedalus deployment: Check Dedalus Docs
MCP protocol: See MCP Spec
This server: Open an issue in the repository
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Enables AI assistants to search YouTube videos with rich metadata including titles, channels, view counts, and duration. Supports multi-language search and is designed for remote deployment on the Dedalus platform.