Skip to main content
Glama

youtube-transcript-mcp

一个 MCP 服务器,让编码代理能够读取和搜索 YouTube 视频字幕。无需 API 密钥、无需 Google 账户、无需注册任何东西。它通过 YouTube 的公共端点获取字幕,并额外提供原始字幕转储所没有的一项功能:章节摘要。

这最初是我自己使用的一个小工具。我经常遇到包含 YouTube 链接的对话,需要知道视频实际说了什么,而反复粘贴字幕浪费了大量时间。后来它变成了一个可复用的服务器,任何基于 Model Context Protocol 运行的程序都可以直接调用。

功能

四个工具。

  • get_transcript(video_url_or_id, languages=["en"], include_timestamps=False) 获取完整字幕并返回纯文本。它接受完整的 YouTube URL(watch?v=、youtu.be、/embed/、/shorts/、/live/)或裸的 11 位视频 ID。

  • get_video_metadata(video_url_or_id) 通过 YouTube 的免认证 oEmbed 端点返回标题、频道名称、频道 URL 和缩略图。它刻意不返回发布日期或完整描述,因为那些需要官方的 Data API 密钥,而这里的重点恰恰是你不需要密钥。

  • search_transcript(video_url_or_id, query, languages=["en"]) 查找与关键词或短语匹配的字幕片段,不区分大小写,每个片段都带有 [mm:ss] 时间戳,以便模型能够指出视频中某句话出现的位置。

  • summarize_chapters(video_url_or_id, gap_seconds=4.0, min_chunk_seconds=45.0, languages=["en"]) 将字幕按自然停顿切分为粗略的时间分块,并返回这些分块,这样代理就可以逐段总结,而不是一次性吞下整个巨大的文本块。这是一个启发式方法,并非 YouTube 真实的章节数据。

所有工具都返回纯字符串,包括错误信息(例如"Error: captions are disabled for this video")。不会有异常暴露给调用代理,也不会泄漏任何堆栈跟踪。

Related MCP server: YouTube for AI Agents

刻意不提供的功能

  • 不适用于字幕已禁用的视频、私密或不可用的视频,以及没有字幕的直播流。它会明确说明原因,而不是猜测。

  • 不依赖 YouTube Data API。没有它就无法获取发布日期或完整描述,这是设计使然。

  • 不做缓存。对同一视频的两次调用会两次重新获取。对于该工具的实际用途来说没问题。如果你将来需要大规模使用,可以自行添加缓存。

安装

需要 Python 3.11+ 和 uv。

uv sync

独立运行以确认它能正常启动:

uv run server.py

它会一直等待 MCP stdio 输入,因此在客户端连接之前看起来像是没有任何反应。这是正常现象。按 Ctrl+C 退出。

注册到 MCP 客户端

将其添加到客户端的 MCP 设置中。服务器通过 stdio 调用,因此配置就是一条命令行。以 Claude CLI 为例:

claude mcp add youtube-transcript -- uv --directory /absolute/path/to/youtube-transcript-mcp run server.py

或者在 JSON 配置中:

{
  "mcpServers": {
    "youtube-transcript": {
      "command": "uv",
      "args": ["--directory", "/absolute/path/to/youtube-transcript-mcp", "run", "server.py"]
    }
  }
}

来之不易的经验教训

  • 只有带字幕(自动生成或手动上传)的视频才能工作。没有字幕的视频会返回明确的错误,这是一个刻意的选择:空结果看起来像是静默失败,而错误信息则明确指出了问题。

  • 语言列表很重要。languages=["en"] 会在存在英文字幕轨时获取英文字幕。如果某个频道只上传其他语言的内容,请传入对应的语言代码。

  • 将 mcp>=1.28.1 固定下来,但保持在 2.0 以下。mcp 2.x 重命名了 mcp.server.fastmcp,导入会在服务器启动时静默失败。你需要的是能真正加载的那个版本。

许可证

MIT。参见 LICENSE。

Available Tools

4 tools
get_transcriptA

Fetch the full transcript of a YouTube video as plain text.

Args:
    video_url_or_id: Full YouTube URL (watch/youtu.be/embed/shorts) or bare 11-char video ID.
    languages: Preferred language codes in priority order, e.g. ["en", "en-GB"]. Defaults to ["en"].
    include_timestamps: If true, prefix each line with a [mm:ss] timestamp.
ParametersJSON Schema
NameRequiredDescriptionDefault
languagesNo
video_url_or_idYes
include_timestampsNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.3/5.0
Behavior4/5

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

With no annotations, the description carries the burden of behavior and does a good job: it explains accepted URL formats, the bare ID alternative, language priority ordering, the default language list, and timestamp formatting. It does not mention edge cases like missing captions or rate limits, but the disclosed behavior covers the core interaction well.

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 compact and well-structured: a one-line purpose, followed by a concise Args block. Every sentence earns its place, and parameter docs are front-loaded with the needed specifics.

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

Completeness4/5

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

For a three-parameter tool with an output schema, the description provides enough to invoke the tool correctly: required argument, optional language behavior, and timestamp control. It could be strengthened with guidance about when to use sibling tools or what happens when no transcript is available, but it is largely complete.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate, and it does thoroughly. Each parameter is explained with concrete examples, accepted formats, defaults, and behavioral effects, adding substantial meaning beyond the bare schema properties.

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

Purpose5/5

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

The first sentence clearly states the action ('Fetch the full transcript'), the resource ('YouTube video'), and the output form ('as plain text'). The word 'full' differentiates it from sibling tools like search_transcript, which implies partial or query-based retrieval.

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

Usage Guidelines3/5

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

Usage is implied by the purpose: use this tool when you need the complete transcript of a YouTube video. However, there is no explicit guidance about when to prefer search_transcript, get_video_metadata, or summarize_chapters instead, nor exclusions such as 'use search_transcript for snippets'.

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

get_video_metadataA

Fetch title, channel name, and thumbnail for a YouTube video via the no-auth oEmbed endpoint.

Note: oEmbed does not expose upload date or full description (those require the official
Data API + an API key). This returns what's available without one.

Args:
    video_url_or_id: Full YouTube URL or bare 11-char video ID.
ParametersJSON Schema
NameRequiredDescriptionDefault
video_url_or_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.6/5.0
Behavior4/5

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

With no annotations available, the description carries the behavioral disclosure burden. It credibly explains that the tool uses a no-auth endpoint, returns only a limited set of metadata, and does not expose upload date or full description. It could also mention error behavior or invalid inputs, but the core behavioral limitations are transparently disclosed.

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 compact and front-loaded with the main purpose. The limitation note is valuable context, and the Args section is minimal and directly useful. Every sentence contributes to correct invocation.

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

Completeness5/5

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

For a single-parameter metadata retrieval tool with a provided output schema, the description covers purpose, input format, expected returned fields, and key limitations. Nothing essential for selecting or invoking the tool is missing.

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

Parameters5/5

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

The input schema provides only a bare string type with 0% description coverage, but the description fully compensates by defining accepted values: 'Full YouTube URL or bare 11-char video ID.' This gives the agent exactly what it needs to construct a valid argument.

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

Purpose5/5

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

The description uses a specific verb ('Fetch') and names the exact resources returned ('title, channel name, and thumbnail'), clearly distinguishing this from the transcript-focused sibling tools. It also names the mechanism ('no-auth oEmbed endpoint'), leaving no ambiguity about what the tool does.

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

Usage Guidelines4/5

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

The description clearly implies when to use this tool (when basic YouTube metadata is needed without authentication) and explicitly notes when it is insufficient (when upload date or full description is required, which 'require the official Data API + an API key'). It does not explicitly reference sibling tools, but the field-level exclusions provide solid guidance.

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

search_transcriptA

Search a video's transcript for a keyword/phrase and return matching segments with timestamps.

Args:
    video_url_or_id: Full YouTube URL or bare 11-char video ID.
    query: Keyword or phrase to search for (case-insensitive substring match).
    languages: Preferred language codes in priority order. Defaults to ["en"].
ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes
languagesNo
video_url_or_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.1/5.0
Behavior3/5

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

No annotations are provided, so the description carries the burden of behavioral disclosure. It does disclose that query matching is case-insensitive and substring-based, and that languages default to ['en']. However, it does not mention what happens when no transcript is available, whether network fetching is involved, or how missing language captions are handled.

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 opens with a precise one-sentence purpose and then uses a clean bulleted Args list. There is no redundant or filler text; every sentence earns its place and the most important information is front-loaded.

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

Completeness4/5

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

Given the tool's moderate complexity, the description covers purpose, return type (matching segments with timestamps), and all parameters. An output schema exists to cover return-value details, but the description does not address edge cases or when to choose this tool over siblings, so it is not fully complete.

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

Parameters5/5

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

Schema description coverage is 0%, but the description fully compensates by explaining all three parameters: video_url_or_id accepts a full URL or bare 11-char ID, query is a case-insensitive substring match, and languages are priority-ordered with a default. This adds significant meaning beyond the bare schema.

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

Purpose5/5

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

The description clearly states the action: search a video's transcript for a keyword/phrase and return matching segments with timestamps. It differentiates itself from sibling tools like get_transcript and get_video_metadata by focusing on search-within-transcript rather than retrieval of the full transcript or metadata.

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

Usage Guidelines3/5

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

The purpose implies when to use it (when you need to find specific content in a transcript rather than reading the whole transcript), but it does not explicitly state when to prefer alternatives. No exclusions or alternative routing are provided, so the usage context is only implied.

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

summarize_chaptersA

Break a transcript into rough time-blocked chunks at natural pauses, for easier per-section summarizing.

This is a heuristic, not real chapter data: it splits wherever the gap between two consecutive
caption snippets exceeds `gap_seconds`, then merges any resulting chunk shorter than
`min_chunk_seconds` into its neighbor so chunks stay summarizable.

Args:
    video_url_or_id: Full YouTube URL or bare 11-char video ID.
    gap_seconds: Silence gap (seconds) between captions that triggers a new chunk boundary.
    min_chunk_seconds: Minimum chunk duration; shorter chunks get merged forward.
    languages: Preferred language codes in priority order. Defaults to ["en"].
ParametersJSON Schema
NameRequiredDescriptionDefault
languagesNo
gap_secondsNo
video_url_or_idYes
min_chunk_secondsNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations provided, the description carries the full burden and does so admirably. It explicitly discloses that this is 'a heuristic, not real chapter data' and explains the exact split/merge algorithm involving gap_seconds and min_chunk_seconds, so the agent knows what behavior to expect.

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 definition is front-loaded with a one-sentence summary, followed by a concise explanation of the heuristic behavior and a clean Args section. Every sentence carries necessary information, and there is no filler.

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

Completeness5/5

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

The tool has an output schema, so return values need not be repeated. The description covers the algorithm, parameters, defaults, and limitations, which is everything an agent needs to call it correctly. The only minor nuance is languages defaulting to ['en'] in the prose while the schema shows null, but the behavior is still clear.

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

Parameters5/5

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

Schema description coverage is 0%, so the description alone documents semantics. It gives meaningful explanations for all four parameters, including units ('seconds'), behavior ('triggers a new chunk boundary', 'merged forward'), and accepted values for video_url_or_id. This fully compensates for the schema's lack of descriptions.

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

Purpose5/5

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

The description opens with a specific verb and resource: 'Break a transcript into rough time-blocked chunks at natural pauses', which clearly defines the tool's output and purpose. It further distinguishes itself from real chapter data and from the sibling retrieval/search tools by stating it is a heuristic chunking operation.

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

Usage Guidelines4/5

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

The phrase 'for easier per-section summarizing' gives a clear context and intended use. It does not explicitly name alternatives (get_transcript, search_transcript) or state when not to use it, so it stops short of a 5, but it is not ambiguous.

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. 4 tool updatesv0.1.0
    • First observedget_transcript
    • First observedget_video_metadata
    • First observedsearch_transcript
    • First observedsummarize_chapters

TDQS

A4.4/5.0

Scored across 4 tools

Disambiguation5/5

Each tool targets a distinct operation: fetching raw transcript text, fetching metadata, searching within a transcript, and chunking into chapters. Even though three tools operate on transcripts, their purposes are clearly separated and descriptions make the boundaries obvious.

Naming Consistency5/5

All tool names follow a consistent verb_noun snake_case pattern: get_transcript, get_video_metadata, search_transcript, summarize_chapters. The verbs clearly indicate the action, and the nouns indicate the resource or output.

Tool Count5/5

With 4 tools, the server is well-scoped for a focused YouTube transcript utility. Each tool covers a meaningful, non-redundant capability without unnecessary bloat.

Completeness4/5

The set covers the core transcript workflows: fetching, searching, chunking, and basic metadata retrieval. A minor gap is the lack of a tool to list available transcript languages or caption tracks, which could help when the default language is unavailable.

Maintenance

ActivitySlowing
ResponsivenessUnresponsive

Related MCP Connectors

Related MCP Servers