Skip to main content

Persistent memory system for Cursor IDE — remembers context across sessions

Project description

cursor-mem

Persistent memory for Cursor IDE — automatically records session context and keeps memory across sessions.

中文说明 (README_CN.md)


Features

  • Cross-session memory: Remembers last session’s actions, edited files, and shell commands
  • Zero-config: Works out of the box with rule-based compression; no API key required
  • Optional AI summarization: Use any OpenAI-compatible API (e.g. free Gemini) for smarter summaries
  • Full-text search: FTS5 search over observations and sessions
  • MCP tools: Agent can query project history (memory_search, memory_timeline, memory_get)
  • Web viewer: Browse memory stream in the browser with live updates
  • Multi-project isolation: Separate memory per project

Comparison with claude-mem

criterion cursor-mem claude-mem
Target Cursor IDE only, native hooks Claude Code first, Cursor via adapter
Stack Python 3.10+, FastAPI, SQLite TypeScript/Bun, Express, SQLite + ChromaDB
Setup pip install cursor-memcursor-mem install Clone, build, plugin/marketplace or Cursor standalone setup
Out-of-the-box Works immediately with no API key (rule-based compression) AI processing is central; free tier needs Gemini/OpenRouter config
Codebase size ~20 core modules, single package 600+ files, plugin + worker + skills
Context injection .cursor/rules/cursor-mem.mdc (Cursor Rules) Same for Cursor; Claude Code uses additionalContext
Search SQLite FTS5 only (simple, no extra deps) FTS5 + ChromaDB vector search (hybrid)
Dependencies Python stdlib + FastAPI/Click/httpx Node/Bun, Claude Agent SDK, ChromaDB, etc.

When to choose cursor-mem: You use Cursor only, want minimal setup and no required API key, and prefer a small Python codebase. When to choose claude-mem: You use Claude Code or want vector/semantic search, token economics, or the full plugin ecosystem.


Quick start

# Install from PyPI
pip install cursor-mem

# One-shot setup (global; applies to all projects)
cursor-mem install --global

# Restart Cursor

From source (development):

pip install -e .
cursor-mem install --global

How it works

User submits prompt → beforeSubmitPrompt hook
  → init session + inject history into .cursor/rules/cursor-mem.mdc

Agent runs → afterShellExecution / afterFileEdit / afterMCPExecution hooks
  → capture operations, compress, store in SQLite

Agent stops → stop hook
  → generate session summary + refresh context file for next session

Commands

cursor-mem install [--global]   # Install hooks + start worker
cursor-mem start                # Start worker
cursor-mem stop                 # Stop worker
cursor-mem restart              # Restart worker
cursor-mem status               # Show status

cursor-mem config set <key> <val>   # Set config
cursor-mem config get [key]         # Show config

cursor-mem data stats             # Data stats
cursor-mem data projects          # List projects
cursor-mem data cleanup           # Clean old data
cursor-mem data export [file]     # Export data

Optional AI summarization

# Gemini (free tier)
cursor-mem config set ai.enabled true
cursor-mem config set ai.base_url "https://generativelanguage.googleapis.com/v1beta/openai"
cursor-mem config set ai.api_key "your-gemini-api-key"
cursor-mem config set ai.model "gemini-2.0-flash"

# Or any OpenAI-compatible API
cursor-mem config set ai.base_url "https://api.openai.com/v1"
cursor-mem config set ai.api_key "sk-..."
cursor-mem config set ai.model "gpt-4o-mini"

Web viewer

After install, open http://127.0.0.1:37800 for:

  • Session list and details
  • Observation timeline
  • Full-text search
  • Live SSE updates

MCP tools

Registered in ~/.cursor/mcp.json on install:

  • memory_search(query) — search history
  • memory_timeline(session_id?) — timeline view
  • memory_get(ids) — fetch observation details

Project layout

cursor-mem/
├── cli.py           # CLI entry
├── installer.py     # Install logic
├── hook_handler.py  # Unified hook handler
├── config.py        # Config and paths
├── worker/          # FastAPI HTTP service
├── storage/         # SQLite layer
├── context/         # Context build and inject
├── summarizer/      # Rule-based + AI summarizer
├── mcp/             # MCP search tools
├── ui/              # Web viewer
├── pyproject.toml
└── README.md

Testing

  • Automated: pip install -e ".[dev]" then pytest tests/ -v
  • In Cursor: See TESTING.md for manual test cases (hooks, MCP, worker, CLI).

License

This project is licensed under the Apache License 2.0. See LICENSE for the full text.


Data locations

  • Database: ~/.cursor-mem/cursor-mem.db
  • Config: ~/.cursor-mem/config.json
  • Logs: ~/.cursor-mem/logs/
  • Injected context: <project>/.cursor/rules/cursor-mem.mdc

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_mem-0.1.2.tar.gz (39.2 kB view details)

Uploaded Source

Built Distribution

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

cursor_mem-0.1.2-py3-none-any.whl (40.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cursor_mem-0.1.2.tar.gz
  • Upload date:
  • Size: 39.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for cursor_mem-0.1.2.tar.gz
Algorithm Hash digest
SHA256 730bc32023522e7f0592f735fb0197c2ed5f5769be64d42946f67c1f19780ea0
MD5 3e8ad611b32f6dc22272cabbcc355053
BLAKE2b-256 42dbb81d5833c4d46d2d30575c51ee869bada58d6da3b6c1f670dabb1f710987

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cursor_mem-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 40.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for cursor_mem-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f8002bed35d47bbfa00d81f36e3ad1e89d040efe9dde755e34957d42f2fd3ce7
MD5 e320a9bf4fa9f61a597cca1d8e650dd0
BLAKE2b-256 cbb1a46230eec93d6b2ad516d2336840a3327246dfcdce65de167ae2d6d40bfe

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