YouTube Transcript MCP Server
Enables fetching YouTube video transcripts with Google OAuth 2.0 authentication. Supports both manual and auto-generated transcripts with optional timestamps from video URLs or IDs.
README
YouTube Transcript MCP Server
An MCP (Model Context Protocol) server that provides YouTube transcript fetching capabilities with Google OAuth 2.0 authentication. Only authorized users can access transcript data.
Features
- Fetch YouTube video transcripts from video IDs or full URLs
- Support for both manually created and auto-generated transcripts
- Optional timestamp inclusion for each transcript segment
- List available transcripts for any video
- Google OAuth 2.0 authentication with email-based authorization
- Automatic video ID extraction from various YouTube URL formats
Installation
- Clone this repository
- Install dependencies:
pip install -r requirements.txt
Google OAuth Setup
1. Create Google Cloud Project
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Identity API (if not already enabled)
2. Create OAuth 2.0 Credentials
- Navigate to APIs & Services > Credentials
- Click Create Credentials > OAuth client ID
- Select Web application as the application type
- Add authorized redirect URIs:
- For local development:
http://localhost:8080 - For production: Your application's callback URL
- For local development:
- Click Create
- Download the client configuration or note your Client ID
3. Configure Environment Variables
- Copy the example environment file:
cp .env.example .env
- Edit
.envand add your configuration:
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
AUTHORIZED_EMAILS=user1@gmail.com,user2@example.com
GOOGLE_CLIENT_ID: Your OAuth 2.0 client ID from Google Cloud ConsoleAUTHORIZED_EMAILS: Comma-separated list of email addresses allowed to use the service
Running the Server
Option 1: Docker (Recommended)
- Build and run with docker-compose:
docker-compose up -d
- Or build and run manually:
docker build -t youtube-transcript-mcp .
docker run -p 8000:8000 --env-file .env youtube-transcript-mcp
The server will be available at: http://localhost:8000/sse
Option 2: Direct Python
The server runs with SSE (Server-Sent Events) transport on port 8000 by default:
python youtube_transcript_mcp.py
The server will be available at: http://localhost:8000/sse
For MCP Inspector or other MCP clients, use:
- Transport Type: SSE
- URL:
http://localhost:8000/sse
Available Tools
1. youtube_get_transcript
Fetches the transcript for a YouTube video.
Parameters:
video_input(string, required): YouTube video ID or full URL- Examples:
dQw4w9WgXcQorhttps://youtube.com/watch?v=dQw4w9WgXcQ
- Examples:
cursor(integer, optional, default: 0): Starting segment index for pagination
Returns: Markdown-formatted transcript with timestamps
How Pagination Works:
- The tool automatically fits as many segments as possible within the MCP response size limit (25,000 characters)
- If the transcript is too long, it returns a chunk and tells you there's more
- Use the
cursorparameter from the response to fetch the next chunk
Example (start from beginning):
{
"video_input": "dQw4w9WgXcQ"
}
Example (fetch next page):
{
"video_input": "dQw4w9WgXcQ",
"cursor": 250
}
Response Format: When the transcript is paginated, the response includes:
Showing segments X-Y of Z: Current page rangeHas more: Whether there are more segments to fetchNext cursor: Value to use for fetching the next batch (only if has_more is true)
2. youtube_list_available_transcripts
Lists all available transcripts for a YouTube video.
Parameters:
video_input(string, required): YouTube video ID or full URLauth_token(string, required): Google OAuth 2.0 ID token
Returns: Markdown-formatted list of available transcripts with language information
Example:
{
"video_input": "https://youtu.be/dQw4w9WgXcQ",
"auth_token": "your-google-oauth-token"
}
Supported URL Formats
The server automatically extracts video IDs from these URL formats:
https://www.youtube.com/watch?v=VIDEO_IDhttps://youtu.be/VIDEO_IDhttps://www.youtube.com/embed/VIDEO_IDhttps://www.youtube.com/v/VIDEO_ID- Direct video ID:
VIDEO_ID
Authentication Flow
- User authenticates with Google OAuth 2.0
- Client obtains an ID token from Google
- Client passes the ID token in the
auth_tokenparameter - Server validates the token with Google
- Server checks if the user's email is in the authorized list
- If authorized, the tool executes; otherwise, access is denied
Error Handling
The server provides clear error messages for common issues:
- Invalid/expired token: "Invalid or expired authentication token"
- Unauthorized user: "Access denied. User X is not authorized"
- Video unavailable: "Video is unavailable. It may be private, deleted, or the ID is incorrect"
- No transcripts: "No transcripts available for this video"
- Transcripts disabled: "Transcripts are disabled for this video"
Security Considerations
- OAuth tokens are validated on every request
- Only users in the
AUTHORIZED_EMAILSlist can access tools - Client secrets should never be committed to version control
- Store
.envsecurely and never share publicly - The server is read-only and cannot modify YouTube data
Limitations
- Currently only supports English transcripts
- Requires internet connection to fetch transcripts and validate tokens
- Subject to YouTube's rate limits and availability
- Very long transcripts should use pagination to stay within MCP response size limits
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。