Integrates Google OAuth 2.0 authentication for user authorization and token validation to control access to YouTube transcript services
Provides tools for fetching YouTube video transcripts, listing available transcripts, and extracting video IDs from various YouTube URL formats with Google OAuth 2.0 authentication
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:
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:8080For production: Your application's callback URL
Click Create
Download the client configuration or note your Client ID
3. Configure Environment Variables
Copy the example environment file:
Edit
.envand add your configuration:
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:
Or build and run manually:
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:
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 URLExamples:
dQw4w9WgXcQorhttps://youtube.com/watch?v=dQw4w9WgXcQ
include_timestamps(boolean, optional, default: true): Include [MM:SS] timestampsallow_auto_generated(boolean, optional, default: true): Fall back to auto-generated if manual transcript unavailableauth_token(string, required): Google OAuth 2.0 ID token
Returns: Markdown-formatted transcript with optional timestamps
Example:
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:
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_IDDirect 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_tokenparameterServer 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 toolsClient secrets should never be committed to version control
Store
.envsecurely and never share publiclyThe server is read-only and cannot modify YouTube data
Limitations
Currently only supports English transcripts
Maximum response size limited to 25,000 characters (automatically truncated with notice)
Requires internet connection to fetch transcripts and validate tokens
Subject to YouTube's rate limits and availability
License
MIT
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
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.