yt-subs

yt-subs

Extracts clean text transcripts from YouTube videos using their subtitles and returns them as plain text.

Category
访问服务器

README

YouTube Subtitles MCP Server

An MCP (Model Context Protocol) server that extracts clean text transcripts from YouTube videos using their subtitles.

Features

  • Extract English subtitles (auto-generated or manual) from YouTube videos
  • Convert subtitle files to clean, deduplicated plain text
  • Save transcripts to local files or return them directly
  • Works with any MCP-compatible client (Claude Desktop, etc.)

Prerequisites

Before using this MCP server, you must have the following tools installed:

Required Dependencies

  1. yt-dlp - YouTube video downloader

    # Install via Homebrew (macOS)
    brew install yt-dlp
    
    # Or via pip
    pip install yt-dlp
    
  2. ffmpeg - Media file converter

    # Install via Homebrew (macOS)
    brew install ffmpeg
    
    # Or via apt (Linux)
    sudo apt install ffmpeg
    
  3. Node.js - Version 18 or higher

    # Check your version
    node --version
    
    # Install via Homebrew (macOS)
    brew install node
    

Installation

Quick Start (Using npx)

No installation required! Just add to your MCP client configuration:

{
  "mcpServers": {
    "yt-subs": {
      "command": "npx",
      "args": ["-y", "yt-subs-mcp"]
    }
  }
}

Note: You still need to have yt-dlp and ffmpeg installed on your system (see Prerequisites above).

Claude Desktop Configuration

Edit your Claude Desktop config file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Add the server to the mcpServers section:

Option 1: Using npx (recommended)

{
  "mcpServers": {
    "yt-subs": {
      "command": "npx",
      "args": ["-y", "yt-subs-mcp"],
      "env": {
        "YT_SUBS_DOWNLOAD_DIR": "/path/to/your/transcripts"
      }
    }
  }
}

Option 2: Using local installation

{
  "mcpServers": {
    "yt-subs": {
      "command": "node",
      "args": ["/absolute/path/to/yt-subs/index.js"]
    }
  }
}

For Local Development

  1. Clone this repository

  2. Install dependencies:

    npm install
    
  3. Make the script executable:

    chmod +x index.js
    

Usage

Once configured in your MCP client, you can use the get_youtube_transcript tool:

Tool: get_youtube_transcript

Extracts the subtitle/transcript text from a YouTube video URL.

Parameters:

  • url (required): The YouTube video URL
  • save_to_file (optional): Whether to save the transcript to a file (default: true)

Examples:

// Get transcript and save to file
{
  "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "save_to_file": true
}

// Get transcript without saving
{
  "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "save_to_file": false
}

Response:

{
  "success": true,
  "video_id": "dQw4w9WgXcQ",
  "transcript": "Never gonna give you up\nNever gonna let you down...",
  "saved_to": "/Users/yourname/Downloads/yts/dQw4w9WgXcQ.txt",
  "message": "Transcript extracted and saved to /Users/yourname/Downloads/yts/dQw4w9WgXcQ.txt"
}

Configuration

Environment Variables

  • YT_SUBS_DOWNLOAD_DIR: Custom directory for saving transcript files
    • If not set, defaults to ~/Downloads/yts/
    • Must be an absolute path
    • Directory will be created if it doesn't exist

Example:

export YT_SUBS_DOWNLOAD_DIR="/path/to/your/transcripts"

Setting Environment Variables in Claude Desktop

To use a custom download directory, add the env property to your server configuration:

{
  "mcpServers": {
    "yt-subs": {
      "command": "node",
      "args": ["/absolute/path/to/yt-subs/index.js"],
      "env": {
        "YT_SUBS_DOWNLOAD_DIR": "/path/to/your/transcripts"
      }
    }
  }
}

Output Location

By default, transcript files are saved to:

~/Downloads/yts/

Or to the directory specified by YT_SUBS_DOWNLOAD_DIR environment variable.

Each transcript is saved with the video ID as the filename:

VIDEO_ID.txt

How It Works

  1. Extracts the video ID from the provided YouTube URL
  2. Downloads English subtitles (VTT format) using yt-dlp
  3. Converts VTT to SRT format using ffmpeg
  4. Extracts and deduplicates text content
  5. Cleans up temporary files
  6. Returns the clean transcript text

Troubleshooting

"Missing required dependencies" error

Make sure yt-dlp and ffmpeg are installed and available in your PATH:

which yt-dlp
which ffmpeg

"Failed to download subtitle" error

The video may not have English subtitles available. Try a different video or check if subtitles exist on YouTube.

"Could not extract video ID" error

Ensure you're providing a valid YouTube URL format:

  • https://www.youtube.com/watch?v=VIDEO_ID
  • https://youtu.be/VIDEO_ID

Development

Running Locally

npm start

The server will run on stdio and wait for MCP protocol messages.

Testing

You can test the server using an MCP client or by sending JSON-RPC messages via stdio.

Publishing to npm

If you want to publish your own version to npm:

  1. Update the package name in package.json to something unique

  2. Update the repository URLs to your GitHub repository

  3. Add your author information

  4. Login to npm:

    npm login
    
  5. Publish:

    npm publish
    

Before publishing, make sure to:

  • Test the package locally using npm pack and npm install -g ./yt-subs-mcp-1.0.0.tgz
  • Update the version number following semver
  • Ensure README is up to date
  • Add appropriate tags and keywords

License

MIT

Credits

Based on the yt-subs bash script for extracting YouTube subtitles.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选