Skip to main content
Glama
l4b4r4b4b4

YouTube MCP Server

by l4b4r4b4b4

get_live_chat_messages

Retrieve recent live chat messages from a YouTube live stream using pagination. Poll with a page token to get only new messages.

Instructions

Get recent live chat messages from a streaming video.

Fetches live chat messages with pagination support for efficient polling.
Use the returned next_page_token in subsequent calls to get only new messages.
Cached for 30 seconds for near real-time monitoring.

Args:
    video_id: YouTube video ID of the live stream.
    max_results: Maximum messages to return (1-2000, default 200).
    page_token: Pagination token from previous call (None for first call).

Returns:
    Dictionary with:
    - video_id: YouTube video ID
    - messages: List of messages with author, text, published_at, author_channel_id
    - total_returned: Number of messages in this response
    - next_page_token: Token for next page (None if no more)
    - polling_interval_millis: YouTube's recommended polling interval

Example:
    >>> # First call - get latest messages
    >>> result = get_live_chat_messages("dQw4w9WgXcQ", max_results=50)
    >>> print(f"Got {result['total_returned']} messages")
    >>>
    >>> # Second call - get only new messages since first call
    >>> result2 = get_live_chat_messages(
    ...     "dQw4w9WgXcQ",
    ...     max_results=50,
    ...     page_token=result["next_page_token"]
    ... )

Note:
    - Costs 1 quota unit per request
    - Cached for 30 seconds in youtube.comments namespace
    - Polling Pattern:
      1. First call: No page_token → Get latest messages + next_page_token
      2. Store next_page_token
      3. Subsequent calls: Pass page_token → Get only NEW messages
      4. Repeat step 3 every 30-60 seconds for continuous monitoring
    - MCP Limitation: Agent must manually call this tool repeatedly to see new messages

Caching Behavior:

  • Parameters that accept reference strings can accept a ref_id from a previous tool call

  • Large results return ref_id + preview; use get_cached_result to paginate

  • All responses include ref_id for future reference

Ref input compatibility: Support depends on the tool's input schema/validation. Some strictly typed parameters may reject string ref_ids before resolution.

Full retrieval: Use get_cached_result(ref_id, full=True) to get the complete value.

Preview Size: server default. Override per-call with get_cached_result(ref_id, max_size=...).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
video_idYes
page_tokenNo
max_resultsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior2/5

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

No annotations are provided, so the description carries full burden. It discloses caching (30 seconds), quota cost, and the MCP limitation. However, the generic 'Caching Behavior' block at the end introduces ref_id concepts that do not apply to this tool's paramaters or output, potentially misleading agents.

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

Conciseness2/5

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

The description is overly long with redundant sections. The generic caching boilerplate at the end is unnecessary and not specific to this tool. While structured with headings, the extraneous text hurts conciseness.

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

Completeness3/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 (described in Returns) and the description covers usage, examples, and notes. However, the confusing generic caching section detracts from completeness, and the absence of output schema details in JSON may leave some ambiguity.

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's 'Args' section provides clear, detailed explanations for all three parameters (video_id, max_results, page_token) with defaults and usage context, fully compensating for the schema gap.

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 'Get recent live chat messages from a streaming video' with a specific verb and resource. It distinguishes from siblings like 'get_live_chat_id' and 'get_video_comments' by focusing on live chat messages with pagination.

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 explains the polling pattern, cost, caching, and when to use page_token. It provides a detailed step-by-step note on the polling cycle. However, it does not explicitly mention when not to use this tool or alternatives for other chat-related data.

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/l4b4r4b4b4/yt-api-mcp'

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