Skip to main content
Glama

YouTube MCP Server

by nattyraz

YouTube MCP 服务器

用于与 YouTube 视频交互的模型上下文协议 (MCP) 服务器。该服务器提供用于提取视频元数据和字幕的工具,并使用各种模板将其转换为 Markdown 格式。

特征

  • 视频元数据:获取全面的视频信息
  • 字幕提取:支持自动生成和手动字幕
  • 多种语言:内置英语和法语支持
  • 模板系统:内置三个markdown模板:
    • 基础:简单的成绩单格式
    • 详细信息:带有时间戳的完整元数据
    • 搜索:结果突出显示并显示上下文
  • 搜索功能:在视频字幕内搜索
  • 灵活的身份验证:支持 API 密钥和 OAuth2 身份验证

先决条件

  • Node.js(v16 或更高版本)
  • npm 或 yarn
  • YouTube 数据 API 密钥和/或 OAuth2 凭据

安装

  1. 克隆存储库:
git clone [repository-url] cd youtube-mcp
  1. 安装依赖项:
npm install
  1. 构建项目:
npm run build

配置

使用您的 YouTube 凭据在根目录中创建一个.env文件:

YOUTUBE_API_KEY=your_api_key YOUTUBE_CLIENT_ID=your_client_id YOUTUBE_CLIENT_SECRET=your_client_secret YOUTUBE_REFRESH_TOKEN=your_refresh_token # Optional, for OAuth2

MCP 配置

将服务器添加到您的 MCP 设置文件(通常位于~/.config/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json ):

{ "mcpServers": { "youtube": { "command": "node", "args": ["path/to/youtube-mcp/build/index.js"], "env": { "YOUTUBE_API_KEY": "your_api_key", "YOUTUBE_CLIENT_ID": "your_client_id", "YOUTUBE_CLIENT_SECRET": "your_client_secret" }, "disabled": false, "alwaysAllow": [] } } }

用法

该服务器提供以下工具:

1. 获取视频信息

use_mcp_tool youtube get_video_info { "url": "https://www.youtube.com/watch?v=VIDEO_ID" }

2. 获取字幕

use_mcp_tool youtube get_captions { "url": "https://www.youtube.com/watch?v=VIDEO_ID", "language": "en" // Optional, defaults to "en" }

3. 转换为 Markdown

use_mcp_tool youtube convert_to_markdown { "url": "https://www.youtube.com/watch?v=VIDEO_ID", "template_name": "detailed", // Optional, "basic", "detailed", or "search" "language": "en", // Optional "options": { // Optional "include_chapters": true, "search_term": "keyword" // Only for search template } }

4. 列表模板

use_mcp_tool youtube list_templates

依赖项

{ "dependencies": { "@modelcontextprotocol/sdk": "latest", "googleapis": "^146.0.0", "google-auth-library": "^9.0.0", "youtube-captions-scraper": "^2.0.0", "express": "^4.18.2", "open": "^9.1.0" }, "devDependencies": { "@types/node": "^20.0.0", "typescript": "^5.0.0", "tsx": "^4.0.0" } }

OAuth2 设置

对于 OAuth2 身份验证(私人视频访问所需):

  1. Google Cloud Console中创建项目
  2. 启用 YouTube 数据 API v3
  3. 创建 OAuth2 凭据(Web 应用程序类型)
  4. 运行身份验证脚本:
node src/get-api-key.js
  1. 按照浏览器提示授权应用程序
  2. 将刷新令牌复制到您的配置中

自定义模板

您可以通过修改src/index.ts中的DEFAULT_TEMPLATES数组来添加自定义模板。模板遵循以下结构:

interface MarkdownTemplate { name: string; description: string; format: { header?: string; chapter_format?: string; caption_block: string; timestamp_format?: string; search_result_format?: string; } }

执照

麻省理工学院

贡献

  1. 分叉存储库
  2. 创建你的功能分支( git checkout -b feature/amazing-feature
  3. 提交您的更改( git commit -m 'Add some amazing feature'
  4. 推送到分支( git push origin feature/amazing-feature
  5. 打开拉取请求
-
security - not tested
-
license - not tested
-
quality - not tested

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.

通过提取元数据、多种语言的字幕以及使用各种模板将内容转换为 markdown,实现与 YouTube 视频的交互。

  1. 特征
    1. 先决条件
      1. 安装
        1. 配置
          1. MCP 配置
            1. 用法
              1. 获取视频信息
              2. 获取字幕
              3. 转换为 Markdown
              4. 列表模板
            2. 依赖项
              1. OAuth2 设置
                1. 自定义模板
                  1. 执照
                    1. 贡献

                      Related MCP Servers

                      • A
                        security
                        F
                        license
                        A
                        quality
                        This server allows AI language models to interact with YouTube content through a standardized interface, providing features such as video and channel information retrieval, transcript management, and playlist operations.
                        Last updated -
                        7
                        182
                        205
                        TypeScript
                        • Linux
                        • Apple
                      • A
                        security
                        F
                        license
                        A
                        quality
                        An MCP server that enables users to generate summaries of YouTube videos in multiple languages and formats through integration with DeepSRT's API.
                        Last updated -
                        1
                        33
                        JavaScript
                        • Apple
                      • -
                        security
                        F
                        license
                        -
                        quality
                        Enables extraction of transcript text from YouTube videos by providing the video URL, supporting standard, shortened, and embed URL formats.
                        Last updated -
                        1
                        JavaScript
                      • -
                        security
                        A
                        license
                        -
                        quality
                        A Model Context Protocol server that enables retrieval of transcripts from YouTube videos with language-specific support.
                        Last updated -
                        526
                        MIT License

                      View all related MCP servers

                      MCP directory API

                      We provide all the information about MCP servers via our MCP API.

                      curl -X GET 'https://glama.ai/api/mcp/v1/servers/nattyraz/youtube-mcp'

                      If you have feedback or need assistance with the MCP directory API, please join our Discord server