Skip to main content
Glama

get-video-comments

Extract comments from a specific YouTube video by providing the video ID. Use this tool to analyze or export YouTube video comments with ease.

Instructions

Retrieve comments for a specific YouTube video

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
maxResultsNo
videoIdYes

Implementation Reference

  • Core implementation of fetching YouTube video comments using the YouTube Data API v3 commentThreads.list endpoint. This is the primary logic executed by the tool.
    async getComments( videoId: string, maxResults: number = 20, options: { order?: 'time' | 'relevance'; pageToken?: string; includeReplies?: boolean; } = {} ): Promise<youtube_v3.Schema$CommentThreadListResponse> { try { const { order = 'relevance', pageToken, includeReplies = false } = options; const response = await this.youtube.commentThreads.list({ part: includeReplies ? ['snippet', 'replies'] : ['snippet'], videoId, maxResults, order, pageToken }); return response.data; } catch (error) { console.error('Error getting comments:', error); throw error; } }
  • src/index.ts:265-299 (registration)
    MCP server.tool registration for 'get-video-comments', including input schema validation with Zod and the tool handler function that delegates to YouTubeService.getComments and formats the response.
    server.tool( 'get-video-comments', 'Retrieve comments for a specific YouTube video with sorting options', { videoId: z.string().min(1), maxResults: z.number().min(1).max(100).optional(), order: z.enum(['time', 'relevance']).optional(), includeReplies: z.boolean().optional(), pageToken: z.string().optional() }, async ({ videoId, maxResults = 20, order = 'relevance', includeReplies = false, pageToken }) => { try { const commentsData = await youtubeService.getComments(videoId, maxResults, { order, includeReplies, pageToken }); return { content: [{ type: 'text', text: JSON.stringify(commentsData, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: `Error fetching comments: ${error}` }], isError: true }; } } );
  • Zod schema defining input parameters for the get-video-comments tool: videoId (required), optional maxResults, order, includeReplies, and pageToken.
    { videoId: z.string().min(1), maxResults: z.number().min(1).max(100).optional(), order: z.enum(['time', 'relevance']).optional(), includeReplies: z.boolean().optional(), pageToken: z.string().optional() },

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/coyaSONG/youtube-mcp-server'

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