Knowledge Graph Memory MCP: AI Persistent Memory & Entity Mgmt

Knowledge Graph Memory MCP servers empower AI with persistent memory, entity management, and relation tracking through local knowledge graph interaction.

GitHub starsnpm versionnpm downloads

Knowledge Graph Memory Server

Overview

The MCP Knowledge Graph Memory Server provides AI models with persistent memory capabilities using a local knowledge graph. It enables AI to retain and recall information across conversational turns and sessions, enhancing conversational continuity, personalization, and overall intelligence.

Official Server:

Developed and maintained by Anthropic

Key Features

🧠

Persistent Memory

Enables AI models to retain and recall information across sessions

🔗

Entity & Relation Management

Create, update, and delete entities and their relationships

📝

Observation Tracking

Store atomic facts and details associated with entities

🔍

Graph Search & Retrieval

Efficiently search and retrieve information from the knowledge graph

Available Tools

Quick Reference

ToolPurposeCategory
create_entitiesAdd new entities to the graphWrite
create_relationsEstablish relations between entitiesWrite
add_observationsAdd observations to entitiesWrite
delete_entitiesRemove entities and their relationsWrite
delete_observationsDelete specific entity observationsWrite
delete_relationsRemove specific relationsWrite
read_graphRetrieve the entire knowledge graphRead
search_nodesSearch entities by queryDiscovery
open_nodesRetrieve specific entities by nameRead

Detailed Usage

Installation

To get started with the Knowledge Graph Memory Server, follow the installation instructions below. The server can be integrated into various environments, including general setups, Claude Desktop, and VS Code.

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-memory",
        "--port",
        "8000",
        "--data-dir",
        "./memory-data"
      ]
    }
  }
}

Custom Port & Data Directory:

Adjust --port and --data-dir as needed. The --data-dir specifies where your knowledge graph data will be stored persistently.

Common Use Cases

Persistent AI Memory

Store and retrieve long-term memories for AI agents, allowing them to retain information across sessions and interactions.

// Example: Storing a new memory about a user interaction
use_mcp_tool({
  server_name: "memory",
  tool_name: "create_entities",
  arguments: {
    entities: [
      {
        name: "User_Query_123",
        entityType: "interaction",
        observations: ["User asked about product pricing"]
      }
    ]
  }
});

// Example: Retrieving past interactions related to a product
use_mcp_tool({
  server_name: "memory",
  tool_name: "search_nodes",
  arguments: {
    query: "product pricing interaction"
  }
});
Contextual Understanding

Enhance AI's ability to understand complex contexts by providing access to a structured knowledge base of entities and their relationships.

// Example: Adding context about a company's hierarchy
use_mcp_tool({
  server_name: "memory",
  tool_name: "create_entities",
  arguments: {
    entities: [
      { name: "CEO_Alice", entityType: "person" },
      { name: "CTO_Bob", entityType: "person" },
      { name: "Company_X", entityType: "organization" }
    ]
  }
});
use_mcp_tool({
  server_name: "memory",
  tool_name: "create_relations",
  arguments: {
    relations: [
      { from: "CEO_Alice", to: "Company_X", relationType: "leads" },
      { from: "CTO_Bob", to: "Company_X", relationType: "works_at" }
    ]
  }
});

// Example: Querying relationships to understand roles
use_mcp_tool({
  server_name: "memory",
  tool_name: "read_graph",
  arguments: {
    query: "relations involving Company_X"
  }
});
Personalized Experiences

Tailor AI responses and behaviors based on individual user preferences, history, and known facts stored in the knowledge graph.

// Example: Storing user preferences
use_mcp_tool({
  server_name: "memory",
  tool_name: "create_entities",
  arguments: {
    entities: [
      {
        name: "User_Jane",
        entityType: "user",
        observations: ["Prefers dark mode", "Interested in AI news"]
      }
    ]
  }
});

// Example: Retrieving preferences for a personalized response
use_mcp_tool({
  server_name: "memory",
  tool_name: "open_nodes",
  arguments: {
    names: ["User_Jane"]
  }
});
Dynamic Data Integration

Integrate real-time data from various sources into the knowledge graph, allowing AI to access and reason over up-to-date information.

// Example: Adding a new observation from an external API
use_mcp_tool({
  server_name: "memory",
  tool_name: "add_observations",
  arguments: {
    observations: [
      {
        entityName: "Product_A",
        contents: ["Current stock: 150 units (updated 5 mins ago)"]
      }
    ]
  }
});

// Example: Updating a relation based on a system event
use_mcp_tool({
  server_name: "memory",
  tool_name: "create_relations",
  arguments: {
    relations: [
      { from: "Order_XYZ", to: "Product_A", relationType: "contains" }
    ]
  }
});

Sources