Skip to main content
Glama
efikuta

YouTube Knowledge MCP

by efikuta

generate_knowledge_graph

Create knowledge graphs from multiple YouTube videos to visualize concept relationships and connections across content.

Instructions

Create cross-video knowledge graphs showing concept relationships

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
videoIdsYesYouTube video IDs to create knowledge graph from
graphDepthNoDepth of concept extraction and analysismedium
focusTopicsNoSpecific topics to focus on (optional)
includeTranscriptsNoInclude transcript content in analysis

Implementation Reference

  • Main handler function that executes the generate_knowledge_graph tool. Parses input args using the schema, gathers video data, extracts concepts using LLM, merges them, builds the graph structure, enhances with clustering, and caches the result.
    async execute(args: unknown): Promise<KnowledgeGraph> {
      const params = GenerateKnowledgeGraphSchema.parse(args);
      
      this.logger.info(`Generating knowledge graph for ${params.videoIds.length} videos`);
    
      // Generate cache key
      const cacheKey = `knowledge_graph:${params.videoIds.sort().join(',')}:${params.graphDepth}`;
    
      // Check cache first
      const cached = await this.cache.get<KnowledgeGraph>(cacheKey);
      if (cached) {
        this.logger.info(`Returning cached knowledge graph for videos`);
        return cached;
      }
    
      try {
        // Step 1: Gather video data
        const videoData = await this.gatherVideoData(params);
    
        // Step 2: Extract concepts from each video
        const conceptExtractions = await this.extractConceptsFromVideos(videoData, params);
    
        // Step 3: Merge and deduplicate concepts
        const mergedConcepts = this.mergeConceptExtractions(conceptExtractions);
    
        // Step 4: Build knowledge graph structure
        const knowledgeGraph = await this.buildKnowledgeGraph(mergedConcepts, videoData, params);
    
        // Step 5: Enhance with clustering and analysis
        const enhancedGraph = await this.enhanceKnowledgeGraph(knowledgeGraph);
    
        // Cache the result
        await this.cache.set(cacheKey, enhancedGraph, 7200); // 2 hours cache
        
        this.logger.info(`Knowledge graph generated: ${enhancedGraph.nodes.length} nodes, ${enhancedGraph.edges.length} edges`);
        
        return enhancedGraph;
    
      } catch (error) {
        this.logger.error(`Failed to generate knowledge graph:`, error);
        throw error;
      }
    }
  • Zod schema defining the input parameters for the generate_knowledge_graph tool, used for validation in the handler.
    export const GenerateKnowledgeGraphSchema = z.object({
      videoIds: z.array(z.string()).min(2).max(20).describe('Array of YouTube video IDs to analyze'),
      focusTopics: z.array(z.string()).optional().describe('Specific topics to focus on'),
      includeTranscripts: z.boolean().default(true).describe('Whether to analyze video transcripts'),
      graphDepth: z.enum(['shallow', 'medium', 'deep']).default('medium').describe('Depth of knowledge graph analysis'),
    });
  • src/index.ts:596-598 (registration)
    Registration in the tool dispatch switch statement: calls the KnowledgeGraphGenerator.execute() method when the tool is invoked.
    case 'generate_knowledge_graph':
      result = await this.knowledgeGraphTool.execute(args);
      break;
  • src/index.ts:507-542 (registration)
    Tool specification registered in the listTools response, including name, description, and input schema matching the Zod schema.
    {
      name: 'generate_knowledge_graph',
      description: 'Create cross-video knowledge graphs showing concept relationships',
      inputSchema: {
        type: 'object',
        properties: {
          videoIds: {
            type: 'array',
            items: {
              type: 'string'
            },
            minItems: 2,
            maxItems: 10,
            description: 'YouTube video IDs to create knowledge graph from'
          },
          graphDepth: {
            type: 'string',
            enum: ['shallow', 'medium', 'deep'],
            default: 'medium',
            description: 'Depth of concept extraction and analysis'
          },
          focusTopics: {
            type: 'array',
            items: {
              type: 'string'
            },
            description: 'Specific topics to focus on (optional)'
          },
          includeTranscripts: {
            type: 'boolean',
            default: true,
            description: 'Include transcript content in analysis'
          }
        },
        required: ['videoIds']
      }
  • src/index.ts:182-182 (registration)
    Instantiation of the KnowledgeGraphGenerator class instance used as the tool handler.
    this.knowledgeGraphTool = new KnowledgeGraphGenerator(this.youtubeClient, this.cache, this.llmService, this.transcriptProcessor, this.logger);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool 'creates' knowledge graphs, implying a generative/mutation operation, but fails to describe what 'create' entails—such as whether it returns a visual graph, data structure, or summary; potential rate limits; or any side effects like storing results. This leaves significant gaps in understanding the tool's behavior.

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

Conciseness5/5

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

The description is a single, efficient sentence that front-loads the core purpose without any wasted words. It directly states what the tool does, making it easy to parse and understand quickly, which is ideal for conciseness.

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 the complexity of creating knowledge graphs from multiple videos, the lack of annotations, and no output schema, the description is insufficient. It doesn't explain the output format (e.g., graph data, visualization), error conditions, or behavioral nuances like processing time or resource usage, leaving the agent poorly equipped to use this tool effectively.

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

Parameters3/5

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

The input schema has 100% description coverage, clearly documenting all four parameters. The description adds no additional meaning beyond the schema, such as explaining how 'graphDepth' affects output or what 'focusTopics' prioritizes. Since the schema does the heavy lifting, a baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 ('create') and resource ('cross-video knowledge graphs showing concept relationships'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'analyze_video_content' or 'generate_learning_path', which might also involve video analysis and content generation.

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 provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, such as needing video IDs, or compare it to siblings like 'analyze_video_content' for simpler analysis or 'generate_learning_path' for structured learning content, leaving the agent with no context for tool selection.

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/efikuta/youtube-knowledge-mcp'

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