All posts
·6 min read

How to Add Persistent Memory to Claude Code, Cursor, and Windsurf

Step-by-step guide to giving any MCP-compatible AI coding agent persistent cloud memory. Works with Claude Code, Cursor, Windsurf, and any MCP client.

TutorialClaude CodeCursorWindsurfMCP

TL;DR:Any AI coding agent that supports MCP can have persistent cloud memory. This guide covers Claude Code, Cursor, and Windsurf setup with Agent-Memo.AI — each takes under 2 minutes.

What is persistent memory for AI agents?

Persistent memory lets your AI coding agent remember context across sessions: architecture decisions, coding preferences, project history, and team conventions. Instead of starting every conversation from scratch, the agent picks up where it left off.

This is powered by the Model Context Protocol (MCP)— an open standard by Anthropic that lets AI agents connect to external tools. Agent-Memo.AI provides an MCP server with 14 memory tools, including semantic search and a knowledge graph.

Prerequisites

Setup for Claude Code

Claude Code has the richest MCP support, including hooks for automatic memory management.

Step 1: Create .mcp.json in your project root:

{
  "mcpServers": {
    "agent-memo": {
      "command": "npx",
      "args": ["-y", "@agent-memo/mcp-client"],
      "env": {
        "AGENTMEMO_TOKEN": "your-token-here"
      }
    }
  }
}

Step 2: Create .claude/settings.local.json for auto-save hooks:

{
  "hooks": {
    "SessionStart": [{"matcher": "startup", "hooks": [
      {"type": "command", "command": "npx -y @agent-memo/mcp-client --hook recall", "timeout": 30}
    ]}],
    "Stop": [{"matcher": "*", "hooks": [
      {"type": "command", "command": "npx -y @agent-memo/mcp-client --hook save", "timeout": 30}
    ]}],
    "PreCompact": [{"hooks": [
      {"type": "command", "command": "npx -y @agent-memo/mcp-client --hook precompact", "timeout": 30}
    ]}]
  }
}

That's it. Claude Code now has persistent memory with automatic recall, save, and pre-compression hooks.

Setup for Cursor

Cursor supports MCP servers natively. Add the same .mcp.json file to your project root. Cursor doesn't support hooks yet, so memory operations are manual (the agent calls memory_store and memory_recall as needed).

Setup for Windsurf

Windsurf also supports MCP. Add .mcp.json to your project root with the same configuration as above. Like Cursor, hooks aren't available yet, but the 14 memory tools work through MCP.

What happens after setup?

Your agent now has access to 14 tools:

  • memory_store / memory_recall — Store and search memories semantically
  • memory_overview — Load high-importance memories on startup
  • memory_update / memory_delete — Manage existing memories
  • kg_add / kg_query — Build and query a knowledge graph
  • memory_check_duplicate — Avoid storing redundant information
  • And 6 more for stats, topics, timelines, and expansion

Pro tips

  • Use topics — Tag memories with topics like "auth-migration" or "database-design" for precise recall
  • Set importance levels — 1 (low) to 4 (critical). Critical memories are always loaded on startup
  • Let hooks do the work — With Claude Code hooks, you rarely need to manually store memories. The agent handles it

Full documentation | Get started free

Give your AI agent persistent memory today.

Get started free