YouTube MCP Server

repository·main·Indexed 19 days ago

https://github.com/zubeidhendricks/youtube-mcp-server

A Model Context Protocol (MCP) server that enables AI models to interact with YouTube. It provides 10 tools for searching videos and channels, retrieving transcripts, and accessing playlist and channel metadata. The server supports multiple API keys for failover, multiple transport modes (stdio and http), and includes utility functions for generating thumbnails and A/B testing schedules.

Tokens
11.4K
Snippets
46
Records
57
Agent score
67%

What's inside zubeid-youtube-mcp-server

  1. Use YouTube MCP Server tools for Video, Channel, and Playlist management

    main

    The server provides tools to interact with YouTube content. Below are examples of how these tools are used conceptually:

    Video Operations

    • getVideo: Retrieve details like title, description, and duration.
    • getTranscript: Retrieve timestamped captions for a video.
    • searchVideos: Search for videos using a query.

    Channel Operations

    • getChannel: Get channel details and statistics.
    • listVideos: List videos belonging to a specific channel.

    Playlist Operations

    • getPlaylistItems: List items within a playlist.
    • getPlaylist: Get specific playlist details.
    // Get video details
    const video = await youtube.videos.getVideo({
      videoId: "video-id"
    });
    
    // Get video transcript
    const transcript = await youtube.transcripts.getTranscript({
      videoId: "video-id",
      language: "en"
    });
    
    // Search videos
    const searchResults = await youtube.videos.searchVideos({
      query: "search term",
      maxResults: 10
    });
    
    // Get channel details
    const channel = await youtube.channels.getChannel({
      channelId: "channel-id"
    });
    
    // List channel videos
    const videos = await youtube.channels.listVideos({
      channelId: "channel-id",
      maxResults: 50
    });
    
    // Get playlist items
    const playlistItems = await youtube.playlists.getPlaylistItems({
      playlistId: "playlist-id",
      maxResults: 50
    });
    
    // Get playlist details
    const playlist = await youtube.playlists.getPlaylist({
      playlistId: "playlist-id"
    });
  2. Install YouTube MCP Server for Claude Desktop

    main

    To use the YouTube MCP Server with Claude Desktop, you can either install it globally via npm or use npx to run it without a permanent installation.

    Option 1: Global Installation

    1. Install the package globally:
    npm install -g zubeid-youtube-mcp-server
    1. Update your Claude Desktop configuration file (~/Library/Application Support/Claude/claude_desktop_config.json on macOS or %APPDATA%\Claude\claude_desktop_config.json on Windows) with the following entry:
    {
      "mcpServers": {
        "zubeid-youtube-mcp-server": {
          "command": "zubeid-youtube-mcp-server",
          "env": {
            "YOUTUBE_API_KEY": "your_primary_youtube_api_key",
            "YOUTUBE_API_KEY2": "your_secondary_youtube_api_key",
            "YOUTUBE_API_KEY3": "your_tertiary_youtube_api_key"
          }
        }
      }
    }

    Option 2: Using NPX (No Installation Required)

    Add this to your Claude Desktop configuration instead:

    {
      "mcpServers": {
        "youtube": {
          "command": "npx",
          "args": ["-y", "zubeid-youtube-mcp-server"],
          "env": {
            "YOUTUBE_API_KEY": "your_primary_youtube_api_key",
            "YOUTUBE_API_KEY2": "your_secondary_youtube_api_key",
            "YOUTUBE_API_KEY3": "your_tertiary_youtube_api_key"
          }
        }
      }
    }
    {
      "mcpServers": {
        "zubeid-youtube-mcp-server": {
          "command": "zubeid-youtube-mcp-server",
          "env": {
            "YOUTUBE_API_KEY": "your_primary_youtube_api_key"
          }
        }
      }
    }
  3. Configure YouTube MCP Server for VS Code

    main

    To manually configure the YouTube MCP server in VS Code, add the following JSON block to your User Settings (JSON) file (accessible via Ctrl + Shift + P -> Preferences: Open User Settings (JSON)):

    {
      "mcp": {
        "inputs": [
          {
            "type": "promptString",
            "id": "apiKey",
            "description": "YouTube API Key",
            "password": true
          }
        ],
        "servers": {
          "youtube": {
            "command": "npx",
            "args": ["-y", "@modelcontextprotocol/server-youtube"],
            "env": {
              "YOUTUBE_API_KEY": "${input:apiKey}"
            }
          }
        }
      }
    }

    Alternatively, you can create a .vscode/mcp.json file in your workspace with the following content:

    {
      "inputs": [
        {
          "type": "promptString",
          "id": "apiKey",
          "description": "YouTube API Key",
          "password": true
        }
      ],
      "servers": {
        "youtube": {
          "command": "npx",
          "args": ["-y", "@modelcontextprotocol/server-youtube"],
          "env": {
            "YOUTUBE_API_KEY": "${input:apiKey}"
          }
        }
      }
    }
  4. Configure YouTube MCP Server in VS Code

    main

    To use the server in VS Code, add the following JSON block to your User Settings (JSON) file (accessible via Ctrl + Shift + P -> Preferences: Open User Settings (JSON)):

    {
      "mcp": {
        "inputs": [
          {
            "type": "promptString",
            "id": "apiKey",
            "description": "YouTube API Key",
            "password": true
          }
        ],
        "servers": {
          "youtube": {
            "command": "npx",
            "args": ["-y", "zubeid-youtube-mcp-server"],
            "env": {
              "YOUTUBE_API_KEY": "${input:apiKey}"
            }
          }
        }
      }
    }

    You can also place this configuration in a .vscode/mcp.json file within your workspace.

  5. Run YouTube MCP Server via Docker

    main

    The Docker image starts the server over HTTP by default.

    Default Settings:

    • Transport: http
    • Endpoint: http://localhost:8088/mcp
    • Readiness endpoint: http://localhost:8088/ready
    • Mode: stateless
    • Host: 0.0.0.0
    • Port: 8088

    Build and Run:

    docker build -t youtube-mcp-server .
    docker run --rm -p 8088:8088 youtube-mcp-server

    Note: The build process copies .env into the runtime image. If .env is present during docker build, the container will load credentials automatically without needing them at docker run time.

  6. Develop the YouTube MCP Server

    main

    To develop the server locally, follow these steps:

    # Install dependencies
    npm install
    
    # Build the project
    npm run build
    
    # Start the server (requires at least one configured YouTube API key)
    npm start
    
    # Development mode with auto-rebuild
    npm run dev
    npm install
    npm run build
    npm start
    npm run dev
  7. Configure YouTube API Keys and Environment Variables

    main

    The server requires YouTube Data API keys to function. It supports up to three keys for automatic failover if a quota is exhausted.

    Environment Variables

    • YOUTUBE_API_KEY: Primary YouTube Data API key (Required)
    • YOUTUBE_API_KEY2: Secondary fallback API key (Optional)
    • YOUTUBE_API_KEY3: Third fallback API key (Optional)
    • YOUTUBE_TRANSCRIPT_LANG: Default language for transcripts (Optional, defaults to en)

    Note: At least one of YOUTUBE_API_KEY, YOUTUBE_API_KEY2, or YOUTUBE_API_KEY3 must be set.