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[];
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Create' implies a write/mutation operation, the description doesn't address critical aspects: permission requirements, whether creation is idempotent or can overwrite existing lessons, what happens on failure, or what the response contains. For a complex creation tool with nested objects, this leaves significant behavioral uncertainty.

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, focused sentence with zero wasted words. It front-loads the core action ('Create a new lesson') and immediately specifies the source material. Every word contributes essential information, making it optimally concise for its purpose.

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?

For a creation tool with complex nested parameters (1 parameter with 6+ sub-properties), no annotations, and no output schema, the description is insufficient. It doesn't explain the creation workflow, success/failure behavior, return values, or how the input structure relates to the described 'error and its solution' concept. The agent must rely entirely on the raw schema without contextual guidance.

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 description mentions the parameter's purpose ('from an error and its solution'), which provides high-level context for the 'lesson' object. However, with 0% schema description coverage and 1 complex nested parameter containing multiple sub-properties, the description doesn't explain the structure, required fields beyond what the schema shows, or how 'error' and 'solution' map to specific properties like 'errorPattern' and 'verificationSteps'. It adds minimal value beyond the schema's structural definition.

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 verb 'Create' and the resource 'new lesson', specifying it's created 'from an error and its solution'. This distinguishes it from generic creation tools like 'create_entities' by focusing on error-based lesson creation. However, it doesn't explicitly differentiate from 'update_lesson_success' which might also involve lesson modifications.

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 like 'create_entities' (for general entity creation) or 'update_lesson_success' (for modifying existing lessons). It mentions the source material ('from an error and its solution') but doesn't specify prerequisites, constraints, or appropriate contexts for invocation.

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

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