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
アーカイブ動画のコメントを取得します
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"videoId": "<videoId>"
},
"name": "get_video_comments"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| videoId | Yes | ビデオID | |
| limit | No | 取得する最大コメント数(デフォルト: 20) | |
| cursor | No | 次のページのカーソル |
Implementation Reference
- src/tools/handlers/video.ts:31-49 (handler)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 } }); } - src/tools/definitions.ts:212-235 (schema)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 }); - src/services/gql.ts:7-49 (helper)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}` ); } }