Memories with Lessons MCP server

Enables persistent memory and error tracking for assistants using a local knowledge graph structure with transactional operations, file management, and caching.
Back to servers
Setup instructions
Provider
T1nker-1220
Release date
Feb 14, 2025
Language
TypeScript
Stats
51 stars

The Knowledge Graph Memory Server provides persistent memory for Claude across conversations using a local knowledge graph. It enables Claude to remember user information and learn from past errors through a comprehensive lesson system.

Installation

Prerequisites

You need to have Node.js and npm or pnpm installed on your system.

Installation Methods

Using Cursor MCP Client

  1. Clone the repository:

    git clone [repository-url]
    cd [repository-name]
    
  2. Install dependencies:

    pnpm install
    
  3. Build the project:

    pnpm build
    
  4. Configure the server:

    • Find the full path to the built server file: /path/to/the/dist/index.js
    • Start the server using Node.js: node /path/to/the/dist/index.js
  5. Activate in Cursor:

    • Use keyboard shortcut Ctrl+Shift+P
    • Type "reload window" and select it
    • Wait for the MCP server to activate
    • Select the stdio type when prompted

Using Claude Desktop

Add the server configuration to your claude_desktop_config.json file using one of these methods:

Docker Option
{
  "mcpServers": {
    "memory": {
      "command": "docker",
      "args": ["run", "-i", "-v", "claude-memory:/app/dist", "--rm", "mcp/memory"]
    }
  }
}
NPX Option
{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-memory"
      ]
    }
  }
}
Customized NPX Option
{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-memory"
      ],
      "env": {
        "MEMORY_FILE_PATH": "/path/to/custom/memory.json"
      }
    }
  }
}

Usage

Knowledge Graph API

Managing Entities

Use these tools to create and manage the basic building blocks of the knowledge graph:

Creating Entities
{
  "entities": [
    {
      "name": "John_Smith",
      "entityType": "person",
      "observations": ["Speaks fluent Spanish", "Graduated in 2019"]
    }
  ]
}
Creating Relations
{
  "relations": [
    {
      "from": "John_Smith",
      "to": "Anthropic",
      "relationType": "works_at"
    }
  ]
}
Adding Observations
{
  "observations": [
    {
      "entityName": "John_Smith",
      "contents": ["Prefers morning meetings"]
    }
  ]
}

Querying the Graph

Access stored information with these tools:

Reading the Full Graph

Use read_graph without any parameters to retrieve the complete knowledge graph.

Searching for Specific Nodes
{
  "query": "Spanish speaker"
}
Opening Specific Nodes
{
  "names": ["John_Smith", "Anthropic"]
}

Lesson Management System

The lesson system helps Claude learn from past errors:

Creating a Lesson
{
  "lesson": {
    "name": "NPM_VERSION_MISMATCH_01",
    "entityType": "lesson",
    "observations": [
      "Error occurs when using incompatible package versions",
      "Affects Windows environments specifically"
    ],
    "errorPattern": {
      "type": "dependency",
      "message": "Cannot find package @shadcn/ui",
      "context": "package installation"
    },
    "metadata": {
      "severity": "high",
      "environment": {
        "os": "windows",
        "nodeVersion": "18.x"
      }
    },
    "verificationSteps": [
      {
        "command": "pnpm add shadcn@latest",
        "expectedOutput": "Successfully installed shadcn",
        "successIndicators": ["added shadcn"]
      }
    ]
  }
}
Finding Similar Errors
{
  "errorPattern": {
    "type": "dependency",
    "message": "Cannot find package",
    "context": "installation"
  }
}
Updating Lesson Success
{
  "lessonName": "NPM_VERSION_MISMATCH_01",
  "success": true
}

System Prompt for Memory Usage

Add this prompt to Claude's "Custom Instructions" in a Claude.ai Project:

Follow these steps for each interaction:

1. User Identification:
   - You should assume that you are interacting with default_user
   - If you have not identified default_user, proactively try to do so.

2. Memory Retrieval:
   - Always begin your chat by saying only "Remembering..." and retrieve all relevant information from your knowledge graph
   - Always refer to your knowledge graph as your "memory"

3. Memory
   - While conversing with the user, be attentive to any new information that falls into these categories:
     a) Basic Identity (age, gender, location, job title, education level, etc.)
     b) Behaviors (interests, habits, etc.)
     c) Preferences (communication style, preferred language, etc.)
     d) Goals (goals, targets, aspirations, etc.)
     e) Relationships (personal and professional relationships up to 3 degrees of separation)

4. Memory Update:
   - If any new information was gathered during the interaction, update your memory as follows:
     a) Create entities for recurring organizations, people, and significant events
     b) Connect them to the current entities using relations
     b) Store facts about them as observations

Configuration Options

The server can be configured using these environment variables:

  • MEMORY_FILE_PATH: Custom path for the memory storage file (default: memory.json in the server directory)

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "memory" '{"command":"npx","args":["-y","@modelcontextprotocol/server-memory"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "memory": {
            "command": "npx",
            "args": [
                "-y",
                "@modelcontextprotocol/server-memory"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "memory": {
            "command": "npx",
            "args": [
                "-y",
                "@modelcontextprotocol/server-memory"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later