DEV Community

Cover image for How to Give Cursor and Claude Code Persistent Memory Across Sessions via MCP
Mohammed Rafay
Mohammed Rafay

Posted on Originally published at docs.memorysync.io

How to Give Cursor and Claude Code Persistent Memory Across Sessions via MCP

How to Give Cursor and Claude Code Long-Term Memory Across Sessions via MCP

By MemorySync Team ΓÇó Published September 2026 ΓÇó 8 min read


The Problem: Context Amnesia in AI Coding Assistants

If you use Cursor, Claude Code, or Claude Desktop for serious software development, you have encountered this daily frustration:

You explain your project's architecture, database conventions, and pinned dependency versions in one chat session. An hour later, you open a new chatΓÇöand the model has completely forgotten everything.

Developers typically resort to two flawed workarounds:

  1. Static Rules Files (.cursorrules / CLAUDE.md): As your project grows, these files bloat to thousands of lines, eating up expensive context window tokens on every single query and causing the model to miss instructions.
  2. Copy-Pasting Context: You waste the first 5 minutes of every coding session copying past decisions, API schemas, and test conventions.

What coding agents need is durable, semantic, cross-session memory: the ability to store architectural decisions once, and automatically recall only the relevant facts when a specific question is asked in a fresh conversation.

In this guide, we will set up persistent long-term memory for Cursor and Claude Code in under 60 seconds using the Model Context Protocol (MCP) and MemorySync.


How It Works: The Remote MCP Memory Architecture

The Model Context Protocol (MCP) is the open standard developed by Anthropic that allows LLMs to interact with external tools and state.

MemorySync provides a high-speed, remote MCP memory server:

Key Architectural Advantages:

  • Zero Local Daemons: No Docker containers, Python venvs, or local Postgres/Qdrant processes running on your laptop.
  • Cross-Client Synchronization: Decisions saved in Cursor while writing frontend code are instantly accessible to Claude Code running in your CLI terminal.
  • Cryptographic Isolation: Every memory is strictly isolated by X-Project-ID and X-End-User-ID, preventing cross-project context pollution.
  • Auditability: Every recalled memory has an immutable ID and timestamp, so you always know why the model made a specific architectural choice.

60-Second Setup: Cursor

Option A: Install via Cursor Directory (1-Click)

  1. Visit the official listing on cursor.directory/plugins/memorysync.
  2. Click Install Plugin to automatically configure the MCP server, rules, and memory hooks.

Option B: Manual Configuration

  1. In Cursor, open Settings (Ctrl + , or Cmd + ,) -> Features -> MCP Servers.
  2. Click + Add New MCP Server.
  3. Fill in the connection parameters:

    • Name: memorysync
    • Type: sse
    • Server URL: https://mcp.memorysync.io/mcp
    • Headers:
     {
       "Authorization": "Bearer YOUR_MEMORYSYNC_API_KEY",
       "X-Project-ID": "your-project-slug"
     }
    
  4. Click Save. Cursor will verify the connection and show a green dot next to memorysync.

(You can get a free API key at app.memorysync.io).


60-Second Setup: Claude Code & Claude Desktop

For Claude Desktop:

Open your claude_desktop_config.json:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Add the MemorySync MCP server definition:

{
  "mcpServers": {
    "memorysync": {
      "url": "https://mcp.memorysync.io/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_MEMORYSYNC_API_KEY",
        "X-Project-ID": "your-project-slug"
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

For Claude Code (Terminal CLI):

Run the following command in your terminal:

claude mcp add memorysync https://mcp.memorysync.io/mcp --header "Authorization: Bearer YOUR_MEMORYSYNC_API_KEY" --header "X-Project-ID: your-project-slug"
Enter fullscreen mode Exit fullscreen mode

Verifying Persistent Memory: The "Fresh Session" Test

To prove that memory persists across chat sessions, run this quick 2-minute test:

Step 1: Store an Architecture Constraint (Session 1)

In Cursor or Claude, start a chat and write:

"Remember this project decision: All API endpoints must use strict UTC ISO-8601 timestamps with millisecond precision (e.g., 2026-09-13T12:00:00.000Z). Do not use Unix epoch integers."

The model will invoke save_memory via the MemorySync MCP server:

{
  "status": "success",
  "memory_id": "mem_9f82a1b",
  "stored": "All API endpoints must use strict UTC ISO-8601 timestamps with millisecond precision. Do not use Unix epoch integers."
}
Enter fullscreen mode Exit fullscreen mode

Step 2: Open a Brand New Chat (Session 2)

  1. Close the current chat window.
  2. Open a completely fresh chat session (do not mention the rule from Step 1).
  3. Ask the assistant: > "Write a FastAPI route that returns the current server status and response timestamp."

Step 3: Observe Automatic Retrieval

Notice what happens before the model writes the code:

  1. It automatically calls query_memory(query="server timestamp API endpoint").
  2. MemorySync returns mem_9f82a1b.
  3. The generated code strictly uses datetime.now(timezone.utc).isoformat(timespec='milliseconds') instead of time.time().

The model recalled your architecture rule without you re-explaining it.


Comparison: How MemorySync Compares to Alternatives

Capability MemorySync (MCP) Mem0 Zep Static .cursorrules
Model Context Protocol (MCP) Native Remote SSE Custom tool wrapper REST API None (Static file)
Setup Overhead 60 Seconds (1-line) Requires Python environment Complex cloud dashboard Manual copy/paste
Cross-IDE Sync Cursor + Claude Code synced Single environment Single environment Workspace-local only
Token Efficiency High (Dynamic semantic recall) Moderate Moderate Poor (Consumes prompt tokens every turn)
Multi-Tenant Isolation Cryptographic Headers String filtering Session IDs None
Free Tier / Zero Cost Free Community Tier Self-hosted or Cloud Paid Cloud Free

Next Steps

Top comments (0)