Provides read-only access to Cursor's internal SQLite database to retrieve chat session history and metadata
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Chat Context MCPfind my chat about implementing authentication from last week"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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