Foundation: Building AI Memory with MCP and Cursor

John Lindquist
InstructorJohn Lindquist

Social Share Links

Tweet

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-memory and initialize a new memory store for your current project.
  • Configure the MCP Server: Create a simple mcp.json file in your .cursor directory to connect basic-memory to 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-memory saves 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.

[00:00] Once you install basic memory, either with UV or brew, you'll see that it installs a basic memory executable, aliased as BM. So if I type BM help, you'll see some of the options that we have here. Right now we're mostly interested in the project and the MCP. So I'm going to say bmprojectadd, and I'm going to call this script generator after the name of my current project. And then I'm going to add this to my dev script generator directory, then slash memories.

[00:34] Now this is going to set up a directory in my current project called memories and this directory is currently empty and basic memory will write markdown files to this directory. Now to set up this specific basic memory project for our project, we'll go down into the project command, which you can find in here under multiple projects. We'll copy this and in our cursor directory we're going to create a new file, call this mcp.json, and then just paste the contents of that JSON. It'll say new MCP server detected, click enable, and now if you check in your settings, Command-Shift-J, and go down to the tools and integrations, you'll see that basic memory would be enabled here. Because I copy and pasted I need to adjust this to script generator.

[01:22] Hit save and then we should be back in business. So now we have our tools enabled. You'll see it has the ability to read and write notes and search the notes and everything. So if we do our basic agent command we'll just say please use basic memory to write a hello world note. Hit enter.

[01:39] You'll see it calls write note and the result is created notes and so you'll see In our memories directory we will now have a memories notes hello world. And so now if I start a new conversation and I ask it to using basic memory please read all of the notes I've created so far and summarize them for me we'll get back this extremely basic here's your hello world note where it called this directory and got back the notes directory. It read that specific note and got its content back. And now we have a straightforward way of managing markdown files over MCP Using our agent.