searchComments
Search YouTube comment collections to find relevant comments by query, with results ranked by relevance and showing author, likes, and score.
Instructions
Search imported comment collections with ranked results. Returns matching comments with author, like count, and relevance score. Uses active comment collection by default.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query | |
| collectionId | No | Specific collection to search | |
| maxResults | No | ||
| minScore | No | ||
| videoIdFilter | No | ||
| useActiveCollection | No |
Implementation Reference
- src/server/mcp-server.ts:1078-1086 (handler)The handler for the "searchComments" tool in the MCP server, which delegates the call to the service layer.
case "searchComments": return service.searchComments({ query: readString(args, "query"), collectionId: optionalString(args, "collectionId"), maxResults: optionalNumber(args, "maxResults"), minScore: optionalNumber(args, "minScore"), videoIdFilter: optionalStringArray(args, "videoIdFilter"), useActiveCollection: optionalBoolean(args, "useActiveCollection"), }); - The core implementation of the searchComments tool logic within the comment-knowledge-base service.
async search(input: SearchCommentsInput): Promise<SearchCommentsOutput> { const startedAt = Date.now(); const maxResults = Math.max(1, Math.min(input.maxResults ?? 10, 50)); const minScore = Math.max(0, Math.min(input.minScore ?? 0.15, 1)); const scope = this.resolveCollectionScope(input); const targetCollections = scope.searchedCollectionIds; const videoFilter = input.videoIdFilter ? new Set(input.videoIdFilter) - src/server/mcp-server.ts:600-615 (registration)Registration of the "searchComments" tool definition in the MCP server.
name: "searchComments", description: "Search imported comment collections with ranked results. Returns matching comments with author, like count, and relevance score. Uses active comment collection by default.", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query" }, collectionId: { type: "string", description: "Specific collection to search" }, maxResults: { type: "number", minimum: 1, maximum: 50 }, minScore: { type: "number", minimum: 0, maximum: 1 }, videoIdFilter: { type: "array", items: { type: "string" }, minItems: 1, maxItems: 100 }, useActiveCollection: { type: "boolean" }, }, required: ["query"], additionalProperties: false, }, },