Skip to main content
Glama

get_video_comments

Retrieve comments from archived Twitch videos to analyze viewer engagement and feedback. Specify video ID and optional parameters for pagination and result limits.

Instructions

アーカイブ動画のコメントを取得します

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
videoIdYesビデオID
limitNo取得する最大コメント数(デフォルト: 20)
cursorNo次のページのカーソル

Implementation Reference

  • Main handler function that processes the tool call, fetches comments using GraphQL service, and formats the response.
    export async function handleGetVideoComments( gqlService: GraphQLService, args: { videoId: string; limit?: number; cursor?: string } ) { const { comments, nextCursor } = await gqlService.getVideoComments( args.videoId, args.limit, args.cursor ); return formatResponse({ total: comments.length, comments, pagination: { hasNextPage: !!nextCursor, nextCursor: nextCursor } }); }
  • Tool definition including name, description, and input schema for validation.
    { name: 'get_video_comments', description: 'アーカイブ動画のコメントを取得します', inputSchema: { type: 'object', properties: { videoId: { type: 'string', description: 'ビデオID', }, limit: { type: 'number', description: '取得する最大コメント数(デフォルト: 20)', minimum: 1, maximum: 100, }, cursor: { type: 'string', description: '次のページのカーソル', }, }, required: ['videoId'], }, },
  • src/index.ts:153-157 (registration)
    Registration in the main switch statement dispatching tool calls to the handler.
    case 'get_video_comments': return await handleGetVideoComments(this.gqlService, { videoId: args.videoId as string });
  • GraphQL service method that queries Twitch GQL for video comments, processes them, and handles pagination.
    async getVideoComments(videoId: string, limit: number = 20, cursor?: string): Promise<{ comments: any[], nextCursor: string | null }> { try { // クエリの作成 const query = cursor ? this.createCursorQuery(videoId, cursor) : this.createFirstQuery(videoId); // リクエストの実行 const response = await this.gqlSession.post('/gql', query); const data = response.data; const comments: any[] = []; const edges = data[0]?.data?.video?.comments?.edges || []; const pageInfo = data[0]?.data?.video?.comments?.pageInfo; // コメントの処理(指定された数まで) for (let i = 0; i < Math.min(edges.length, limit); i++) { comments.push(this.processComment(edges[i])); } // 次のページのカーソルを取得 let nextCursor: string | null = null; if (pageInfo?.hasNextPage && comments.length === limit) { nextCursor = edges[edges.length - 1].cursor; } return { comments, nextCursor }; } catch (error: any) { if (error.response?.data?.message) { throw new McpError( ErrorCode.InvalidParams, `GraphQL API error: ${error.response.data.message}` ); } throw new McpError( ErrorCode.InternalError, `Network error: ${error.message}` ); } }

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/mtane0412/twitch-mcp-server'

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