Skip to main content

AI agent memory layer (mem0-compatible) powered by Cursor SDK

Project description

cursor-mem

AI agent memory layer modeled on mem0, with one key change: LLM inference uses Cursor SDK and CURSOR_API_KEY instead of OpenAI / Anthropic / other third-party LLM API keys.

Everything else follows mem0’s pipeline (v3 additive extraction, hybrid retrieval, entity linking, SQLite history, Qdrant vector store).

Architecture

Component Provider API key
Memory extraction & reasoning cursor-sdk Agent.prompt CURSOR_API_KEY
Embeddings fastembed (local ONNX) None
Vector store Qdrant (embedded, on disk) None
History SQLite None
flowchart LR
  subgraph input [Conversation]
    M[messages]
  end
  subgraph cursor_mem [cursor-mem]
    S[search: embed + BM25 + entities]
    L[Cursor SDK LLM extract facts]
    V[(Qdrant)]
    H[(SQLite history)]
  end
  M --> S
  S --> L
  L --> V
  L --> H

Install

From PyPI (recommended):

pip install cursor-mem0

# MCP server for Cursor agents
pip install "cursor-mem0[mcp]"

# Optional: BM25 + entity extraction (same as mem0[nlp])
pip install "cursor-mem0[nlp]"
python -m spacy download en_core_web_sm

Note: PyPI package name is cursor-mem0 (import: from cursor_mem import Memory). The name cursor-mem on PyPI is a different project (IDE session hooks).

From source:

pip install -e .

# Optional extras
pip install -e ".[mcp]"
pip install -e ".[nlp]"
python -m spacy download en_core_web_sm

Setup

  1. Create an API key: Cursor Dashboard → Integrations
  2. Configure locally (recommended):
cp .env.example .env
# Edit .env and set CURSOR_API_KEY=...

Or export in the shell:

export CURSOR_API_KEY="cursor_..."

Data is stored under ~/.cursor-mem/ (override with CURSOR_MEM_DIR).

MCP in Cursor (project)

This repo includes a stdio MCP server so Cursor agents can call add_memory, search_memories, and list_memories.

1. Install with MCP extras

pip install "cursor-mem0[mcp]"
# or from source: pip install -e ".[mcp]"

2. Project config (already in repo)

File: .cursor/mcp.json

{
  "mcpServers": {
    "cursor-mem": {
      "command": "python3",
      "args": ["-m", "cursor_mem.mcp_server"],
      "cwd": "${workspaceFolder}",
      "env": {
        "CURSOR_API_KEY": "${env:CURSOR_API_KEY}",
        "CURSOR_MEM_USER_ID": "${env:CURSOR_MEM_USER_ID}"
      }
    }
  }
}

The server loads CURSOR_API_KEY from .env in the project root when Cursor starts it (cwd = workspace).

3. Enable in Cursor

  1. Open this folder as the workspace (cursor-mem).
  2. Cursor Settings → MCP (or run /mcp in chat) and confirm cursor-mem appears and is enabled.
  3. If tools do not show up, reload the window and check MCP logs for python3 / missing mcp package.

4. Optional: user-global MCP

To use memory in every project, add the same block to ~/.cursor/mcp.json and set cwd to this repo’s absolute path, or export CURSOR_API_KEY globally.

MCP tools

Tool Purpose
add_memory Store facts from conversation (infer=true uses mem0 extraction via Cursor SDK)
search_memories Semantic + hybrid search
list_memories List memories for a user_id
get_memory Fetch one memory by id

Quickstart

Same API as mem0’s Memory class:

from cursor_mem import Memory

memory = Memory()

# Add memories from a conversation
memory.add(
    "I prefer dark mode and vim keybindings",
    user_id="alice",
)

# Search
results = memory.search(
    "What are Alice's editor preferences?",
    filters={"user_id": "alice"},
    top_k=3,
)
for item in results["results"]:
    print(item["memory"], item.get("score"))

Chat example

export CURSOR_API_KEY="cursor_..."
python examples/chat_with_memory.py

Configuration

Defaults (Memory())

  • LLM: provider: cursor, model composer-2.5, local.cwd = current directory
  • Embedder: fastembed + thenlper/gte-large (1024 dims)
  • Vector store: local Qdrant at ~/.cursor-mem/qdrant

Custom config (mem0-style dict)

from cursor_mem import Memory

memory = Memory.from_config({
    "llm": {
        "provider": "cursor",
        "config": {
            "api_key": "cursor_...",
            "model": "composer-2.5",
            "cwd": "/path/to/project",
        },
    },
    "embedder": {
        "provider": "fastembed",
        "config": {"model": "thenlper/gte-large"},
    },
    "vector_store": {
        "provider": "qdrant",
        "config": {
            "path": "/tmp/my-qdrant",
            "collection_name": "my_memories",
            "embedding_model_dims": 1024,
        },
    },
})

Environment variables

Variable Purpose
CURSOR_API_KEY Cursor SDK authentication (required for LLM)
CURSOR_MEM_DIR Storage root (default ~/.cursor-mem)
CURSOR_MEM_USER_ID Default user id in the example script

How it maps to mem0

  • Unchanged: add, search, get, get_all, update, delete, prompts, scoring, entity store, history DB.
  • Swapped: mem0.llms.openai.OpenAILLMcursor_mem.llms.cursor.CursorLLM (registered as provider cursor).
  • Default embedder: openaifastembed so you do not need OPENAI_API_KEY for vectors.

Why fastembed for embeddings?

Cursor SDK exposes agent/LLM APIs, not a dedicated embeddings endpoint. mem0 still needs dense vectors for semantic search; fastembed runs locally with no cloud API key, which matches the goal of avoiding third-party keys while keeping mem0’s retrieval logic intact.

License

Apache-2.0 (aligned with mem0 OSS).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cursor_mem0-0.1.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cursor_mem0-0.1.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file cursor_mem0-0.1.0.tar.gz.

File metadata

  • Download URL: cursor_mem0-0.1.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.9

File hashes

Hashes for cursor_mem0-0.1.0.tar.gz
Algorithm Hash digest
SHA256 57275463dd9a5ee4a2539bacd36a11c396e470c5ee699d8490a9b160be66afcb
MD5 2633655f4f5295e1813ff5173a6b6f72
BLAKE2b-256 7bd3b5b92da9fa37be1a9befbf35def61095de9216bf3a830af01f045724ac9a

See more details on using hashes here.

File details

Details for the file cursor_mem0-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cursor_mem0-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.9

File hashes

Hashes for cursor_mem0-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1222bef29ddf05e25f65fb1fe3f477d2f090139ca309f9fc37c30304a794effb
MD5 6312fd6dcc55708a5b60a8b1e2099603
BLAKE2b-256 c61815d18f8eadd89f67971c589be943c79f9dfd7919a6545db38305af74cd33

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page