Skip to main content
Glama

YouTube MCP Server

A Model Context Protocol (MCP) server that enables AI agents to search and play YouTube videos through natural language commands.

Features

  • searchVideos: Search YouTube for videos matching any query

  • playPlaylist: Open videos in your default browser as a playlist

Related MCP server: mcp-server-youtube

Prerequisites

  1. Node.js 18+ installed

  2. YouTube Data API v3 key from Google Cloud Console

Getting a YouTube API Key

  1. Go to Google Cloud Console

  2. Create a new project (or select existing)

  3. Navigate to APIs & Services > Library

  4. Search for "YouTube Data API v3" and enable it

  5. Go to APIs & Services > Credentials

  6. Click Create Credentials > API Key

  7. Copy your API key

Installation

  1. Clone the repository

  2. Install dependencies:

    npm install
  3. Configure Environment Variables: Create a .env file in the root directory (copy from .env.example):

    cp .env.example .env

    Edit .env and add your YOUTUBE_API_KEY.

  4. Build the project:

    npm run build

Add the following to your MCP configuration (e.g., .cursor/mcp.json or Claude Desktop config):

{
  "mcpServers": {
    "youtube-mcp": {
      "command": "node",
      "args": ["/path/to/your/project/youtubeMCP/dist/index.js"]
    }
  }
}

Note: The server will automatically load the YOUTUBE_API_KEY from the .env file in the project directory. Alternatively, you can pass it directly in the env object in the JSON config above.

Usage Examples

Once configured, you can ask your AI agent:

  • "Search for 10 best English songs on YouTube"

  • "Play 5 relaxing piano music videos"

  • "Find Taylor Swift songs and play them"

  • "Search for coding tutorials"

Available Tools

searchVideos

Search YouTube for videos by query.

Parameters:

  • query (string, required): Search query

  • maxResults (number, optional): Number of results (1-50, default: 10)

playPlaylist

Play videos in the browser.

Parameters:

  • videoIds (string[], optional): Array of video IDs to play

  • query (string, optional): Search and play videos matching this query

  • maxResults (number, optional): Number of videos when using query (default: 10)

Development

# Watch mode for development
npm run dev

# Build
npm run build

# Start
npm start

Project Structure

YouTubeMCP/
├── package.json
├── tsconfig.json
├── README.md
├── src/
│   ├── index.ts           # MCP server entry point
│   ├── youtube-client.ts  # YouTube API wrapper
│   └── tools/
│       ├── search.ts      # searchVideos tool
│       └── play.ts        # playPlaylist tool
└── dist/                  # Compiled JavaScript

License

MIT

Available Tools

2 tools
playPlaylistA

Play YouTube videos in the browser. Provide video IDs directly or a search query to find and play videos automatically.

Inputs: videoIds, query, maxResults.

searchVideosC

Search for YouTube videos by query. Returns video IDs, titles, channels, and descriptions.

Inputs: query (required), maxResults.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have clearly distinct purposes: playPlaylist is for playing videos in the browser, while searchVideos is for searching and returning video metadata. There is no overlap in functionality, making it easy for an agent to choose the correct tool based on the task.

    Naming Consistency2/5

    The naming is inconsistent: playPlaylist uses camelCase, while searchVideos uses a verb_noun pattern. This mix of conventions lacks a predictable pattern, which could confuse agents expecting uniformity across tools.

    Tool Count2/5

    With only 2 tools, the server feels thin for a YouTube domain, which typically involves operations like listing playlists, managing subscriptions, or uploading videos. The current set is insufficient for comprehensive YouTube interactions, suggesting a significant under-scoping.

    Completeness2/5

    The tool surface is severely incomplete for a YouTube server. It lacks basic CRUD operations such as creating playlists, managing subscriptions, or handling user accounts. The existing tools cover only playback and search, leaving major gaps that will likely cause agent failures in broader tasks.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to search videos, read channels, browse playlists, fetch comments, and get transcripts from YouTube using the YouTube Data API v3 and InnerTube API for captions.
      2
      GPL 3.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI models to search, retrieve, and analyze YouTube videos, channels, playlists, and transcripts via the YouTube Data API, with automatic API key failover.
      503 npm
      MIT