Knowledge Graph MCP server

Enables persistent memory and structured knowledge management for enhanced personalization and context retention in natural language interactions through a local graph database.
Back to servers
Setup instructions
Provider
Shane Holloman
Release date
Dec 26, 2024
Language
TypeScript
Stats
714 stars

This MCP Knowledge Graph server provides persistent memory for AI models through a local knowledge graph, allowing you to store and retrieve information across conversations using entities, relations, and observations. It works with Claude Code/Desktop and any MCP-compatible AI platform.

Installation and Setup

Global Memory Setup (Recommended)

Add the following configuration to your claude_desktop_config.json or .claude.json file:

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-knowledge-graph",
        "--memory-path",
        "/Users/yourusername/.aim/"
      ]
    }
  }
}

This creates memory files in your specified directory:

  • memory.jsonl - Master Database (default for all operations)
  • memory-work.jsonl - Work database
  • memory-personal.jsonl - Personal database

Project-Local Memory Setup

To use project-specific memory, create a .aim directory in any project:

mkdir .aim

When run from this project, memory tools will automatically use .aim/memory.jsonl (project-local master database) instead of global storage.

Understanding the Storage System

Storage Organization

Global Setup:

/Users/yourusername/.aim/
├── memory.jsonl           # Master Database (default)
├── memory-work.jsonl      # Work database
├── memory-personal.jsonl  # Personal database
└── memory-health.jsonl    # Health database

Project Setup:

my-project/
├── .aim/
│   ├── memory.jsonl       # Project Master Database (default)
│   └── memory-work.jsonl  # Project Work database
└── src/

Storage Logic Priority

  1. Project with .aim - Uses .aim/memory.jsonl (project-local)
  2. No project/no .aim - Uses configured global directory
  3. Contexts - Adds suffix: memory-work.jsonl, memory-personal.jsonl

Available Tools

  • aim_create_entities - Add new people, projects, events
  • aim_create_relations - Link entities together
  • aim_add_observations - Add facts to existing entities
  • aim_search_nodes - Find information by keyword
  • aim_read_graph - View entire memory
  • aim_open_nodes - Retrieve specific entities by name
  • aim_list_databases - Show all available databases and current location
  • aim_delete_entities - Remove entities
  • aim_delete_observations - Remove specific facts
  • aim_delete_relations - Remove connections

Common Parameters

  • context (optional) - Specify named database (work, personal, etc.). Defaults to master database
  • location (optional) - Force project or global storage location. Defaults to auto-detection

Usage Examples

Using the Master Database (Default)

aim_create_entities({
  entities: [{
    name: "John_Doe",
    entityType: "person",
    observations: ["Met at conference"]
  }]
})

Using Named Databases

// Work database
aim_create_entities({
  context: "work",
  entities: [{
    name: "Q4_Project",
    entityType: "project",
    observations: ["Due December 2024"]
  }]
})

// Personal database
aim_create_entities({
  context: "personal",
  entities: [{
    name: "Mom",
    entityType: "person",
    observations: ["Birthday March 15th"]
  }]
})

Specifying Storage Location

aim_create_entities({
  location: "global",
  entities: [{
    name: "Important_Info",
    entityType: "reference",
    observations: ["Stored in global master database"]
  }]
})

Database Discovery

Use aim_list_databases to see all available databases:

{
  "project_databases": [
    "default",      // Master Database (project-local)
    "project-work"  // Named database
  ],
  "global_databases": [
    "default",      // Master Database (global)
    "work",
    "personal",
    "health"
  ],
  "current_location": "project (.aim directory detected)"
}

Advanced Configuration

Home Directory Setup

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-knowledge-graph",
        "--memory-path",
        "/Users/yourusername/.aim"
      ]
    }
  }
}

Custom Location (e.g., Dropbox)

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-knowledge-graph",
        "--memory-path",
        "/Users/yourusername/Dropbox/.aim"
      ]
    }
  }
}

Auto-approve All Operations

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-knowledge-graph",
        "--memory-path",
        "/Users/yourusername/.aim"
      ],
      "autoapprove": [
        "aim_create_entities",
        "aim_create_relations",
        "aim_add_observations",
        "aim_search_nodes",
        "aim_read_graph",
        "aim_open_nodes",
        "aim_list_databases"
      ]
    }
  }
}

Troubleshooting

"File does not contain required _aim safety marker" error

  • The file may not belong to this system
  • Manual JSONL files need {"type":"_aim","source":"mcp-knowledge-graph"} as first line
  • If you created the file manually, add the _aim marker or delete and let the system recreate it

Memories going to unexpected locations

  • Check if you're in a project directory with .aim folder (uses project-local storage)
  • Otherwise uses the configured global --memory-path directory
  • Use aim_list_databases to see all available databases and current location
  • Use ls .aim/ or ls /Users/yourusername/.aim/ to see your memory files

Requirements

  • Node.js 18+
  • MCP-compatible AI platform

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","mcp-knowledge-graph","--memory-path","/Users/shaneholloman/Dropbox/shane/db/memory.jsonl"],"autoapprove":["create_entities","create_relations","add_observations","delete_entities","delete_observations","delete_relations","read_graph","search_nodes","open_nodes"]}'

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",
                "mcp-knowledge-graph",
                "--memory-path",
                "/Users/shaneholloman/Dropbox/shane/db/memory.jsonl"
            ],
            "autoapprove": [
                "create_entities",
                "create_relations",
                "add_observations",
                "delete_entities",
                "delete_observations",
                "delete_relations",
                "read_graph",
                "search_nodes",
                "open_nodes"
            ]
        }
    }
}

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",
                "mcp-knowledge-graph",
                "--memory-path",
                "/Users/shaneholloman/Dropbox/shane/db/memory.jsonl"
            ],
            "autoapprove": [
                "create_entities",
                "create_relations",
                "add_observations",
                "delete_entities",
                "delete_observations",
                "delete_relations",
                "read_graph",
                "search_nodes",
                "open_nodes"
            ]
        }
    }
}

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