Skip to main content

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

Project description

cursor-mem

PyPI GitHub

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.1.tar.gz (12.8 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.1-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cursor_mem0-0.1.1.tar.gz
  • Upload date:
  • Size: 12.8 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.1.tar.gz
Algorithm Hash digest
SHA256 3baa9e0c0cbbdf5ae61363293715dc6e8cbcb151dae64e33900870f314a3a174
MD5 093bf2e8ddb11725b45800e075f5085c
BLAKE2b-256 f991957695bba8f9558b7e3575467328132941c2a1cb59e6a64bcc7f6f871cc1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cursor_mem0-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 83d4829f8d13d79841efd8c3fd8e6ee58fb75b3f5fcce373e37ffaae8be432a8
MD5 4efb1bec2a36131154262d9561732af4
BLAKE2b-256 777a91d2bc5d960348b96b19c62ebbaaae35e8cb661c761662708990343b5a35

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