Skip to main content
Glama
T1nker-1220

Knowledge Graph Memory Server

get_lesson_recommendations

Find relevant lessons tailored to your context using the Knowledge Graph Memory Server, enhancing learning and interaction with personalized recommendations.

Instructions

Get relevant lessons based on the current context

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextYesThe current context to find relevant lessons for

Implementation Reference

  • The core handler function in KnowledgeGraphManager class that executes the tool logic: loads all lessons, computes similarity scores based on error patterns, observations, relations, and success rates, then returns sorted relevant lessons.
    async getLessonRecommendations(context: string): Promise<LessonEntity[]> { // Load all files containing lessons const lessonFiles = await this.fileManager.getFilesForEntityType('lesson'); const allLessons: LessonEntity[] = []; // Load and merge lessons from all files for (const filePath of lessonFiles) { try { const fileContent = await fs.readFile(filePath, 'utf-8'); const fileGraph = JSON.parse(fileContent); const lessons = fileGraph.entities.filter((e: Entity): e is LessonEntity => e.entityType === 'lesson' ); allLessons.push(...lessons); } catch (error) { console.error(`Error loading lessons from ${filePath}:`, error); } } // Calculate relevance scores for each lesson const scoredLessons = await Promise.all( allLessons.map(async (lesson) => { let score = 0; // Check error pattern fields if (lesson.errorPattern) { score += this.calculateSimilarity(lesson.errorPattern.type, context) * 0.3; score += this.calculateSimilarity(lesson.errorPattern.message, context) * 0.3; score += this.calculateSimilarity(lesson.errorPattern.context, context) * 0.2; } // Check observations const observationScores = lesson.observations.map(obs => this.calculateSimilarity(obs, context) ); if (observationScores.length > 0) { score += Math.max(...observationScores) * 0.2; } // Check related lessons const relatedLessons = await this.getRelatedLessons(lesson.name); if (relatedLessons.length > 0) { score *= 1.2; // Boost score for lessons with relations } // Consider success rate const successRate = lesson.metadata?.successRate ?? 0; score *= (1 + successRate) / 2; // Weight by success rate return { lesson, score }; }) ); // Filter lessons with a minimum relevance score and sort by score return scoredLessons .filter(({ score }) => score > 0.1) // Minimum relevance threshold .sort((a, b) => b.score - a.score) .map(({ lesson }) => lesson); }
  • The tool schema definition including name, description, and input schema for 'context' parameter, registered in ListToolsRequestSchema handler.
    { name: "get_lesson_recommendations", description: "Get relevant lessons based on the current context", inputSchema: { type: "object", properties: { context: { type: "string", description: "The current context to find relevant lessons for" } }, required: ["context"] } }
  • index.ts:1251-1252 (registration)
    The switch case in CallToolRequestSchema handler that registers and dispatches the tool call to the KnowledgeGraphManager.getLessonRecommendations method.
    case "get_lesson_recommendations": return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.getLessonRecommendations(args.context as string), null, 2) }] };

Other Tools

Related 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/T1nker-1220/memories-with-lessons-mcp-server'

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