#!/bin/bash
# Setup script for yt-fetch MCP server with Claude Desktop
set -e
echo "π Setting up yt-fetch MCP server for Claude Desktop"
# Check if YouTube API key is provided
if [ -z "$YOUTUBE_API_KEY" ]; then
echo "β Error: YOUTUBE_API_KEY environment variable is required"
echo " Get your API key from: https://console.developers.google.com/"
echo " Then run: export YOUTUBE_API_KEY='your-api-key'"
exit 1
fi
# Determine Claude Desktop config location based on OS
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
CONFIG_DIR="$HOME/Library/Application Support/Claude"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux
CONFIG_DIR="$HOME/.config/Claude"
else
echo "β Unsupported OS: $OSTYPE"
exit 1
fi
CONFIG_FILE="$CONFIG_DIR/claude_desktop_config.json"
echo "π Claude Desktop config location: $CONFIG_FILE"
# Create config directory if it doesn't exist
mkdir -p "$CONFIG_DIR"
# Get absolute path of this project
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Create or update Claude Desktop configuration
cat > "$CONFIG_FILE" << EOF
{
"mcpServers": {
"yt-fetch": {
"command": "uv",
"args": [
"run",
"--project",
"$PROJECT_DIR",
"yt-fetch"
],
"env": {
"YOUTUBE_API_KEY": "$YOUTUBE_API_KEY"
}
}
}
}
EOF
echo "β
Created Claude Desktop configuration at: $CONFIG_FILE"
echo ""
echo "π Configuration includes:"
echo " - Server name: yt-fetch"
echo " - Project path: $PROJECT_DIR"
echo " - YouTube API Key: ****${YOUTUBE_API_KEY: -4}"
echo ""
echo "π Please restart Claude Desktop to load the new MCP server"
echo ""
echo "π― Available tools after restart:"
echo " - search_videos: Search YouTube with filters"
echo " - get_video_details: Get detailed video information"
echo " - get_channel_info: Get channel statistics"
echo " - filter_videos: Apply custom filters to video lists"
echo " - get_transcripts: Extract video transcripts for analysis"
echo " - trending_analysis: Analyze trending videos"
echo ""
echo "π‘ Usage example:"
echo ' "Search for videos about Claude AI from the last month"'