Knowledge Graph MCP server

Provides persistent memory for Claude through a local knowledge graph that stores entities with observations and relations, enabling structured information retrieval and complex context retention across conversations.
Back to servers
Provider
itseasy21
Release date
Mar 18, 2025
Language
TypeScript
Package
Stats
5.4K downloads
49 stars

This MCP knowledge graph server provides a persistent memory system for Claude using a local knowledge graph structure, enabling Claude to remember information across conversations with customizable storage locations.

Installation Options

Using Smithery (Recommended)

The easiest way to install the Knowledge Graph Memory Server is via Smithery:

npx -y @smithery/cli install @itseasy21/mcp-knowledge-graph --client claude

Manual Configuration

Add the server to your MCP configuration file (mcp.json or claude_desktop_config.json):

{
    "mcpServers": {
      "memory": {
        "command": "npx",
        "args": [
          "-y",
          "@itseasy21/mcp-knowledge-graph"
        ],
        "env": {
          "MEMORY_FILE_PATH": "/path/to/your/memory.jsonl"
        }
      }
    }
}

Custom Memory Path Configuration

You can specify where the memory file is stored in two ways:

Using Command-Line Arguments

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "@itseasy21/mcp-knowledge-graph", "--memory-path", "/path/to/your/memory.jsonl"]
    }
  }
}

Using Environment Variables

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "@itseasy21/mcp-knowledge-graph"],
      "env": {
        "MEMORY_FILE_PATH": "/path/to/your/memory.jsonl"
      }
    }
  }
}

If no path is specified, the server will default to memory.jsonl in its installation directory.

Understanding the Knowledge Graph

Entities

Entities are the main nodes in the knowledge graph, representing people, organizations, events, etc.

Each entity contains:

  • A unique name (identifier)
  • An entity type (classification)
  • A list of observations (facts)
  • Creation date and version tracking

Example entity:

{
  "name": "John_Smith",
  "entityType": "person",
  "observations": ["Speaks fluent Spanish"]
}

Relations

Relations define connections between entities, always stored in active voice.

Example relation:

{
  "from": "John_Smith",
  "to": "Anthropic",
  "relationType": "works_at"
}

Observations

Observations are discrete facts about entities:

  • 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"
  ]
}

API Tools

Creating Entities

{
  "entities": [
    {
      "name": "John_Smith",
      "entityType": "person",
      "observations": ["Speaks Spanish", "Lives in Seattle"]
    },
    {
      "name": "Anthropic",
      "entityType": "organization",
      "observations": ["AI research company"]
    }
  ]
}

Creating Relations

{
  "relations": [
    {
      "from": "John_Smith",
      "to": "Anthropic",
      "relationType": "works_at"
    }
  ]
}

Adding Observations

{
  "observations": [
    {
      "entityName": "John_Smith",
      "contents": ["Has a dog named Rex", "Enjoys hiking"]
    }
  ]
}

Deleting Entities

{
  "entityNames": ["SomeEntity"]
}

Deleting Observations

{
  "deletions": [
    {
      "entityName": "John_Smith",
      "observations": ["Has a dog named Rex"]
    }
  ]
}

Deleting Relations

{
  "relations": [
    {
      "from": "John_Smith",
      "to": "Anthropic",
      "relationType": "works_at"
    }
  ]
}

Reading the Graph

This tool takes no parameters and returns the entire knowledge graph.

Searching Nodes

{
  "query": "Seattle"
}

Opening Specific Nodes

{
  "names": ["John_Smith", "Anthropic"]
}

Using with Claude

Example System Prompt

Here's an example prompt for chat personalization that you can use in Claude's "Custom Instructions" field:

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

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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