A Model Context Protocol (MCP) server implementation utilizing the YouTube Data API. It allows AI language models to interact with YouTube content through a standardized interface.
Note: OAuth is only required if you want to access your private YouTube playlists. Public content works without authentication.
Ensure OAuth is configured (see Prerequisites section above)
Authenticate with Google:
For npx users:
npx yt-mcp-auth auth
For local development:
npm run auth
Verify authentication:
For npx users:
npx yt-mcp-auth status
For local development:
npm run auth:status
Check status:
# npx users
npx yt-mcp-auth status
# Local development
npm run auth:status
Revoke authentication:
# npx users
npx yt-mcp-auth revoke
# Local development
npm run auth:revoke
Once authenticated, you can access your private playlists using the getMyPlaylists
tool.
The server provides the following MCP tools:
Tool Name | Description | Required Parameters |
---|---|---|
getVideoDetails |
Get detailed information about multiple YouTube videos including metadata, statistics, and content details | videoIds (array) |
searchVideos |
Search for videos based on a query string | query , maxResults (optional) |
getTranscripts |
Retrieve transcripts for multiple videos | videoIds (array), lang (optional) |
getRelatedVideos |
Get videos related to a specific video based on YouTube’s recommendation algorithm | videoId , maxResults (optional) |
getChannelStatistics |
Retrieve detailed metrics for multiple channels including subscriber count, view count, and video count | channelIds (array) |
getChannelTopVideos |
Get the most viewed videos from a specific channel | channelId , maxResults (optional) |
getVideoEngagementRatio |
Calculate engagement metrics for multiple videos (views, likes, comments, and engagement ratio) | videoIds (array) |
getTrendingVideos |
Get currently popular videos by region and category | regionCode (optional), categoryId (optional), maxResults (optional) |
compareVideos |
Compare statistics across multiple videos | videoIds (array) |
getPlaylistDetails |
Get detailed information about a specific YouTube playlist | playlistId |
getPlaylistVideos |
Retrieve all videos contained in a specific playlist | playlistId , maxResults (optional) |
searchPublicPlaylists |
Search for public playlists based on a query string | query , maxResults (optional), channelId (optional) |
getChannelPlaylists |
Get all public playlists from a specific channel | channelId , maxResults (optional) |
getMyPlaylists |
Get your own playlists (including private ones) | maxResults (optional) |
checkOAuthStatus |
Check if OAuth authentication is active | None |
No installation required! Use directly with Claude Desktop:
{
"mcpServers": {
"youtube": {
"command": "npx",
"args": ["-y", "yt-mcp"],
"env": {
"YOUTUBE_API_KEY": "YOUR_API_KEY_HERE",
"YOUTUBE_TRANSCRIPT_LANG": "en"
}
}
}
}
git clone https://github.com/space-cadet/yt-mcp.git
cd yt-mcp
npm install
npm run build
Step-by-step Google Cloud Console setup:
Only needed if you want to access private playlists:
http://localhost:3000/oauth2callback
Add environment variables directly to your Claude Desktop MCP configuration:
Basic configuration (public content only):
{
"mcpServers": {
"youtube": {
"command": "npx",
"args": ["-y", "yt-mcp"],
"env": {
"YOUTUBE_API_KEY": "YOUR_API_KEY_HERE",
"YOUTUBE_TRANSCRIPT_LANG": "en"
}
}
}
}
Full configuration (with OAuth for private playlists):
{
"mcpServers": {
"youtube": {
"command": "npx",
"args": ["-y", "yt-mcp"],
"env": {
"YOUTUBE_API_KEY": "YOUR_API_KEY_HERE",
"YOUTUBE_TRANSCRIPT_LANG": "en",
"GOOGLE_OAUTH_CLIENT_ID": "YOUR_OAUTH_CLIENT_ID",
"GOOGLE_OAUTH_CLIENT_SECRET": "YOUR_OAUTH_CLIENT_SECRET",
"OAUTH_REDIRECT_URI": "http://localhost:3000/oauth2callback"
}
}
}
}
Create a .env
file in the project root:
# Required
YOUTUBE_API_KEY=your_youtube_api_key_here
# Optional
YOUTUBE_TRANSCRIPT_LANG=en
# OAuth (for private playlists)
GOOGLE_OAUTH_CLIENT_ID=your_oauth_client_id
GOOGLE_OAUTH_CLIENT_SECRET=your_oauth_client_secret
OAUTH_REDIRECT_URI=http://localhost:3000/oauth2callback
Local development MCP configuration:
{
"mcpServers": {
"youtube": {
"command": "node",
"args": ["/path/to/yt-mcp/dist/index.js"]
}
}
}
“Error: YOUTUBE_API_KEY environment variable is not set”
“Google hasn’t verified this app” warning during OAuth
“OAuth authentication required” error
npx yt-mcp-auth auth
(or npm run auth
for local)“invalid_token” error during auth revocation
MCP server not responding
npm run build
If you encounter issues:
# Clone and setup
git clone https://github.com/space-cadet/yt-mcp.git
cd yt-mcp
npm install
# Create .env file with your credentials
cp .env.example .env
# Edit .env with your API keys
# Development commands
npm run dev # Run in development mode with auto-reload
npm run build # Build TypeScript to JavaScript
npm run start # Run built version
npm test # Run tests
npm run lint # Lint code
src/
├── index.ts # Main MCP server
├── auth-cli.ts # OAuth authentication CLI
├── functions/
│ ├── videos.ts # Video-related API functions
│ └── playlists.ts # Playlist-related API functions
└── utils/
├── oauth.ts # OAuth token management
├── oauth-routes.ts # OAuth callback server
└── cli-auth.ts # CLI authentication flow
tokens.json
- keep this file secureThis project is forked from youtube-data-mcp-server by icraft2170. Special thanks to the original author for creating the foundation of this YouTube MCP server implementation.
This project is licensed under the MIT License. See the LICENSE file for details.