P

cursor-db-mcp

...
Created 3/7/2025byjbdamask

Language:

Python

Stars:

11

Forks:

0

Cursor DB MCP Server

A Model Context Protocol (MCP) server for accessing Cursor IDE's SQLite databases. This server allows AI assistants to explore and interact with Cursor's project data, chat history, and composer information.

Cursor In Cursor GIF

Prerequisites

Cursor IDE

Installation

Easy Installation

Use the provided installation script to install all dependencies:

python install.py

This script will install:

  • Basic MCP server and dependencies

Using with Cursor IDE

            1. Open Cursor and navigate to Settings->Cursor Settings->MCP. 

2. Click: Add new MCP server 3. Name: Cursor DB MCP; Type: Command 4. Command: \uv run --with mcp[cli] mcp run /cursor-db-mcp-server.py

Cursor DB MCP

Now you can ask questions about the database or retrieve info about historical chats.

DB structure

DB keys

Available Resources

  • cursor://projects - List all available Cursor projects
  • cursor://projects/detailed - List projects with detailed information
  • cursor://projects/{project_name}/chat - Get chat data for a specific project
  • cursor://projects/{project_name}/composers - Get composer IDs for a specific project
  • cursor://composers/{composer_id} - Get data for a specific composer

Available Tools

  • query_table - Query a specific table in a project's database

  • refresh_databases - Refresh the list of database paths

              - You: "I'm getting a 401 error when connecting to the API. Here's my code..."
    
  • Claude: "It looks like you're missing the authorization header in your request..."


## Querying Database Tables

**User**: "Can you search for keys related to 'settings' in the ItemTable of my 'project1' project?"

**Claude**:

I'll search for keys related to 'settings' in the ItemTable of your 'project1' project.

Here are the results:

  1. Key: "workbench.settings.editor" Value: {"mode": "ui", "lastFocusedSettingId": "editor.fontSize"}

  2. Key: "settings.language" Value: "en"

  3. Key: "settings.theme" Value: "dark"


## Analyzing Chat Data

**User**: "Can you analyze the chat data from my 'project1' project and tell me what topics I've been discussing most frequently?"

**Claude**:

I'll analyze the chat data from your 'project1' project.

Based on your chat history, here are the most frequent topics you've been discussing:

  1. React Hooks and Components (5 conversations)
  2. API Integration (3 conversations)
  3. CSS Styling (2 conversations)
  4. Performance Optimization (2 conversations)
  5. Debugging (1 conversation)

The most common questions were about state management in React and handling API responses.


# Architecture

The server uses the Model Context Protocol (MCP) to expose Cursor's SQLite databases to AI assistants. Key components include:

1. **Lifespan Context Management**: The server uses MCP's lifespan API to efficiently manage resources throughout the server's lifecycle.

2. **CursorDBManager**: Handles the detection and management of Cursor projects and their databases.

3. **Resources**: Expose data from Cursor databases as MCP resources.

4. **Tools**: Provide functionality to query databases and manage projects.

5. **Prompts**: Define reusable templates for AI interactions. -->

# How It Works


            
        
            
                The server scans your Cursor installation directory to find project databases (state.vscdb files). It then exposes these databases through MCP resources and tools, allowing AI assistants to query and analyze the data.

# Notes
1. Cursor stores AI conversations in different places. Increasingly, chats are stored as "composerData" under globalStorage/state.vscdb. If you don't get results when asking about chats for recent projects, try asking for composers.
2. This was written on a Mac. YMMV with other OS

# Shameless Plug


Like this? Try [Cursor Journal](https://medium.com/@jbdamask/building-cursor-journal-with-cursor-77445026a08c) to create DevLogs directly from Cursor chat history!

# License

MIT
Last updated: 3/24/2025

Publisher info

jbdamask's avatar

John Damask

Bored with what I know. Chasing what I don't.

Cambridge, MA
16
followers
7
following
47
repos

More MCP servers built with Python

apollo-io-mcp-server

MCP server that exposes the Apollo.io API functionalities as tools

By Edward Choh
mcp-openvision

MCP Server using OpenRouter models to get descriptions for images

By Nazruden2
DeepView MCP

Enables IDEs like Cursor and Windsurf to analyze large codebases using Gemini's extensive context window.

By ai-1st