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
651 stars

MCP Knowledge Graph serves as persistent memory for AI models through a local knowledge graph system. It allows you to store and retrieve information across conversations using entities, relations, and observations, working with Claude Code/Desktop and any MCP-compatible AI platform.

Installation

Global Memory Setup (Recommended)

Add this 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 your project:

mkdir .aim

Now memory tools automatically use .aim/memory.jsonl (project-local master database) when run from this project.

Usage

Database Organization

The system uses the following storage logic:

  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

The master database is your primary memory store and is used by default when no specific database is requested.

File Structure

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/

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

Using the Tools

Here are examples of how to use the memory tools:

// Master Database (default - no context needed)
aim_create_entities({
  entities: [{
    name: "John_Doe",
    entityType: "person",
    observations: ["Met at conference"]
  }]
})

// 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"]
  }]
})

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

Database Discovery

Use the aim_list_databases tool to see all available databases:

aim_list_databases()

This returns information like:

{
  "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

Custom Memory Location

You can specify any directory for your memory files:

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

Auto-approve Operations

To avoid confirmation prompts for certain 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 Safety Marker Error

If you see "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
  • Delete the file and let the system recreate it

Memory Location Issues

If memories are stored in unexpected locations:

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

Database Management

If you have too many similar databases:

  • Manually delete unwanted database files if needed
  • Encourage AI to use simple, consistent database names
  • Remember that the master database is always available as the default

System 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