Memory Knowledge Graph MCP server

Provides a persistent knowledge graph system for maintaining structured memory across conversations, enabling creation, querying, and management of entities and relationships through specialized graph operation tools.
Back to servers
Setup instructions
Provider
okooo5km
Release date
Mar 19, 2025
Language
Swift
Stats
94 stars

The Memory MCP Server provides knowledge graph management capabilities for large language models. It allows AI assistants to create, read, update, and delete entities and relations in a persistent knowledge graph, maintaining memory across conversations. This Swift implementation requires macOS 14.0 or later.

Installation Options

Quick Installation

Install the server with a simple one-line command:

curl -fsSL https://raw.githubusercontent.com/okooo5km/memory-mcp-server/main/install.sh | bash

This will:

  • Create ~/.local/bin directory if needed
  • Add this directory to your PATH
  • Download and install the latest version
  • Make the binary executable

Building from Source

  1. Clone the repository:
git clone https://github.com/okooo5km/memory-mcp-server.git
cd memory-mcp-server
  1. Build the project:
swift build -c release
  1. Install the binary:
mkdir -p ~/.local/bin
cp $(swift build -c release --show-bin-path)/memory-mcp-server ~/.local/bin/
  1. Add to your PATH:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc  # or ~/.bashrc
source ~/.zshrc  # or source ~/.bashrc

Command Line Options

# Display help information
memory-mcp-server --help

# Display version information
memory-mcp-server --version

Configuration

Environment Variables

Configure the storage location for your knowledge graph:

export MEMORY_FILE_PATH="/path/to/your/memory.json"

If not specified, it defaults to memory.json in the current directory.

Integration with AI Tools

Claude.app Configuration

Add to your Claude settings:

"mcpServers": {
  "memory": {
    "command": "memory-mcp-server",
    "env": {
      "MEMORY_FILE_PATH": "/path/to/your/memory.json"
    }
  }
}

Cursor Configuration

Add to your Cursor editor's Settings - mcp.json:

{
  "mcpServers": {
    "memory": {
      "command": "memory-mcp-server",
      "env": {
        "MEMORY_FILE_PATH": "/path/to/your/memory.json"
      }
    }
  }
}

Available Tools

Entity Management

  • create_entities: Add multiple new entities to the knowledge graph
  • delete_entities: Remove entities and their relations
  • add_observations: Add new observations to existing entities
  • delete_observations: Remove specific observations from entities

Relation Management

  • create_relations: Create relationships between entities
  • delete_relations: Remove specific relations

Query Tools

  • read_graph: Retrieve the entire knowledge graph
  • search_nodes: Find nodes matching a query string
  • open_nodes: Retrieve specific entities by name

Usage Examples

Creating Entities

{
  "entities": [
    {
      "name": "John Smith",
      "entityType": "Person",
      "observations": ["Software engineer", "Lives in San Francisco", "Enjoys hiking"]
    },
    {
      "name": "Acme Corp",
      "entityType": "Company",
      "observations": ["Founded in 2010", "Tech startup"]
    }
  ]
}

Creating Relations

{
  "relations": [
    {
      "from": "John Smith",
      "to": "Acme Corp",
      "relationType": "works at"
    }
  ]
}

Adding Observations

{
  "observations": [
    {
      "entityName": "John Smith",
      "contents": ["Recently promoted to Senior Engineer", "Working on AI projects"]
    }
  ]
}

Searching Nodes

{
  "query": "San Francisco"
}

Opening Specific Nodes

{
  "names": ["John Smith", "Acme Corp"]
}

Example System Prompt

You have access to a Knowledge Graph memory system, which can store and retrieve information across conversations. Use it to remember important details about the user, their preferences, and any facts they've shared.

When you discover important information, save it using memory tools:
- `create_entities` to add new people, places, or concepts
- `create_relations` to record how entities relate to each other
- `add_observations` to record facts about existing entities

Before answering questions that might require past context, check your memory:
- `search_nodes` to find relevant information
- `open_nodes` to retrieve specific entities
- `read_graph` to get a complete view of your knowledge

Always prioritize information from your memory when responding to the user, especially when they reference past conversations.

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":"memory-mcp-server","env":{"MEMORY_FILE_PATH":"/path/to/your/memory.json"}}'

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": "memory-mcp-server",
            "env": {
                "MEMORY_FILE_PATH": "/path/to/your/memory.json"
            }
        }
    }
}

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": "memory-mcp-server",
            "env": {
                "MEMORY_FILE_PATH": "/path/to/your/memory.json"
            }
        }
    }
}

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