YouTube视频搜索服务

一个用于搜索John Savill的YouTube频道中与Azure相关视频的MCP服务器,适用于Azure学习和技术查询。

  • by danielsegan
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 danielsegan/YTAzureMCP

使用说明

John Savill Azure YouTube Search MCP Server

An MCP (Model Context Protocol) server that searches John Savill's YouTube channel for relevant Azure-related videos based on questions.

This server uses Streamable HTTP transport and is designed for deployment to Azure App Service.

Features

  • Search Azure Videos: Search John Savill's YouTube channel for videos relevant to Azure questions
  • Get Channel Info: Retrieve information about John Savill's YouTube channel
  • Relevant Results: Uses YouTube's relevance algorithm to find the most appropriate videos

Prerequisites

  1. Python 3.8+ installed
  2. YouTube Data API v3 Key: You need to obtain a YouTube Data API key from Google Cloud Console

Getting a YouTube Data API Key

Follow these detailed steps to get your YouTube API key:

  1. Go to Google Cloud Console

  2. Create or Select a Project

    • Click the project dropdown at the top of the page
    • Click "New Project"
    • Enter a project name (e.g., "YouTube MCP Server")
    • Click "Create"
    • Wait for the project to be created, then select it from the dropdown
  3. Enable YouTube Data API v3

    • In the left sidebar, go to "APIs & Services" > "Library"
    • Search for "YouTube Data API v3"
    • Click on "YouTube Data API v3" from the results
    • Click the "Enable" button
    • Wait for the API to be enabled (this may take a minute)
  4. Create API Credentials

    • Go to "APIs & Services" > "Credentials" in the left sidebar
    • Click "+ CREATE CREDENTIALS" at the top
    • Select "API key" from the dropdown
    • Your API key will be generated and displayed in a popup
    • Important: Copy the API key immediately (you can't see it again later)
    • Click "Close"
  5. Optional: Restrict the API Key (Recommended for Security)

    • Click on your newly created API key in the credentials list
    • Under "API restrictions", select "Restrict key"
    • Check "YouTube Data API v3"
    • Under "Application restrictions", you can optionally restrict by IP or HTTP referrer
    • Click "Save"
  6. Set the API Key

    • Copy your API key
    • Set it as an environment variable:
      export YOUTUBE_API_KEY="your-api-key-here"
      
    • Or add it to your shell profile (~/.zshrc or ~/.bashrc) to make it persistent:
      echo 'export YOUTUBE_API_KEY="your-api-key-here"' >> ~/.zshrc
      source ~/.zshrc
      

Note: The free tier allows 10,000 units per day. Each search request costs 100 units, so you can make approximately 100 searches per day for free.

Installation

  1. Clone or navigate to this directory:

    cd YTAzureMCP
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Set your YouTube API key as an environment variable:

    export YOUTUBE_API_KEY="your-api-key-here"
    

    Or on Windows:

    set YOUTUBE_API_KEY=your-api-key-here
    

Running the Server

Local Development

# Activate virtual environment
source venv/bin/activate

# Run the server
python server.py

The server will start on http://localhost:8001/mcp by default.

Azure App Service Deployment

This server is designed for deployment to Azure App Service. See azure-mcp-deploy.md for detailed deployment instructions.

Quick deploy:

  1. Set startup command: bash startup.sh
  2. Set environment variable: YOUTUBE_API_KEY=your-key
  3. Deploy code from GitHub or ZIP

MCP Client Configuration

This server uses Streamable HTTP transport and must be accessed via HTTP/HTTPS URL.

For VSCode/Cursor

Configure your MCP client with the server URL:

Local:

{
  "mcpServers": {
    "john-savill-azure-youtube": {
      "url": "http://127.0.0.1:8001/mcp"
    }
  }
}

Azure (after deployment):

{
  "mcpServers": {
    "john-savill-azure-youtube": {
      "url": "https://your-app.azurewebsites.net/mcp"
    }
  }
}

Note: The server must be running before the client connects. For local development, start the server first.

Available Tools

search_azure_videos

Searches John Savill's YouTube channel for videos relevant to a question or topic.

Parameters:

  • question (string, required): The question or topic to search for (can be any topic, not just Azure)
  • max_results (integer, optional): Maximum number of videos to return (default: 5, max: 50)
  • search_transcripts (boolean, optional): If True, also search video transcripts (default: False)

Returns:

  • JSON object with video information including title, URL, description, view count, duration, and optionally transcript matches

Example:

search_azure_videos(
    question="How to set up Azure Functions",
    max_results=5,
    search_transcripts=True
)

get_channel_info

Retrieves information about John Savill's YouTube channel.

Returns:

  • JSON object with channel information including name, subscriber count, video count, and description

get_latest_videos

Get the most recently published videos from John Savill's channel.

Parameters:

  • count (integer, optional): Number of latest videos to return (default: 10, max: 50)

Returns:

  • JSON object with the most recent videos including full details and thumbnails

Example:

get_latest_videos(count=10)

search_with_filters

Search with advanced filtering options.

Parameters:

  • question (string, required): The question or topic to search for
  • max_results (integer, optional): Maximum number of videos (default: 5, max: 50)
  • min_views (integer, optional): Minimum view count filter
  • published_after (string, optional): Filter videos published after this date (ISO 8601 format, e.g., "2024-01-01T00:00:00Z")
  • published_before (string, optional): Filter videos published before this date (ISO 8601 format)
  • max_duration_minutes (integer, optional): Maximum video duration in minutes
  • sort_by (string, optional): Sort order - "relevance", "date", "viewCount", "rating" (default: "relevance")

Returns:

  • JSON object with filtered video results

Example:

search_with_filters(
    question="Azure Functions",
    min_views=10000,
    published_after="2024-01-01T00:00:00Z",
    max_duration_minutes=30,
    sort_by="viewCount"
)

search_playlist

Search for videos within a specific playlist.

Parameters:

  • playlist_name (string, required): Name or partial name of the playlist (e.g., "Azure Master Class", "Certification Cram")
  • query (string, required): Search query within the playlist
  • max_results (integer, optional): Maximum number of videos (default: 10, max: 50)

Returns:

  • JSON object with videos from the playlist matching the query

Common Playlists:

  • "Azure Master Class"
  • "Certification Cram Videos"
  • "DevOps Master Class"
  • "PowerShell Master Class"
  • "Weekly Azure Update"
  • "Mentoring Content"

Example:

search_playlist(
    playlist_name="Azure Master Class",
    query="Functions",
    max_results=10
)

Example Usage

Once configured, you can ask questions like:

  • "How do I deploy an Azure Function App?"
  • "What is Azure Kubernetes Service?"
  • "How to configure Azure AD B2C?"
  • "Azure cost optimization strategies"

The server will search John Savill's channel and return relevant video results.

Notes

  • The server searches specifically on John Savill's channel (channel ID: UCpIn7ox7j7bH_OFj7tYouOQ)
  • Results are ordered by relevance
  • The YouTube Data API has quota limits - be mindful of your API usage
  • Free tier allows 10,000 units per day (1 search = 100 units)

License

MIT