<RETURN_TO_BASE

How to Implement Persistent Memory with a Local Knowledge Graph in Claude Desktop

This guide explains how to implement persistent memory in Claude Desktop using a local knowledge graph, enabling personalized and consistent AI conversations across multiple chats.

Introducing Knowledge Graph Memory Server in Claude Desktop

The Knowledge Graph Memory Server enables Claude Desktop to retain and organize user information across multiple chat sessions. It can store user preferences, past interactions, and personal details, which are structured as a knowledge graph. This structure allows Claude to understand the relationships between different data points, resulting in more personalized and less repetitive responses.

Setting Up Persistent Memory

This tutorial guides you through implementing a basic persistent memory system using a local knowledge graph within Claude Desktop. This setup helps Claude remember user information across chats, enhancing the personalization and consistency of responses.

Step 1: Installing Dependencies

Node.js Installation

To run the Knowledge Graph Memory Server via npx, Node.js is required. Download the latest Node.js version from nodejs.org and install it using default settings.

Claude Desktop Installation

Download the latest Claude Desktop version from https://claude.ai/download. To connect Claude to your MCP server, edit or create the claude_desktop_config.json file in the Claude directory using any text editor.

Step 2: Configuring the MCP Server

Create or edit the mcp.json file with the following configuration to set up the memory server:

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

Step 3: Configuring Claude Settings

Open Claude and navigate to File > Settings > Claude Settings > Configure. In the Personal Preferences section, add the following instructions:

  1. User Identification: Assume interaction with default_user. Proactively identify this user if not already done.
  2. Memory Retrieval: Start each chat by saying "Remembering..." and retrieve all pertinent information from your knowledge graph memory.
  3. Memory: During conversations, pay attention to new information about:
    • Basic Identity (age, gender, location, job, education)
    • Behaviors (interests, habits)
    • Preferences (communication style, language)
    • Goals (targets, aspirations)
    • Relationships (up to 3 degrees of personal/professional connections)
  4. Memory Update: When new info is gathered:
    • Create entities for recurring organizations, people, events
    • Link them with relationships
    • Store related facts as observations

Utilizing MCP Tools

After configuration, nine MCP tools become available for managing the Knowledge Graph Server. These include creating entities and relationships, adding and deleting observations, reading and searching the graph, and opening nodes. The preference text ensures Claude automatically uses these tools during chats.

Persistent Memory Across Chats

Claude retains the memory of previous conversations via the knowledge graph, even when starting new chats. This integration allows real-time creation, modification, and utilization of knowledge, enhancing Claude’s capabilities in tasks like database management and SQL query generation. The memory system makes Claude a smarter, more responsive, and consistent assistant.

For more information and advanced resources on the Knowledge Memory Server, visit the official documentation and community links.

Stay connected with us on Twitter, Telegram, and LinkedIn, and join our 90k+ ML SubReddit. Also, consider registering for the miniCON Virtual Conference on AGENTIC AI for free training and workshops.

🇷🇺

Сменить язык

Читать эту статью на русском

Переключить на Русский