Skip to main content
Glama

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
NameRequiredDescriptionDefault
includeVideoListNo

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(),
      };
    }

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/rajanrengasamy/vidlens-mcp'

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