serkanh
MCP Serverserkanhpublic

youtube mcp

一个使用MCP协议从YouTube视频中提取字幕的Web应用。

Repository Info

1
Stars
0
Forks
1
Watchers
0
Issues
Python
Language
-
License

About This Server

一个使用MCP协议从YouTube视频中提取字幕的Web应用。

Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.

Documentation

YouTube Transcript Extractor with MCP

A web application that extracts transcripts from YouTube videos using the Model Context Protocol (MCP) for communication between components.

Architecture

graph TB
    subgraph Frontend
        UI[Gradio Web Interface]
        Client[MCP Client]
    end

    subgraph Backend
        Server[MCP Server]
        YT[YouTube Transcript API]
    end

    UI --> |User Input| Client
    Client --> |MCP Protocol| Server
    Server --> |API Calls| YT
    YT --> |Transcript Data| Server
    Server --> |MCP Response| Client
    Client --> |Display| UI

    style UI fill:#f9f,stroke:#333,stroke-width:2px
    style Server fill:#bbf,stroke:#333,stroke-width:2px
    style YT fill:#bfb,stroke:#333,stroke-width:2px

Component Flow

sequenceDiagram
    participant User
    participant UI as Gradio Interface
    participant Client as MCP Client
    participant Server as MCP Server
    participant YT as YouTube API

    User->>UI: Enter YouTube URL
    UI->>Client: Request Transcript
    Client->>Server: Initialize Connection
    Server->>Client: Connection Established
    Client->>Server: Call get_transcript Tool
    Server->>YT: Request Transcript
    YT->>Server: Return Transcript Data
    Server->>Client: Return Formatted Text
    Client->>UI: Display Transcript
    UI->>User: Show Result

Features

  • Extract transcripts from any YouTube video
  • Support for multiple languages (falls back to English if requested language isn't available)
  • Optional timestamp inclusion
  • Clean and intuitive web interface
  • Robust error handling and fallbacks
  • Efficient client-server communication using MCP

Setup

  1. Clone the repository:
git clone <repository-url>
cd youtube-mcp
  1. Create and activate a Python virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt

Usage

  1. Start the application:
python gradio_youtube_transcript.py
  1. Open your web browser and navigate to the provided URL (typically http://localhost:7860)

  2. Enter a YouTube URL and select your preferences:

    • Choose the desired language
    • Toggle timestamps on/off
    • Click "Get Transcript" to extract

Technical Details

Components

  1. Gradio Interface (gradio_youtube_transcript.py)

    • Provides the web user interface
    • Handles user input and display
    • Manages client-server communication
  2. MCP Server (yt_dlp_transcript_server.py)

    • Implements the Model Context Protocol
    • Provides transcript extraction tools
    • Handles YouTube API interaction
    • Manages error handling and fallbacks

Tools

The MCP server provides two main tools:

  1. get_transcript

    • Gets plain text transcript
    • Parameters:
      • video_url: YouTube video URL
      • language: Preferred language code (defaults to 'en')
  2. get_transcript_with_timestamps

    • Gets transcript with timestamps
    • Parameters:
      • video_url: YouTube video URL
      • language: Preferred language code (defaults to 'en')

Communication Protocol

The application uses the Model Context Protocol (MCP) for client-server communication:

flowchart LR
    subgraph Protocol
        direction TB
        Init[Initialize Connection]
        List[List Available Tools]
        Call[Call Tool]
        Resp[Process Response]
    end

    Init --> List
    List --> Call
    Call --> Resp
    Resp --> |New Request| Call

    style Protocol fill:#f5f5f5,stroke:#333,stroke-width:2px

Error Handling

The application implements robust error handling:

  1. Connection Errors

    • Automatic reconnection attempts
    • Clear error messages to users
  2. Transcript Errors

    • Language fallback system
    • Informative error messages
  3. Resource Management

    • Proper cleanup of connections
    • Memory leak prevention

Requirements

  • Python 3.8+
  • Dependencies listed in requirements.txt:
    • mcp>=0.1.0
    • youtube-transcript-api>=0.6.1
    • gradio>=4.19.2

License

[Add your license information here]

Quick Start

1

Clone the repository

git clone https://github.com/serkanh/youtube-mcp
2

Install dependencies

cd youtube-mcp
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownerserkanh
Repoyoutube-mcp
LanguagePython
License-
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation