listCommentCollections
Lists local comment collections with search focus and indexed counts to organize YouTube comment analysis for AI agents.
Instructions
List local comment collections, active search focus, and indexed comment counts.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| includeVideoList | No |
Implementation Reference
- The `listCollections` method in `CommentKnowledgeBase` class fetches all comment collections from the database, including optional video lists, and maps them to the expected output format. This is the implementation for the `listCommentCollections` tool.
listCollections( includeVideoList = false, ): ListCommentCollectionsOutput { const rows = this.db .prepare( `SELECT c.collection_id, c.label, c.created_at, c.updated_at, COALESCE((SELECT COUNT(*) FROM comment_collection_videos v WHERE v.collection_id = c.collection_id), 0) AS video_count, COALESCE((SELECT COUNT(*) FROM comment_chunks ch WHERE ch.collection_id = c.collection_id), 0) AS total_chunks FROM comment_collections c ORDER BY c.updated_at DESC, c.collection_id ASC`, ) .all() as Array<{ collection_id: string; label: string | null; created_at: string; updated_at: string; video_count: number; total_chunks: number; }>; const activeCollectionId = this.getActiveCollectionId(); const videoMap = includeVideoList ? this.loadVideosForCollections(rows.map((r) => r.collection_id)) : new Map<string, CommentCollectionSummary["videos"]>(); return { collections: rows.map((row) => ({ collectionId: row.collection_id, label: row.label ?? undefined, videoCount: Number(row.video_count ?? 0), totalCommentChunks: Number(row.total_chunks ?? 0), createdAt: row.created_at, lastUpdatedAt: row.updated_at, isActive: row.collection_id === activeCollectionId, videos: videoMap.get(row.collection_id), })), activeCollectionId: activeCollectionId ?? undefined, provenance: localProvenance(), }; }