memories-with-lessons-mcp-server
by: T1nker-1220
I enhance the existing memory mcp server from the official mcp github, so big thanks and credits for creating this
📌Overview
Purpose: The Knowledge Graph Memory Server is designed to provide persistent memory capabilities for Claude, enabling it to remember user information across conversations and learn from past errors through a lesson system.
Overview: This framework utilizes a local knowledge graph to maintain entities, relationships, and lessons, allowing for efficient storage and retrieval of user-related data. By keeping track of observations and error patterns, the server aims to improve user interactions and enhance Claude's reliability in providing assistance.
Key Features:
-
Entity Management: Create, modify, and delete entities in the knowledge graph, allowing it to hold unique identifiers, types, and related observations about users.
-
Lesson Tracking: Capture lessons related to errors and solutions, including detailed information on error patterns, metadata, and steps for verification, thereby enabling continuous learning and improvement.
-
API Tools: A robust set of tools for creating entities, establishing relationships, adding and removing observations, managing lessons, and searching the graph, ensuring comprehensive functionality and ease of use.
Knowledge Graph Memory Server
A basic implementation of persistent memory using a local knowledge graph, allowing Claude to remember user information across chats and learn from past errors through a lesson system.
Core Concepts
Entities
- Unique Name: Identifier for the entity.
- Entity Type: Classification (e.g., "person", "organization").
- Observations: List of facts about the entity.
Example:
{
"name": "John_Smith",
"entityType": "person",
"observations": ["Speaks fluent Spanish"]
}
Relations
Define connections between entities, stored in active voice.
Example:
{
"from": "John_Smith",
"to": "Anthropic",
"relationType": "works_at"
}
Observations
Discrete pieces of information about an entity.
- Stored as strings.
- Attached to specific entities.
- Atomic (one fact per observation).
Example:
{
"entityName": "John_Smith",
"observations": [
"Speaks fluent Spanish",
"Graduated in 2019",
"Prefers morning meetings"
]
}
Lessons
Special entities that capture knowledge about errors and solutions.
Components:
- Unique Name
- Error Pattern (type, message, context)
- Solution Steps and Verification
- Metadata (severity, timestamps, frequency)
Example:
{
"name": "NPM_VERSION_MISMATCH_01",
"entityType": "lesson",
"observations": [
"Error occurs when using incompatible package versions",
"Affects Windows environments",
"Resolution requires version pinning"
],
"errorPattern": {
"type": "dependency",
"message": "Cannot find package @shadcn/ui",
"context": "package installation"
},
"metadata": {
"severity": "high",
"frequency": 1,
"successRate": 1.0
}
}
API
Tools
- create_entities: Create multiple new entities.
- create_relations: Create new relations between entities.
- add_observations: Add new observations to existing entities.
- delete_entities: Remove entities and their relations.
- delete_observations: Remove specific observations from entities.
- delete_relations: Remove specific relations.
- read_graph: Read the entire knowledge graph.
- search_nodes: Search for nodes based on a query.
- open_nodes: Retrieve specific nodes by name.
Lesson Management Tools
- create_lesson: Create a new lesson from an error and its solution.
- find_similar_errors: Find similar errors and their solutions.
- update_lesson_success: Update success tracking for a lesson.
- get_lesson_recommendations: Get relevant lessons for the current context.
File Management
Handles two types of files:
memory.json
: Stores entities and relations.lesson.json
: Stores lesson entities.
Files are split if they exceed 1000 lines for performance.
Cursor MCP Client Setup
Steps to Integrate
- Clone the Repository:
git clone [repository-url] cd [repository-name]
- Install Dependencies:
pnpm install
- Build the Project:
pnpm build
- Configure the Server:
node /path/to/the/dist/index.js
- Activate in Cursor:
- Use keyboard shortcut
Ctrl+Shift+P
. - Type "reload window" and select it.
- Use keyboard shortcut
Usage with Claude Desktop
Setup for Different Environments
Docker
{
"mcpServers": {
"memory": {
"command": "docker",
"args": ["run", "-i", "-v", "claude-memory:/app/dist", "--rm", "mcp/memory"]
}
}
}
NPX
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"]
}
}
}
System Prompt
Customize the interaction prompt for better memory utilization.
Building with Docker
docker build -t mcp/memory -f src/memory/Dockerfile .
License
Licensed under the MIT License, allowing usage, modification, and distribution under specified terms.
Acknowledgments
Special thanks to the original repository owner for base code enhancements. Model Context Protocol