Home / MCP / Knowledge Graph Memory Server

Knowledge Graph Memory Server

Provides a persistent local memory store using a knowledge graph with entities, observations, and relations for Claude.

javascript
74.1kstars
Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
    "mcpServers": {
        "memory_docker": {
            "command": "docker",
            "args": [
                "run",
                "-i",
                "-v",
                "claude-memory:/app/dist",
                "--rm",
                "mcp/memory"
            ],
            "env": {
                "MEMORY_FILE_PATH": "/path/to/custom/memory.jsonl"
            }
        }
    }
}

The Knowledge Graph Memory Server provides a persistent memory layer for Claude by storing user information as a local knowledge graph of entities, observations, and their relationships. It helps the model remember details across chats and personalize interactions over time.

How to use

You interact with the Memory Server through an MCP client, which connects to the server to read and update knowledge graph data. Use the server to create entities for recurring people, organizations, or events; define relationships between those entities; and attach atomic observations to entities. As you converse, add new observations (for example, a preferred meeting time or a location) and let the server keep them organized. When your session ends, you can retrieve the memory to guide future conversations or personalize responses.

How to install

Prerequisites: Ensure you have a runtime capable of running the MCP server, such as Node.js or Docker, depending on how you choose to run the server.

{
  "mcpServers": {
    "memory": {
      "command": "docker",
      "args": ["run", "-i", "-v", "claude-memory:/app/dist", "--rm", "mcp/memory"]
    }
  }
}

Alternatively, run the server with NPX to pull and start the memory server directly.

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

If you need a custom path for memory storage, you can specify an environment variable to point to your own file.

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-memory"
      ],
      "env": {
        "MEMORY_FILE_PATH": "/path/to/custom/memory.jsonl"
      }
    }
  }
}

Additional notes

If you prefer to build and run a Docker image locally, you can build the memory server image before running it.

# Build the memory image from source
docker build -t mcp/memory -f src/memory/Dockerfile .

Configuration and environment

You can customize how memory data is stored by pointing to a memory file path. The example below shows how to set MEMORY_FILE_PATH to a custom location.

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-memory"
      ],
      "env": {
        "MEMORY_FILE_PATH": "/path/to/custom/memory.jsonl"
      }
    }
  }
}

Security and hosting notes

Keep memory storage secure and back up the memory file regularly. If you run multiple instances, ensure they share a consistent data location or use separate memory stores to avoid data conflicts.

Tips for memory management

- Create entities for recurring organizations, people, and key events. - Attach atomic observations to each entity to avoid mixing facts. - Use relations to describe how entities interact, such as who works at which organization.

Terminology refresher

- Entity: a primary node in the memory graph with a unique name and type. - Observations: atomic pieces of information about an entity. - Relations: directed connections between entities that describe how they relate.

Available tools

create_entities

Create multiple new entities in the knowledge graph. Input is an array of entities with name, entityType, and observations.

create_relations

Create multiple new relations between entities. Input is an array of relations with from, to, and relationType.

add_observations

Add new observations to existing entities. Returns added observations per entity and fails if the entity does not exist.

delete_entities

Remove entities and their relations. Performs cascading deletion of related data.

delete_observations

Remove specific observations from entities. Silent if the observation does not exist.

delete_relations

Remove specific relations from the graph. Silent if the relation does not exist.

read_graph

Read the entire knowledge graph, returning all entities and relations.

search_nodes

Search for nodes based on a query across names, types, and observations.

open_nodes

Retrieve specific nodes by name along with direct relations between them.