YouTube Data API MCP Server

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.

Category
Visit Server

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

  1. Clone the repository:

    git clone <repository_url>
    cd youtube-mcp-server
    
  2. Create a virtual environment (recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows: .\venv\Scripts\activate
    
  3. Install dependencies:

    pip install -r requirements.txt
    
  4. Configure Environment Variables: Create a .env file in the root directory of the project based on .env.example:

    YOUTUBE_API_KEY=your_youtube_api_key_here
    

    Replace your_youtube_api_key_here with 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

  1. Build the Docker image:

    docker build -t youtube-mcp-server .
    
  2. 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-server
    

    Replace "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_id or username must 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

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured