YouTube Transcript MCP Server

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.

Category
访问服务器

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

  1. Clone this repository
  2. Install dependencies:
pip install -r requirements.txt

Google OAuth Setup

1. Create Google Cloud Project

  1. Go to Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable the Google Identity API (if not already enabled)

2. Create OAuth 2.0 Credentials

  1. Navigate to APIs & Services > Credentials
  2. Click Create Credentials > OAuth client ID
  3. Select Web application as the application type
  4. Add authorized redirect URIs:
    • For local development: http://localhost:8080
    • For production: Your application's callback URL
  5. Click Create
  6. Download the client configuration or note your Client ID

3. Configure Environment Variables

  1. Copy the example environment file:
cp .env.example .env
  1. Edit .env and 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 Console
  • AUTHORIZED_EMAILS: Comma-separated list of email addresses allowed to use the service

Running the Server

Option 1: Docker (Recommended)

  1. Build and run with docker-compose:
docker-compose up -d
  1. 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: dQw4w9WgXcQ or https://youtube.com/watch?v=dQw4w9WgXcQ
  • 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 cursor parameter 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 range
  • Has more: Whether there are more segments to fetch
  • Next 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 URL
  • auth_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_ID
  • https://youtu.be/VIDEO_ID
  • https://www.youtube.com/embed/VIDEO_ID
  • https://www.youtube.com/v/VIDEO_ID
  • Direct video ID: VIDEO_ID

Authentication Flow

  1. User authenticates with Google OAuth 2.0
  2. Client obtains an ID token from Google
  3. Client passes the ID token in the auth_token parameter
  4. Server validates the token with Google
  5. Server checks if the user's email is in the authorized list
  6. 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_EMAILS list can access tools
  • Client secrets should never be committed to version control
  • Store .env securely 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

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选