Skip to main content
Glama

searchTranscripts

Search YouTube video transcripts to find specific content with timestamped results. Filter by collection or video ID to locate relevant segments quickly.

Instructions

Search imported transcript-text collections with active-collection focus by default and return ranked timestamped chunks.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
collectionIdNo
maxResultsNo
minScoreNo
videoIdFilterNo
useActiveCollectionNo

Implementation Reference

  • This is the actual handler function that executes the transcript search logic. It searches collections, ranks results, and formats the output.
    async search(input: SearchTranscriptsInput): Promise<SearchTranscriptsOutput> {
      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.2, 1));
      const scope = this.resolveCollectionScope(input);
      const targetCollections = scope.searchedCollectionIds;
      const videoFilter = input.videoIdFilter ? new Set(input.videoIdFilter) : undefined;
      const results: SearchTranscriptsOutput["results"] = [];
      let totalChunksSearched = 0;
      let embeddingModelLabel = DEFAULT_LOCAL_EMBEDDING_MODEL;
      let semanticFallback = false;
    
      for (const collectionId of targetCollections) {
        const model = this.loadModel(collectionId);
        if (!model || model.chunkCount === 0) {
          continue;
        }
        const rows = this.loadSearchRows(collectionId, videoFilter);
        if (rows.length === 0) {
          continue;
        }
        totalChunksSearched += rows.length;
        embeddingModelLabel = humanizeAlgorithm(model.algorithm);
        const rankedResult = await rankCollection(rows, model, input.query);
        const ranked = rankedResult.rows;
        semanticFallback ||= rankedResult.semanticFallback;
        const byVideo = groupChunkContexts(rows);
    
        for (const row of ranked) {
          if (row.score < minScore) {
            continue;
          }
          const context = byVideo.get(row.videoId);
          const previous = context?.get(row.ordinal - 1);
          const next = context?.get(row.ordinal + 1);
          results.push({
            collectionId,
            videoId: row.videoId,
            videoTitle: row.videoTitle,
            channelTitle: row.channelTitle,
            chunkText: row.text,
            tStartSec: row.tStartSec,
            tEndSec: row.tEndSec,
            timestampUrl: buildTimestampUrl(row.videoId, row.tStartSec),
            score: round(row.score, 4),
            lexicalScore: round(row.lexicalScore, 4),
            semanticScore: row.semanticScore !== undefined ? round(row.semanticScore, 4) : undefined,
            context: {
              prevChunkText: previous?.text,
              nextChunkText: next?.text,
            },
          });
        }
      }
    
      const deduped = results
        .sort((a, b) => b.score - a.score || a.videoTitle.localeCompare(b.videoTitle))
        .slice(0, maxResults);
    
      return {
        query: input.query,
        results: deduped,
        searchMeta: {
          totalChunksSearched,
          embeddingModel: semanticFallback ? `${embeddingModelLabel} (lexical fallback for this query)` : embeddingModelLabel,
          searchLatencyMs: Date.now() - startedAt,
          scope,
        },
        provenance: localProvenance(),
      };
    }
  • The registration in the server's executeTool switch statement. It passes the arguments to the `service.searchTranscripts` method.
    case "searchTranscripts":
      return service.searchTranscripts({
        query: readString(args, "query"),
        collectionId: optionalString(args, "collectionId"),
        maxResults: optionalNumber(args, "maxResults"),
        minScore: optionalNumber(args, "minScore"),
        videoIdFilter: optionalStringArray(args, "videoIdFilter"),
        useActiveCollection: optionalBoolean(args, "useActiveCollection"),
      });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions 'active-collection focus by default' and 'return ranked timestamped chunks', which gives some behavioral insight (default behavior and output format). However, it lacks details on permissions, rate limits, error handling, or whether it's read-only/destructive, leaving significant gaps for a search tool with multiple parameters.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads key information (search action and default behavior). It avoids redundancy and wastes no words, though it could be slightly more structured for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 6 parameters with 0% schema coverage, no annotations, and no output schema, the description is incomplete. It provides basic purpose and a hint about default behavior but lacks details on parameter usage, behavioral traits, and output format, making it inadequate for a tool of this complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate for all parameters. It only implies 'active-collection focus by default' (related to 'useActiveCollection' and 'collectionId'), but doesn't explain the purpose of 'query', 'maxResults', 'minScore', or 'videoIdFilter'. This leaves most parameters undocumented, failing to add meaningful semantics beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('search'), target ('imported transcript-text collections'), and output ('return ranked timestamped chunks'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'searchComments' or 'searchVisualContent' beyond mentioning transcript-text collections, which is implied but not contrasted.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions 'active-collection focus by default', which provides some context for when to use this tool regarding collection selection. However, it lacks explicit guidance on when to choose this over alternatives like 'searchComments' or 'readTranscript', and doesn't specify prerequisites or exclusions for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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