
youtube mcp
一个使用MCP协议从YouTube视频中提取字幕的Web应用。
Repository Info
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
- Clone the repository:
git clone <repository-url>
cd youtube-mcp
- Create and activate a Python virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
Usage
- Start the application:
python gradio_youtube_transcript.py
-
Open your web browser and navigate to the provided URL (typically http://localhost:7860)
-
Enter a YouTube URL and select your preferences:
- Choose the desired language
- Toggle timestamps on/off
- Click "Get Transcript" to extract
Technical Details
Components
-
Gradio Interface (
gradio_youtube_transcript.py)- Provides the web user interface
- Handles user input and display
- Manages client-server communication
-
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:
-
get_transcript- Gets plain text transcript
- Parameters:
- video_url: YouTube video URL
- language: Preferred language code (defaults to 'en')
-
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:
-
Connection Errors
- Automatic reconnection attempts
- Clear error messages to users
-
Transcript Errors
- Language fallback system
- Informative error messages
-
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
Clone the repository
git clone https://github.com/serkanh/youtube-mcpInstall dependencies
cd youtube-mcp
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.