YouTube Data API MCP Server
A FastAPI server that enables interaction with YouTube's data through search, video details, channel information, and comment retrieval endpoints.
README
YouTube Data API v3 MCP Server
This is a FastAPI-based server designed to interact with the YouTube Data API v3. It provides endpoints to search for YouTube videos, retrieve video details, get channel information, and fetch video comments.
Features
- Search YouTube videos by query, order, and channel.
- Get detailed information for a specific YouTube video.
- Get detailed information for a YouTube channel by ID or username.
- Retrieve comments for a specific YouTube video.
Requirements
- Python 3.9+
- A Google Cloud Project with the YouTube Data API v3 enabled.
- An API Key for the YouTube Data API v3.
Setup and Installation
-
Clone the repository:
git clone <repository_url> cd youtube-mcp-server -
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: .\venv\Scripts\activate -
Install dependencies:
pip install -r requirements.txt -
Configure Environment Variables: Create a
.envfile in the root directory of the project based on.env.example:YOUTUBE_API_KEY=your_youtube_api_key_hereReplace
your_youtube_api_key_herewith your actual YouTube Data API v3 Key. Keep this key secure and do not commit it to version control.
Running the Server
Locally
To run the server locally using Uvicorn:
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
The --reload flag is useful for development as it restarts the server on code changes.
The API will be accessible at http://localhost:8000.
Access the interactive API documentation (Swagger UI) at http://localhost:8000/docs.
Using Docker
-
Build the Docker image:
docker build -t youtube-mcp-server . -
Run the Docker container: Make sure to pass your API key as an environment variable.
docker run -d -p 8000:8000 --name youtube-server -e YOUTUBE_API_KEY="your_youtube_api_key_here" youtube-mcp-serverReplace
"your_youtube_api_key_here"with your actual API key.
API Endpoints
All endpoints are prefixed with /youtube/.
1. Health Check
- GET
/health - Description: Checks if the server is running.
2. Search YouTube Videos
- GET
/youtube/videos/search - Description: Searches YouTube videos based on a query.
- Query Parameters:
query(string, required): The search query string.max_results(integer, optional, default: 10, max: 50): Maximum number of results.order(string, optional, default: "relevance"): Order of results (e.g., "date", "viewCount").channel_id(string, optional): Restricts search to a specific channel.
- Example:
/youtube/videos/search?query=FastAPI%20tutorial&max_results=5
3. Get YouTube Video Details
- GET
/youtube/videos/{video_id} - Description: Retrieves detailed information for a specific YouTube video.
- Path Parameters:
video_id(string, required): The ID of the YouTube video.
- Example:
/youtube/videos/dQw4w9WgXcQ
4. Get YouTube Channel Details
- GET
/youtube/channels - Description: Retrieves detailed information for a YouTube channel by ID or username.
- Query Parameters:
channel_id(string, optional): The ID of the YouTube channel.username(string, optional): The username of the YouTube channel (legacy).- Note: At least one of
channel_idorusernamemust be provided.
- Example:
/youtube/channels?channel_id=UC_x5XG1OV2P6wRIMAn-Ny3A(Google Developers channel) - Example:
/youtube/channels?username=PewDiePie(Note: Username lookup is less reliable now)
5. Get YouTube Video Comments
- GET
/youtube/videos/{video_id}/comments - Description: Retrieves comments for a specified YouTube video.
- Path Parameters:
video_id(string, required): The ID of the YouTube video.
- Query Parameters:
max_results(integer, optional, default: 100, max: 100): Maximum number of comments to return.
- Example:
/youtube/videos/dQw4w9WgXcQ/comments
Error Handling
The API returns standard HTTP status codes for errors (e.g., 400 Bad Request, 404 Not Found, 500 Internal Server Error) with a JSON payload containing a detail message.
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.