Enables fetching subtitles and transcripts from public YouTube videos with support for multiple output formats (SRT, VTT, TXT, JSON), multi-language subtitle support, and complete timestamp information.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@YouTube Subtitle MCP Serverfetch subtitles from https://youtu.be/dQw4w9WgXcQ in SRT format"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐ฌ YouTube Subtitle MCP Server
A Model Context Protocol (MCP) server for fetching YouTube video subtitles/transcripts with support for multiple output formats (SRT, VTT, TXT, JSON).
โจ Features
๐ฅ Fetch subtitles from any public YouTube video
๐ Multiple output formats: SRT, VTT, TXT, JSON
๐ Multi-language subtitle support
โก Two deployment modes: stdio (local) and HTTP (server)
๐ง Zero-configuration setup with npx
๐ Complete timestamp information
๐ Production-ready with TypeScript
๐ฅ Built with youtubei.js for reliable and stable subtitle extraction
๐ Quick Start
โญ Method 1: stdio Mode (Recommended for Local Use)
Zero configuration required! Simply use npx:
npx -y youtube-subtitle-mcpOr install globally:
npm install -g youtube-subtitle-mcp
youtube-subtitle-mcp๐ Method 2: HTTP Mode (For Server Deployment)
# Clone repository
git clone https://github.com/guangxiangdebizi/youtube-subtitle-mcp.git
cd youtube-subtitle-mcp
# Install dependencies
npm install
# Build
npm run build
# Start HTTP server
npm run start:httpServer will start at http://localhost:3000
๐ฆ Installation
For Development
# Clone repository
git clone https://github.com/guangxiangdebizi/youtube-subtitle-mcp.git
cd youtube-subtitle-mcp
# Install dependencies
npm install
# Build
npm run buildFor Production
npm install -g youtube-subtitle-mcp๐ง Configuration
โญ stdio Mode Configuration (Recommended)
Add to your MCP client configuration file:
Claude Desktop / Cursor Configuration:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"youtube-subtitle": {
"command": "npx",
"args": ["-y", "youtube-subtitle-mcp"]
}
}
}For local development:
{
"mcpServers": {
"youtube-subtitle": {
"command": "node",
"args": ["C:/path/to/youtube-subtitle-mcp/build/index.js"]
}
}
}๐ HTTP Mode Configuration
{
"mcpServers": {
"youtube-subtitle": {
"type": "streamableHttp",
"url": "http://localhost:3000/mcp",
"timeout": 600
}
}
}๐ ๏ธ Tool: fetch_youtube_subtitles
Parameters
Parameter | Type | Required | Description | Example |
| string | โ Yes | YouTube video URL or video ID |
|
| string | โ No | Output format (default: JSON) |
|
| string | โ No | Language code (default: auto) |
|
Supported URL Formats
Standard:
https://www.youtube.com/watch?v=VIDEO_IDShort:
https://youtu.be/VIDEO_IDEmbed:
https://www.youtube.com/embed/VIDEO_IDDirect ID:
VIDEO_ID
Language Codes
zh-Hans- Simplified Chinesezh-Hant- Traditional Chineseen- Englishja- Japaneseko- Koreanes- Spanishfr- Frenchde- German
๐ Usage Examples
Example 1: Fetch JSON Format Subtitles (Default)
Please fetch subtitles from this video:
https://www.youtube.com/watch?v=dQw4w9WgXcQExample 2: Fetch SRT Format Subtitles
Please fetch subtitles in SRT format from:
https://www.youtube.com/watch?v=dQw4w9WgXcQExample 3: Fetch Specific Language Subtitles
Please fetch Simplified Chinese subtitles in VTT format from:
https://www.youtube.com/watch?v=dQw4w9WgXcQ
Language code: zh-HansExample 4: Fetch Plain Text Content
Please fetch plain text subtitles from:
https://youtu.be/dQw4w9WgXcQ
Format: TXT๐ Output Format Examples
JSON Format
[
{
"text": "Hello world",
"start": 0,
"end": 2000,
"duration": 2000
},
{
"text": "Welcome to YouTube",
"start": 2000,
"end": 5000,
"duration": 3000
}
]SRT Format
1
00:00:00,000 --> 00:00:02,000
Hello world
2
00:00:02,000 --> 00:00:05,000
Welcome to YouTubeVTT Format
WEBVTT
00:00:00.000 --> 00:00:02.000
Hello world
00:00:02.000 --> 00:00:05.000
Welcome to YouTubeTXT Format
Hello world
Welcome to YouTube
This is a subtitle example๐๏ธ Project Structure
youtube-subtitle-mcp/
โโโ src/
โ โโโ index.ts # stdio mode entry (recommended for local use)
โ โโโ httpServer.ts # HTTP mode entry (for server deployment)
โ โโโ tools/
โ โโโ fetchYoutubeSubtitles.ts # Main tool implementation
โ โโโ formatters.ts # Format converters (SRT/VTT/TXT/JSON)
โ โโโ utils.ts # Utility functions
โโโ build/ # Compiled JavaScript (generated)
โโโ package.json
โโโ tsconfig.json
โโโ README.md๐ Development
Build
npm run buildWatch Mode
npm run watchStart stdio Mode
npm run start:stdioStart HTTP Mode
npm run start:httpCustom Port (HTTP Mode)
PORT=8080 npm run start:http๐ณ Docker Deployment
Using Docker
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "run", "start:http"]# Build image
docker build -t youtube-subtitle-mcp .
# Run container
docker run -d -p 3000:3000 --name youtube-mcp youtube-subtitle-mcpUsing Docker Compose
version: '3.8'
services:
youtube-subtitle-mcp:
build: .
ports:
- "3000:3000"
environment:
- PORT=3000
restart: unless-stoppeddocker-compose up -d๐ Deployment
PM2 (Process Manager)
# Install PM2
npm install -g pm2
# Start service
pm2 start build/httpServer.js --name youtube-subtitle-mcp
# View status
pm2 status
# View logs
pm2 logs youtube-subtitle-mcp
# Restart
pm2 restart youtube-subtitle-mcp
# Stop
pm2 stop youtube-subtitle-mcp๐ API Reference
Health Check (HTTP Mode)
Endpoint: GET /health
Response:
{
"status": "healthy",
"transport": "streamable-http",
"activeSessions": 0,
"name": "youtube-subtitle-mcp",
"version": "1.0.0",
"timestamp": "2024-01-01T12:00:00.000Z"
}MCP Endpoint (HTTP Mode)
Endpoint: POST /mcp
Headers:
Content-Type: application/jsonMcp-Session-Id: <session-id>(after initialization)
Request Body: JSON-RPC 2.0 format
โ ๏ธ Notes
Public videos only: Cannot fetch subtitles from private or restricted videos
Subtitles required: Video must have available subtitles (auto-generated or uploaded)
Language codes: If specified language doesn't exist, an error will be returned
Network required: Requires stable network connection to access YouTube
Terms of Service: Please comply with YouTube's Terms of Service, use for research/analysis purposes only
โ FAQ
Q: Server started but client can't connect?
A: Check the following:
Verify server is running: visit
http://localhost:3000/healthCheck URL in configuration file:
http://localhost:3000/mcpEnsure firewall isn't blocking port 3000
Restart Cursor/Claude Desktop
Q: Why can't I fetch subtitles?
A: Possible reasons:
Video has no subtitles
Video is private or region-restricted
Specified language code doesn't exist
Network connection issue
Server network can't access YouTube
Q: Do you support auto-generated subtitles?
A: Yes, supports YouTube auto-generated subtitles.
Q: Can I batch process multiple videos?
A: Current version processes one video at a time. For batch processing, loop the tool call on the client side.
Q: What's the timestamp unit?
A: Timestamps in JSON format are in milliseconds (ms).
Q: Can I deploy on a remote server?
A: Yes! Just:
Install Node.js on remote server
Clone project and run
npm installStart server with
npm run start:httpUse remote URL in client configuration:
http://your-server:3000/mcpRecommend using HTTPS and reverse proxy (e.g., Nginx) for security
Q: How to change port?
A: Two methods:
Environment variable:
PORT=8080 npm run start:httpCreate
.envfile: addPORT=8080
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
๐ค Author
Xingyu Chen
๐ Acknowledgments
Model Context Protocol - MCP SDK
youtubei.js - Powerful YouTube API wrapper for reliable subtitle extraction
๐ฎ Support
If you have any questions or suggestions, please create an Issue.
Made with โค๏ธ by Xingyu Chen
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.