Enables searching for YouTube videos through natural language commands and playing videos or search results as playlists in the browser.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@YouTube MCP Serverfind and play some lofi hip hop beats for studying"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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
Prerequisites
Node.js 18+ installed
YouTube Data API v3 key from Google Cloud Console
Getting a YouTube API Key
Go to Google Cloud Console
Create a new project (or select existing)
Navigate to APIs & Services > Library
Search for "YouTube Data API v3" and enable it
Go to APIs & Services > Credentials
Click Create Credentials > API Key
Copy your API key
Installation
Clone the repository
Install dependencies:
npm installConfigure Environment Variables: Create a
.envfile in the root directory (copy from.env.example):cp .env.example .envEdit
.envand add yourYOUTUBE_API_KEY.Build the project:
npm run build
Add the following to your MCP configuration (e.g., .cursor/mcp.json or Claude Desktop config):
Note: The server will automatically load the
YOUTUBE_API_KEYfrom the.envfile in the project directory. Alternatively, you can pass it directly in theenvobject 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 querymaxResults(number, optional): Number of results (1-50, default: 10)
playPlaylist
Play videos in the browser.
Parameters:
videoIds(string[], optional): Array of video IDs to playquery(string, optional): Search and play videos matching this querymaxResults(number, optional): Number of videos when using query (default: 10)
Development
Project Structure
License
MIT