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
- Open your Cursor project folder in your file explorer
- Check if a
.cursor
folder exists at the root of your project- If it doesn’t exist, create a new folder named
.cursor
- If it doesn’t exist, create a new folder named
- Inside the
.cursor
folder, check ifmcp.json
exists- If it doesn’t exist, create a new file named
mcp.json
- If it doesn’t exist, create a new file named
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:
-
Using environment variables (as shown in Step 2):
- Edit the
MEMORY_FILE_PATH
value in yourmcp.json
file
- Edit the
-
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:
- Open Cursor and go to your project
- Click on the “Rules” button in the Cursor interface (or press Ctrl+Shift+R)
- 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:
- Save all your changes
- Close and restart Cursor completely
- 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:
-
Retrieving information: Start your prompt with “What do you remember about…” or “Tell me what you know about…”
-
Storing information: At the end of your conversation, you can say “Please remember that…” followed by what you want Cursor to remember
-
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!