Skip to main content
Glama
T1nker-1220

Knowledge Graph Memory Server

create_lesson

Create structured lessons from errors and solutions to prevent recurrence, storing insights in a knowledge graph for future reference.

Instructions

Create a new lesson from an error and its solution

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
lessonYes

Implementation Reference

  • Core handler function in KnowledgeGraphManager that validates the lesson input, checks for duplicates, sets metadata, adds the lesson to the graph, persists it, and returns the created lesson.
    async createLesson(lesson: LessonEntity): Promise<LessonEntity> { // Validate required fields if (!lesson.name || !lesson.errorPattern || !lesson.verificationSteps) { throw new Error('Missing required fields in lesson'); } // Validate error pattern if (!lesson.errorPattern.type || !lesson.errorPattern.message || !lesson.errorPattern.context) { throw new Error('Missing required fields in error pattern'); } // Validate verification steps if (!lesson.verificationSteps.every(step => step.command && step.expectedOutput && Array.isArray(step.successIndicators) )) { throw new Error('Invalid verification steps'); } const graph = await this.loadGraph(); // Check for duplicate lesson if (graph.entities.some(e => e.name === lesson.name)) { throw new Error(`Lesson with name ${lesson.name} already exists`); } // Set metadata timestamps and initial values lesson.metadata = { ...lesson.metadata, createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), frequency: 0, successRate: 0 }; // Add to entities graph.entities.push(lesson); await this.saveGraph(graph); return lesson; }
  • Input schema definition for the create_lesson tool, specifying the structure and validation rules for the LessonEntity input.
    inputSchema: { type: "object", properties: { lesson: { type: "object", properties: { name: { type: "string", description: "Unique identifier for the lesson" }, entityType: { type: "string", enum: ["lesson"], description: "Must be 'lesson'" }, observations: { type: "array", items: { type: "string" }, description: "List of observations about the error and solution" }, errorPattern: { type: "object", properties: { type: { type: "string", description: "Category of the error" }, message: { type: "string", description: "The error message" }, context: { type: "string", description: "Where the error occurred" }, stackTrace: { type: "string", description: "Optional stack trace" } }, required: ["type", "message", "context"] }, metadata: { type: "object", properties: { severity: { type: "string", enum: ["low", "medium", "high", "critical"], description: "Severity level of the error" }, environment: { type: "object", properties: { os: { type: "string" }, nodeVersion: { type: "string" }, dependencies: { type: "object", additionalProperties: { type: "string" } } } } } }, verificationSteps: { type: "array", items: { type: "object", properties: { command: { type: "string", description: "Command to run" }, expectedOutput: { type: "string", description: "Expected output" }, successIndicators: { type: "array", items: { type: "string" }, description: "Indicators of success" } }, required: ["command", "expectedOutput", "successIndicators"] } } }, required: ["name", "entityType", "observations", "errorPattern", "verificationSteps"] } }, required: ["lesson"] }
  • index.ts:1096-1165 (registration)
    Registration of the create_lesson tool in the ListTools response, including name, description, and schema.
    { name: "create_lesson", description: "Create a new lesson from an error and its solution", inputSchema: { type: "object", properties: { lesson: { type: "object", properties: { name: { type: "string", description: "Unique identifier for the lesson" }, entityType: { type: "string", enum: ["lesson"], description: "Must be 'lesson'" }, observations: { type: "array", items: { type: "string" }, description: "List of observations about the error and solution" }, errorPattern: { type: "object", properties: { type: { type: "string", description: "Category of the error" }, message: { type: "string", description: "The error message" }, context: { type: "string", description: "Where the error occurred" }, stackTrace: { type: "string", description: "Optional stack trace" } }, required: ["type", "message", "context"] }, metadata: { type: "object", properties: { severity: { type: "string", enum: ["low", "medium", "high", "critical"], description: "Severity level of the error" }, environment: { type: "object", properties: { os: { type: "string" }, nodeVersion: { type: "string" }, dependencies: { type: "object", additionalProperties: { type: "string" } } } } } }, verificationSteps: { type: "array", items: { type: "object", properties: { command: { type: "string", description: "Command to run" }, expectedOutput: { type: "string", description: "Expected output" }, successIndicators: { type: "array", items: { type: "string" }, description: "Indicators of success" } }, required: ["command", "expectedOutput", "successIndicators"] } } }, required: ["name", "entityType", "observations", "errorPattern", "verificationSteps"] } }, required: ["lesson"] } },
  • MCP CallToolRequestSchema handler case that dispatches to the createLesson function with tool arguments.
    case "create_lesson": return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.createLesson(args.lesson as LessonEntity), null, 2) }] };
  • TypeScript interface definition for LessonEntity used in the create_lesson tool.
    interface LessonEntity extends Entity { errorPattern: ErrorPattern; metadata: Metadata; verificationSteps: VerificationStep[]; }

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