Skip to main content

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

Project description

cursor-mem

English · 简体中文

PyPI GitHub License

Long-term memory for Cursor agents, built on the mem0 pipeline. Use your existing CURSOR_API_KEY for memory extraction (via Cursor SDK); run embeddings locally with fastembed; store vectors in on-disk Qdrant. Optional MCP server exposes memory tools to agents in Cursor IDE.

Overview

Who it’s for Developers using Cursor who want agents to remember preferences and facts across chats
What you need Python 3.11+ (library); MCP via uvx uses Python 3.12 in mcp.json (see fastembed/onnxruntime). Cursor API key and (for MCP) uv
PyPI package cursor-mem0pip install cursor-mem0 (import: from cursor_mem import Memory)

Features

  • One LLM key — extraction uses CURSOR_API_KEY, not a separate OpenAI/Anthropic account for memory
  • Structured memory — mem0-style fact extraction, hybrid retrieval (vectors + BM25 + entities), SQLite history
  • Efficient contextsearch returns only top_k relevant memories instead of reloading a growing markdown file each chat
  • Local embeddings — fastembed; no embedding API key required
  • MCP toolsadd_memory, search_memories, list_memories, get_memory for Cursor agents

How it compares to common alternatives

Approach Typical trade-off
Default mem0 / multi-key stacks Extra LLM and often embedding API keys and billing
File-based memory (MEMORY.md, logs in every prompt) Token cost grows with file size; weaker retrieval
cursor-mem0 CURSOR_API_KEY + local vectors + retrieval bounded by top_k

Extraction uses Cursor SDK quota when infer=true. Embedding runs on your machine.

Demo

Before/after memory in Cursor, MCP tool calls, and context-size comparison (~49s).

cursor-mem0 demo

Full MP4 with controls

Quick start

1. Install

pip install cursor-mem0

# To use memory tools from Cursor agents:
pip install "cursor-mem0[mcp]"

PyPI name cursor-mem0 is not cursor-mem (that package is unrelated IDE session tooling).

2. Get your CURSOR_API_KEY

cursor-mem0 uses the Cursor SDK for memory extraction. You need a user API key from your Cursor account (not a separate OpenAI key).

  1. Sign in at cursor.com.
  2. Open Dashboard → Integrations (API Keys).
  3. Click Create API key, name it (e.g. cursor-mem), and copy the value. Keys usually start with cursor_.
  4. Keep the key secret — do not commit it to git.

Team Admin API keys are not supported by the Cursor SDK yet. Use a personal user key.

3. Configure the key locally

Option A — .env in your project (recommended for MCP):

cp .env.example .env
# Edit .env:
# CURSOR_API_KEY=cursor_...

Option B — shell export:

export CURSOR_API_KEY="cursor_..."

4. Use from Python

from cursor_mem import Memory

memory = Memory()

memory.add("I prefer dark mode and vim keybindings", user_id="alice")

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"))

Interactive example:

python examples/chat_with_memory.py

Data is stored under ~/.cursor-mem/ unless you set CURSOR_MEM_DIR.

Find in Cursor

Install from the community directory (recommended), or submit this repo for official listing:

Where How users find it
cursor.directory Search “memory” / “mem0” — uses root .mcp.json / mcp.json. Submit repo after release.
Cursor Marketplace Settings → Plugins → Browse Marketplace. Requires .cursor-plugin/plugin.json and publish review.

This repository ships a Cursor plugin manifest and MCP config so directories can offer Add to Cursor without cloning the repo. The server runs from PyPI via uvx --python 3.12 (requires uv installed; avoids Python 3.10 wheel gaps for onnxruntime).

Use with Cursor (MCP)

Option A — One-click / directory install (recommended)

  1. Install uv if you do not have it (curl -LsSf https://astral.sh/uv/install.sh | sh).
  2. Set CURSOR_API_KEY (see Get your key above).
  3. Copy mcp.json into your project as .cursor/mcp.json, or use Add to Cursor from cursor.directory once listed.
  4. Put CURSOR_API_KEY in your project .env (optional; envFile in config loads it).

No pip install needed — uvx pulls cursor-mem0[mcp] from PyPI on first run.

Option B — pip install

pip install "cursor-mem0[mcp]"

Copy docs/mcp.pip.json.example to .cursor/mcp.json in your project.

Enable in Cursor

  1. Open your project in Cursor.
  2. Go to Settings → MCP (or type /mcp in chat) and enable cursor-mem.
  3. If tools are missing, reload the window and check MCP logs (uvx / uv on PATH, or pip + mcp package for Option B).

To use memory in all projects, add the same server block to ~/.cursor/mcp.json.

MCP tools

Tool Description
add_memory Save facts from the conversation (infer=true runs mem0 extraction via Cursor SDK)
search_memories Semantic and hybrid search
list_memories List memories for a user_id
get_memory Get one memory by id

Configuration

Defaults (Memory()):

Setting Value
LLM cursor provider, model composer-2.5
Embedder fastembed, thenlper/gte-large (1024 dims)
Vector store Local Qdrant at ~/.cursor-mem/qdrant

Environment variables

Variable Description
CURSOR_API_KEY Required for LLM / extraction
CURSOR_MEM_DIR Storage root (default ~/.cursor-mem)
CURSOR_MEM_USER_ID Default user_id in examples

Custom config (mem0-style):

from cursor_mem import Memory

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

Optional NLP extra (BM25 + entity boosting, same idea as mem0[nlp]):

pip install "cursor-mem0[nlp]"
python -m spacy download en_core_web_sm

Install from source

git clone https://github.com/xwqiang/cursor-mem0.git
cd cursor-mem0
pip install -e ".[mcp]"

Architecture

Component Technology API key
Extraction & reasoning Cursor SDK Agent.prompt CURSOR_API_KEY
Embeddings fastembed (local ONNX) None
Vector store Qdrant (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

Relationship to mem0

cursor-mem0 keeps mem0’s public Memory API and retrieval pipeline. Changes:

  • LLM provider: cursor_mem.llms.cursor.CursorLLM (provider: "cursor") instead of OpenAI by default
  • Default embedder: fastembed instead of openai, so vectors work without OPENAI_API_KEY

Cursor SDK does not expose a dedicated embeddings API; local fastembed preserves semantic search without another cloud key.

License

Apache-2.0

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.2.tar.gz (877.6 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.2-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cursor_mem0-0.1.2.tar.gz
  • Upload date:
  • Size: 877.6 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.2.tar.gz
Algorithm Hash digest
SHA256 9b5b49be33463cb0cbcf2c2a876712900a467f1b0328d2fea831b5d156356300
MD5 76dd92c8eae7b18409c5b199ab98a135
BLAKE2b-256 543687521c3d8de3c35ab947a954aaf17bd7c43077f69a37b4663d7a526cadd5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cursor_mem0-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 16.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3d0401b6bc51a7e80f7faba607a5cdd1d04f908e6ef1217f4c88bf1277496838
MD5 427cfac5aa7e1b1cf0e5bf223963ba18
BLAKE2b-256 9841ba8dac9b870e39e7ffbd33bd491caf1ad26bbac7b69c161ceaf9088ea269

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