Skip to main content
Glama

YouTube MCP 服务器

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

特征

  • 视频元数据:获取全面的视频信息

  • 字幕提取:支持自动生成和手动字幕

  • 多种语言:内置英语和法语支持

  • 模板系统:内置三个markdown模板:

    • 基础:简单的成绩单格式

    • 详细信息:带有时间戳的完整元数据

    • 搜索:结果突出显示并显示上下文

  • 搜索功能:在视频字幕内搜索

  • 灵活的身份验证:支持 API 密钥和 OAuth2 身份验证

Related MCP server: YouTube Video Summarizer MCP Server

先决条件

  • 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. 打开拉取请求

Available Tools

1 tool
get_transcriptC

YouTubeの字幕をURLまたは動画IDから取得します

ParametersJSON Schema
NameRequiredDescriptionDefault
urlYesYouTube動画のURLまたはID
langYes字幕の言語コード(例: 'ja', 'en')en

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions retrieving transcripts but doesn't describe what happens if no transcript exists, rate limits, authentication requirements, error conditions, or the format/scope of returned data. This leaves significant behavioral gaps for a tool that interacts with external APIs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Japanese that clearly communicates the core functionality without any wasted words. It's appropriately sized and front-loaded with the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations, no output schema, and interaction with an external service (YouTube), the description is insufficient. It doesn't explain what format the transcript returns, error handling, availability constraints, or any behavioral aspects needed for reliable use by an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents both parameters (url and lang with their descriptions and default). The description adds no additional parameter semantics beyond what's in the schema, maintaining the baseline score for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('取得します' - get/retrieve) and resource ('YouTubeの字幕' - YouTube subtitles/transcripts) with the input source specified ('URLまたは動画IDから' - from URL or video ID). It's specific about what the tool does, though it doesn't need to distinguish from siblings since there are none.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or limitations. It simply states what the tool does without context about appropriate use cases or constraints.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool update
    • First observedget_transcript

TDQS

B3/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of ambiguity or overlap between tools. The single tool has a clear and distinct purpose focused on retrieving transcripts from YouTube.

Naming Consistency5/5

A single tool inherently has perfect naming consistency as there are no other tools to compare it against. The tool name 'get_transcript' follows a clear verb_noun pattern.

Tool Count2/5

One tool is too few for a server named 'YouTube MCP Server', which suggests a broader scope. A single transcript retrieval tool feels incomplete for typical YouTube operations like searching videos, listing playlists, or managing uploads.

Completeness1/5

The tool surface is severely incomplete for a YouTube server. It only covers transcript retrieval, with no tools for core YouTube functionalities such as video search, metadata retrieval, playlist management, or user interactions, leaving significant gaps.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers