Skip to main content
Glama

summarize_transcript

Fetch a YouTube video transcript and prepare it for AI summarization. Supports custom prompts, timestamps, metadata, and multiple languages.

Instructions

Fetch a YouTube video's transcript and return it with summarization instructions.

The LLM client should use the returned instructions and transcript to produce a summary. The output is structured into clearly-labeled sections so a human can review the prompt before letting the LLM act on it.

Args: url: YouTube video URL or video ID prompt: Custom summarization instructions. If omitted, a default summary prompt is used. languages: Preferred languages in priority order (e.g. ["en", "de"]). Defaults to English. include_timestamps: When True, prefix each transcript line with [HH:MM:SS]. include_metadata: When True (default), include a [VIDEO] block with title, channel, published date, duration, views, and description.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
promptNo
languagesNo
include_timestampsNo
include_metadataNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • main.py:306-364 (handler)
    The main handler function for the summarize_transcript MCP tool. It extracts the video ID, fetches the transcript, and returns it structured with instructions, metadata, and transcript sections for LLM summarization.
    def summarize_transcript(
        url: str,
        prompt: str | None = None,
        languages: list[str] | None = None,
        include_timestamps: bool = False,
        include_metadata: bool = True,
    ) -> str:
        """Fetch a YouTube video's transcript and return it with summarization instructions.
    
        The LLM client should use the returned instructions and transcript to produce a summary.
        The output is structured into clearly-labeled sections so a human can review the prompt
        before letting the LLM act on it.
    
        Args:
            url: YouTube video URL or video ID
            prompt: Custom summarization instructions. If omitted, a default summary prompt is used.
            languages: Preferred languages in priority order (e.g. ["en", "de"]). Defaults to English.
            include_timestamps: When True, prefix each transcript line with [HH:MM:SS].
            include_metadata: When True (default), include a [VIDEO] block with title, channel, published date, duration, views, and description.
        """
        try:
            video_id = extract_video_id(url)
        except ValueError as e:
            return f"Error: {e}"
    
        langs = languages or ["en"]
        try:
            transcript = api.fetch(video_id, languages=langs)
            if include_timestamps:
                text = _format_transcript_with_timestamps(transcript)
            else:
                text = TextFormatter().format_transcript(transcript)
        except Exception as e:
            return _handle_transcript_error(e, video_id, langs)
    
        instructions = prompt or DEFAULT_SUMMARY_PROMPT
        prompt_source = "user-supplied" if prompt else "default"
        language = transcript.language
        language_code = transcript.language_code
        is_generated = transcript.is_generated
    
        sections = [
            f"[INSTRUCTIONS]\n{instructions}",
            f"[PROMPT_SOURCE]\n{prompt_source}",
        ]
    
        if include_metadata:
            meta = _fetch_metadata(video_id)
            sections.append(_format_metadata_block(meta, header="VIDEO"))
    
        sections.append(
            f"[METADATA]\n"
            f"Video ID: {video_id}\n"
            f"Language: {language} ({language_code})\n"
            f"Type: {'auto-generated' if is_generated else 'manual'}"
        )
        sections.append(f"[TRANSCRIPT]\n{text}")
    
        return "\n\n".join(sections)
  • main.py:305-305 (registration)
    The @mcp.tool() decorator registers summarize_transcript as an MCP tool on the FastMCP server instance.
    @mcp.tool()
  • main.py:25-28 (helper)
    Default summary prompt used when no custom prompt is provided by the user.
    DEFAULT_SUMMARY_PROMPT = (
        "Summarize the following YouTube video transcript. "
        "Provide a concise overview of the main topics, key points, and conclusions."
    )
  • Helper function used to format transcript lines with timestamps (called when include_timestamps=True).
    def _format_transcript_with_timestamps(transcript) -> str:
        """Render a FetchedTranscript as text with an [HH:MM:SS] prefix on each line."""
        return "\n".join(
            f"{_format_timestamp(snippet.start)} {snippet.text}" for snippet in transcript
        )
Behavior3/5

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

With no annotations, the description does carry the burden. It explains that the tool returns instructions and transcript for the LLM to produce a summary, and output is structured. However, it does not disclose potential errors, rate limits, or prerequisites like authentication. The key behavior is transparent but not exhaustive.

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

Conciseness4/5

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

The description is front-loaded with the core action, then uses a clear 'Args' list for parameters. It is slightly verbose but every sentence provides value. Could be tightened slightly but remains effective.

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 five parameters, no annotations, and presence of an output schema, the description covers the main behaviors and parameter details. It explains the output structure but misses error handling or return format specifics (likely covered by output schema). Comprehensive enough for an agent.

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 includes a detailed 'Args' section explaining each parameter's purpose, defaults, and behavior (e.g., languages in priority order, timestamps format). This adds significant meaning beyond the 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 it fetches a YouTube transcript and returns it with summarization instructions, distinguishing it from siblings like get_transcript which returns raw transcript. The purpose is specific: to provide a meta-output for LLM summarization, not a direct summary.

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 usage is implied from the description (use when you want a summary with instructions), but there is no explicit guidance on when to choose this over get_transcript or other siblings. No exclusions or alternatives are mentioned, leaving the agent to infer.

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

Install Server

Other Tools

Latest Blog Posts

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/zlatkoc/youtube-summarize'

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