[MCP] Add Persistent Memory in Cursor

Hey Cursor community!

I wanted to share a solution I’ve been working on that adds persistent memory capabilities to Cursor. If you’ve ever been frustrated by Cursor forgetting important context between sessions, this is for you!

What is mcp-knowledge-graph?

The @itseasy21/mcp-knowledge-graph package is an improved implementation of persistent memory using a local knowledge graph with a customizable memory path. It lets Cursor remember information about you and your projects across chats.

Key features:

  • Persistent Memory: Cursor remembers information between sessions
  • Customizable Memory Path: Store your memory file anywhere on your system
  • Knowledge Graph Structure: Organized as entities, relations, and observations
  • Simple Setup: Easy to configure in your Cursor environment

How to Set It Up (Beginner-Friendly Guide)

Prerequisites

  • Cursor installed on your computer
  • Basic familiarity with JSON format
  • Node.js installed (comes with npm/npx)

Step 1: Create the Configuration File

  1. Open your Cursor project folder in your file explorer
  2. Check if a .cursor folder exists at the root of your project
    • If it doesn’t exist, create a new folder named .cursor
  3. Inside the .cursor folder, check if mcp.json exists
    • If it doesn’t exist, create a new file named mcp.json

Note for beginners: The dot (.) in front of .cursor means it’s a hidden folder. You might need to enable “Show hidden files” in your file explorer to see it.

Step 2: Configure the Memory Server

Copy and paste this configuration into your mcp.json file:

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

Important: Replace /path/to/your/project_name.jsonl with an actual path on your computer where you want to store the memory file. For example:

  • Windows: C:\Users\YourName\Documents\cursor_memory\project_name.jsonl
  • macOS/Linux: /Users/YourName/Documents/cursor_memory/project_name.jsonl

Make sure the directory exists before saving the file.

Step 3: Customize the Memory Path (Optional)

You can customize where your memory file is stored in two ways:

  1. Using environment variables (as shown in Step 2):

    • Edit the MEMORY_FILE_PATH value in your mcp.json file
  2. Using command-line arguments:

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

Tip for beginners: Using a consistent memory path for each project helps Cursor maintain separate memories for different projects.

Step 4: Set Up Memory Rules

In your Cursor project, you need to tell Cursor how to use the memory. Add these rules to your project:

  1. Open Cursor and go to your project
  2. Click on the “Rules” button in the Cursor interface (or press Ctrl+Shift+R)
  3. Add the following rules:
# Memory Management
- Start with "Remembering..." and read what you stored in memory before working on a task
- Reference knowledge as "memory"
- When the assigned task is done:
  1. Create/update entities
  2. Define relationships
  3. Store observations

Step 5: Restart Cursor

After setting up the configuration:

  1. Save all your changes
  2. Close and restart Cursor completely
  3. Open your project again

Troubleshooting

  • Memory not working? Make sure the path to your memory file exists and is writable
  • Configuration errors? Check your JSON syntax for missing commas or brackets
  • Package not found? Make sure you have an internet connection when first running Cursor with this setup

How to Use Memory in Conversations

Once set up, you can interact with Cursor’s memory in these ways:

  1. Retrieving information: Start your prompt with “What do you remember about…” or “Tell me what you know about…”

  2. Storing information: At the end of your conversation, you can say “Please remember that…” followed by what you want Cursor to remember

  3. Using memory in tasks: When asking Cursor to help with a task, it will automatically use relevant information from its memory

Benefits for Developers

  • Cursor remembers your project structure and preferences
  • Maintains context about your coding style and previous discussions
  • Improves productivity by reducing repetitive explanations
  • Works across multiple projects with custom memory paths

Getting Started

The package is available on npm as @itseasy21/mcp-knowledge-graph (currently at version 1.0.5).

For more details, check out the GitHub repository.

Has anyone else been experimenting with memory solutions for Cursor? I’d love to hear your experiences or answer any questions about this implementation!

5 Likes

Could you please give more detailed instructions on how to use this tool for beginners?

I have updated the initial post with more instructions, maybe this will help

2 Likes

Hey , thank you for the post. I decided to give it a try. I followed your instructions, there are no errors, but the project_name.jsonl is still empty. Any idea how to debug?

@ krlozanov I can push a debug version for you, but before that could you please navigate to Output tab near the Terminal section, and select the Cursor MCP in the extension and share the logs from there.

Something like this:

1 Like

I’m excited to share a significant update to our knowledge graph memory solution that adds version tracking capabilities alongside persistent memory for Cursor. This enhancement helps maintain historical context of how your project knowledge evolves over time!

Just restart cusor and ideally that should update it to the latest version 1.0.7

how does your tool differ from anthropics memory MCP tool? that one writes also to a json file but theirs is standardized and verified. Most of the steps you provide are copied from the original anthropic repo.

Our tool is a fork of Anthropic’s original memory server with several key improvements. The main differences are:

  1. Our implementation adds version tracking and creation timestamps for entities and relations, allowing you to see how knowledge evolves over time,
  2. We’ve implemented proper update functions that maintain version history,
  3. Our tool uses a customizable memory path that persists between sessions rather than the ephemeral approach in the original, and
  4. While we maintain compatibility with the original format, we’ve enhanced the structure to support more robust knowledge tracking. The setup steps are similar because both tools follow the MCP protocol standard, but our implementation offers these additional features for better memory management.
1 Like

Cool, thanks for the update. will try out your version.

I had to set up my mcp.json to call cmd /c to get the server to actually be ran. ex:

"command": "cmd /c npx",
      "args": ["-y", "@itseasy21/mcp-knowledge-graph", "--memory-path", "your memory path"]

it seems that there is no tool to store the knowgraph into the file.


.Then the file is empty.

The knowledge graph server automatically persists data to the configured JSONL file (default: memory.jsonl) on every operation. The storage happens transparently through the standard create/update methods without requiring explicit save commands. You can verify this by checking their configured MEMORY_FILE_PATH location or passing the --memory-path argument. The persistence is handled by the server’s core infrastructure.

In case you are facing issues, make sure the file exists, if not create an empty file and make sure it has writing permissions.

1 Like