A Go-based Model Context Protocol (MCP) server that provides access to the YouTube Data API v3. This server allows AI assistants and other MCP clients to search for videos, get channel information, retrieve video details, and more.
- Video Search: Search for YouTube videos with filtering options
- Channel Information: Get detailed information about YouTube channels
- Video Details: Retrieve comprehensive details about specific videos
- Playlist Items: Get items from YouTube playlists
- Channel Search: Search for YouTube channels
- Go 1.19 or later installed on your system
- YouTube Data API v3 credentials from Google Cloud Console
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the YouTube Data API v3:
- Navigate to "APIs & Services" → "Library"
- Search for "YouTube Data API v3"
- Click "Enable"
- Create credentials:
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "API Key" (for public data access)
- Or create "OAuth client ID" (for user-specific data)
go mod tidy- Create a
.envfile from the example:
cp .env.example .env- Edit
.envwith your API key:
# YouTube Data API v3 Configuration
YOUTUBE_API_KEY=your_actual_api_key_here
# OAuth2 Configuration (optional, for user-specific data)
OAUTH2_CREDENTIALS_FILE=client_secret.json
TOKEN_FILE=token.jsonexport YOUTUBE_API_KEY="your_api_key_here"cp config.example.json config.json
# Edit config.json with your settings
# Run with: ./youtube-mcp-server -json-config# Build the server
go build -o youtube-mcp-server ./cmd/server
# Run the server (uses .env file)
./youtube-mcp-server
# Or run with JSON config file
./youtube-mcp-server -json-config -config config.json# Build Docker image
docker build -t youtube-mcp-server .
# Run with environment variables
docker run -e YOUTUBE_API_KEY="your_api_key" youtube-mcp-serverSearch for YouTube videos based on a query.
Parameters:
query(string, required): Search query for videosmax_results(integer, optional): Maximum number of results (default: 10)channel_id(string, optional): Limit search to specific channel
Example:
{
"method": "tools/call",
"params": {
"name": "search_videos",
"arguments": {
"query": "golang tutorial",
"max_results": 5
}
}
}Get information about a YouTube channel.
Parameters:
channel_id(string, optional): Channel ID to get info for (if empty, uses authenticated user's channel)
Example:
{
"method": "tools/call",
"params": {
"name": "get_channel_info",
"arguments": {
"channel_id": "UCBUKHRdFNRo2gPXRXCKnN7w"
}
}
}Get detailed information about a YouTube video.
Parameters:
video_id(string, required): YouTube video ID
Example:
{
"method": "tools/call",
"params": {
"name": "get_video_details",
"arguments": {
"video_id": "dQw4w9WgXcQ"
}
}
}Get items from a YouTube playlist.
Parameters:
playlist_id(string, required): YouTube playlist IDmax_results(integer, optional): Maximum number of results (default: 10)
Example:
{
"method": "tools/call",
"params": {
"name": "get_playlist_items",
"arguments": {
"playlist_id": "PLrAXtmRdnEQy4jrMVwm9wRbWqz4_0dmSh",
"max_results": 10
}
}
}Search for YouTube channels based on a query.
Parameters:
query(string, required): Search query for channelsmax_results(integer, optional): Maximum number of results (default: 10)
Example:
{
"method": "tools/call",
"params": {
"name": "search_channels",
"arguments": {
"query": "programming",
"max_results": 5
}
}
}The server can be configured via a JSON file or environment variables:
| Setting | Environment Variable | Description |
|---|---|---|
youtube_api_key |
YOUTUBE_API_KEY |
YouTube Data API v3 key |
oauth2_credentials_file |
- | Path to OAuth2 credentials file |
token_file |
- | Path to store OAuth2 tokens |
server_name |
- | MCP server name |
server_version |
- | MCP server version |
server_description |
- | MCP server description |
youtube-mcp/
├── cmd/
│ └── server/
│ └── main.go # Main server entry point
├── pkg/
│ ├── config/
│ │ └── config.go # Configuration management
│ ├── youtube/
│ │ └── youtube_client.go # YouTube API client wrapper
│ └── mcp/
│ └── mcp_tools.go # MCP tool definitions
├── .env.example # Example environment file
├── config.example.json # Example configuration file (legacy)
├── go.mod # Go module definition
└── README.md # This file
- Add new argument structs in
pkg/mcp/mcp_tools.go - Implement the YouTube API logic in
pkg/youtube/youtube_client.go - Register the new tool in the
SetupMCPToolsfunction
# Run tests
go test ./...
# Run with race detection
go test -race ./...- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
-
"quota exceeded" error: You've exceeded your YouTube API quota. Wait for it to reset or upgrade your quota.
-
"invalid API key" error: Check that your API key is correct and the YouTube Data API v3 is enabled for your project.
-
OAuth2 authentication issues: Ensure your
client_secret.jsonfile is in the correct location and properly formatted.
- Check the YouTube Data API documentation
- Review the MCP specification
- Open an issue on GitHub for bugs or feature requests