Lesson
Foundation: Building AI Memory with MCP and Cursor
Learn how to give your AI coding assistant a long-term memory for your projects using Basic Memory, a tool that stores knowledge in local Markdown files.
- Access
- Included
- Transcript
- Needs source
AI coding assistants are incredibly powerful, but their memory is often ephemeral. They forget context between conversations, forcing you to repeat information and lose valuable insights. This lesson introduces basic-memory, a knowledge management system that solves this by allowing your AI assistant to build a persistent, local knowledge graph using simple Markdown files.
basic-memory integrates directly with Cursor via the Model Context Protocol (MCP), enabling your AI to read and write notes about your project. This creates a long-term memory that the AI can access and build upon over time, all stored as human-readable files right in your project directory.
Workflow Demonstrated
- Install and Initialize: Use a single command to install
basic-memoryand initialize a new memory store for your current project. - Configure the MCP Server: Create a simple
mcp.jsonfile in your.cursordirectory to connectbasic-memoryto Cursor's tool system. - Write to Memory: Use a natural language prompt in Cursor to instruct the AI to create a new note, which
basic-memorysaves as a Markdown file. - Read from Memory: Ask the AI to retrieve and summarize existing notes, demonstrating its ability to access its long-term, project-specific knowledge.
Key Benefits
- Persistent Knowledge: Your AI can pick up conversations right where you left off, retaining context from previous interactions.
- Local-First & Human-Readable: All knowledge is stored as structured Markdown files on your computer, which you can read and edit directly.
- Structured & Searchable: The AI can read, write, and search through notes, effectively building a traversable knowledge graph for your project.
- Seamless Integration: Works directly with Cursor (or any compatible LLM) through the Model Context Protocol (MCP), enabling powerful, stateful automation.
Commands Used
Install the basic-memory tool.
uv tool install basic-memory
Check the available commands for the basic-memory CLI.
bm --help
Add a new basic-memory project, linking a name to a specific directory path for storing memories.
bm project add script-generator ~/dev/script-generator/memories
MCP Configuration
Create a .cursor/mcp.json file and add the following configuration, replacing your-project-name with the name you used in the project add command (script-generator in this example).
{
"mcpServers": {
"basic-memory": {
"command": "uvx",
"args": ["basic-memory", "--project", "script-generator", "mcp"]
}
}
}
AI Prompts
A prompt to ask the AI to write a new note to its memory.
Please use basic memory to write a hello world note.
A prompt to ask the AI to retrieve and summarize information from its memory.
Using basic memory, please read all of the notes I've created so far and summarize them for me.