youtube-mcp

mpnikhil/youtube-mcp

3.2

If you are the rightful owner of youtube-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

A simple Model Context Protocol (MCP) server that provides YouTube video metadata and transcripts.

Tools
1
Resources
0
Prompts
0

YouTube MCP Server

A simple Model Context Protocol (MCP) server that provides YouTube video metadata and transcripts. Built with FastMCP for a cleaner, more Pythonic approach.

Features

  • Get Video Metadata: Retrieve title, description, duration, view count, upload date, channel info, and thumbnail
  • Get Video Transcript: Fetch video transcripts in multiple languages with automatic fallback

Installation

  1. Install Python dependencies:
pip install -r requirements.txt
  1. Make the server executable:
chmod +x server.py

Usage

Running the Server

The server uses stdio for communication. Run it with:

python server.py

MCP Client Configuration

Add this server to your MCP client configuration (e.g., in Cursor or another MCP-compatible client):

{
  "mcpServers": {
    "youtube-mcp": {
      "command": "python",
      "args": ["/path/to/youtube-mcp/server.py"]
    }
  }
}

Tool: get_youtube_video_info

Parameters:

  • video_url_or_id (required): YouTube video URL or video ID
    • Examples:
      • https://www.youtube.com/watch?v=dQw4w9WgXcQ
      • https://youtu.be/dQw4w9WgXcQ
      • dQw4w9WgXcQ
  • language_codes (optional): Array of preferred language codes for transcript (default: ["en"])
    • Example: ["en", "es", "fr"]

Returns:

  • video_id: The extracted video ID
  • metadata: Video metadata including title, description, duration, views, etc.
  • transcript: Transcript data including full text, segments, language, and generation status

Example Response:

{
  "video_id": "dQw4w9WgXcQ",
  "metadata": {
    "title": "Video Title",
    "description": "Video description...",
    "duration": 212,
    "view_count": 1000000,
    "upload_date": "20231015",
    "uploader": "Channel Name",
    "channel": "Channel Name",
    "thumbnail": "https://...",
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  },
  "transcript": {
    "transcript": "Full transcript text...",
    "segments": [
      {
        "text": "Segment text",
        "start": 0.0,
        "duration": 5.0
      }
    ],
    "language": "en",
    "is_generated": false
  }
}

Dependencies

  • fastmcp: FastMCP framework - A Pythonic MCP framework with intuitive decorators (developed by Prefect)
  • youtube-transcript-api: For fetching YouTube transcripts
  • yt-dlp: For fetching YouTube video metadata
  • pydantic: For data validation

Why FastMCP?

FastMCP is a modern, Pythonic framework for building MCP servers that:

  • Uses intuitive decorators (@mcp.tool()) instead of manual tool registration
  • Simplifies server setup with mcp.run() instead of managing stdio streams
  • Provides better type inference and validation
  • Offers a cleaner, more maintainable codebase
  • Is actively maintained by Prefect with excellent documentation

Notes

  • The server automatically extracts video IDs from various YouTube URL formats
  • Transcripts fall back to auto-generated versions if manually created transcripts aren't available
  • If no transcript is available in the preferred language, it will attempt to find any available transcript