Provides read-only access to Cursor's internal SQLite database to retrieve chat session history and metadata
Cursor Cross-Session Context Retrieval
Unlock the power of your Cursor chat history โ Search, organize, and retrieve context from past conversations to enhance your AI-assisted development workflow.
๐ฏ The Problem
Every Cursor Composer session is isolated โ when you start a new chat, the AI has no memory of your previous conversations. This leads to:
โ Repeating context and explanations
โ Lost architectural decisions and discussions
โ Manual copy-pasting from old chats
โ Difficulty finding specific conversations
โ No organization or categorization of chat history
โจ The Solution
This library gives you programmatic access to your entire Cursor chat history with powerful organization and retrieval features:
โ Nickname sessions โ Give chats memorable names instead of UUIDs
โ Tag & organize โ Categorize sessions by feature, bug, topic, etc.
โ Project-scoped search โ Automatically filters chats by project
โ Full-text search โ Search across nicknames, tags, messages, and projects
โ Rich formatting โ Export sessions as Markdown, JSON, or compact previews
โ Type-safe API โ Fully typed TypeScript interface
๐ Quick Start
Installation
CLI Tool
The package includes a powerful command-line interface:
See CLI.md for complete CLI documentation.
MCP Server
Let AI automatically search and retrieve past chat sessions:
Setup:
Build the project:
npm run buildConfigure Cursor (see MCP-SETUP.md)
Restart Cursor
Usage in Chat:
The AI decides when to search based on your conversation. See MCP-SETUP.md for setup instructions.
Library Usage
๐ Core Features
1. Session Management
2. Organization
3. Search
4. Project Management
5. Formatting
6. Statistics
๐๏ธ Architecture
Core Modules
How It Works
Read-only Access โ Safely reads Cursor's internal SQLite database
Separate Metadata โ Stores your nicknames/tags in
~/.cursor-context/metadata.dbAuto-sync โ Automatically syncs sessions on first access
Project Detection โ Extracts workspace paths from tool results in messages
Smart Parsing โ Handles Cursor's complex Lexical richText format
๐ Advanced Usage
Custom Database Paths
Direct Database Access
Batch Operations
๐งช Testing
The library includes 169 comprehensive tests:
Test coverage includes:
โ Unit tests for each module
โ Integration tests for the API
โ End-to-end workflow tests
โ Error handling and edge cases
๐ ๏ธ Development
๐ Database Schema
Cursor's Database (state.vscdb)
Metadata Database (~/.cursor-context/metadata.db)
๐ Security & Privacy
โ Read-only access to Cursor's database
โ Local-only โ No data sent to external servers
โ Separate metadata โ Your organization data is stored separately
โ Retry logic โ Handles database locks gracefully
โ No modifications โ Never writes to Cursor's internal database
๐ฏ Use Cases
1. MCP Server (Recommended)
Integrate with Cursor's Model Context Protocol to let AI automatically fetch context:
2. CLI Tool
Build a command-line interface:
3. VS Code Extension
Create a sidebar that shows session history with search and filters.
4. Custom Integrations
Export sessions to Notion/Obsidian
Generate documentation from chat history
Analyze development patterns
Create knowledge bases
๐บ๏ธ Roadmap
Phase 1: Core Library โ (Complete!)
โ Database access
โ Message parsing
โ Metadata management
โ Full API with search, tagging, formatting
โ 169 comprehensive tests
Phase 2: CLI Tool โ (Complete!)
โ List, get, search commands
โ Nickname and tag management
โ Stats and projects views
โ Configuration management
โ Multiple output formats (table, json, markdown, compact)
โ Color support
Interactive TUI mode (future)
Shell completion (future)
Phase 3: MCP Server โ (Complete!)
โ MCP protocol implementation
โ 9 tool definitions with clear descriptions
โ AI-invoked session search and retrieval
โ Session management (tag, nickname)
โ Universal (works in Cursor, VSCode, Claude Desktop)
โ Stdio-based communication
โ Integration with core library
Phase 4: VSCode/Cursor Extension (Future)
Slash commands (
/chat,/chat search, etc.)Session browser UI (sidebar panel)
Quick pick menus for explicit control
Status bar integration
Right-click context menus
User-invoked actions (vs AI-invoked in MCP)
Phase 5: Advanced Features
Full-text search with SQLite FTS5
Session similarity matching (vector embeddings)
Automatic tagging with AI
Multi-workspace support
Session analytics and insights
๐ค Contributing
Contributions are welcome! Please:
Fork the repository
Create a feature branch
Add tests for new functionality
Ensure all tests pass (
npm test)Submit a pull request
๐ License
MIT License - see LICENSE file for details.
๐ Acknowledgments
Built for the Cursor AI code editor
Uses better-sqlite3 for database access
Tested with Vitest
Made with โค๏ธ for developers who want to unlock their Cursor chat history
For detailed technical documentation, see CURSOR-CROSS-SESSION-CONTEXT.md
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
Enables AI to automatically search, retrieve, and organize your Cursor chat history across sessions. Supports tagging, nicknames, project-scoped search, and full-text search to maintain context between conversations.