Cursor MCP memory & hooks setup across agents

connect ~/.cursor/mcp.json and hooks.json to Cursor's state.vscdb and your terminal agents

Cursor stores Composer and Agent chats in SQLite state.vscdb databases under User/globalStorage and User/workspaceStorage, separate from static .cursor/rules/*.mdc files and separate from terminal sessions in Claude Code, Codex, or opencode. Installing a Cursor-only memory plugin leaves terminal history invisible and loses everything if you later vacuum state.vscdb.

Connect Cursor MCP and lifecycle hooks: deja-vu indexes state.vscdb alongside 51 other coding agents into one local SQLite + FTS5 store, wiring ~/.cursor/mcp.json and ~/.cursor/hooks.json in one pass.
$brew install deja-vu && deja install cursor-auto
$npx @vshulcz/deja-vu install cursor-auto
deja-vu on GitHubCursor guide →

~/.cursor/mcp.json configuration

deja install cursor adds a stdio entry in ~/.cursor/mcp.json:

{
  "mcpServers": {
    "deja": {
      "command": "deja",
      "args": ["mcp"]
    }
  }
}

All 8 modes (recall, context, blame, fix, how, orient, remember, handoff) sit behind a single deja tool at 477 tokens, keeping Cursor's active tool list compact.

7 lifecycle hooks in ~/.cursor/hooks.json

deja install cursor-auto registers Cursor's native camelCase hook events alongside MCP:

Cursor hook eventMatcherBehavior
sessionStart—Injects repo orient summary and shared .deja/memory.jsonl notes (up to 2 KB)
beforeSubmitPrompt—Queries local FTS5 for matching error fixes and decisions (capped at 1,536 bytes per prompt)
preToolUse^(Shell|Write|Task)$Surfaces file blame and real project commands (about 4 KB per tool call)
postToolUse / postToolUseFailure^Shell$Captures friction loops and matches shell errors to prior resolved commands
preCompact—Preserves a 4 KB continuity packet ahead of window summarization
sessionEnd—Incrementally updates ~/.deja/deja.db from the updated SQLite store

Indexing before shrinking state.vscdb & switching agents

Cursor workspaces accumulate hundreds of megabytes inside state.vscdb. Run deja index before clearing or compacting old workspace databases so past sessions stay archived and searchable in ~/.deja/deja.db.

When moving work between Cursor and a terminal CLI agent mid-task, pass the full continuity packet explicitly:

$ deja handoff --to codex
$ deja handoff --to claude

To share vetted project conventions across Cursor, Claude Code, and Codex with teammates, commit sorted records in .deja/memory.jsonl via deja repo candidates and deja repo add <id> --kind gotcha.

Found this useful? Star deja-vu on GitHub.