本项目允许AI助手访问你的Cursor聊天历史记录。借助Model Context Protocol (MCP) 服务器,Cursor、Claude等AI助手能够读取并分析你的Cursor聊天数据,从而基于你的实际开发模式和历史记录提供个性化的编码辅助。
在你的 .cursor/mcp.json 文件中添加以下内容:
{
"mcpServers": {
"cursor-chat-history": {
"command": "npx",
"args": ["-y", "--package=cursor-chat-history-mcp", "cursor-chat-history-mcp"]
}
}
}
你可以向AI助手提出如下指令:
"Analyze my React conversations and create component guidelines"
"Find debugging patterns in my chat history"
"Generate TypeScript coding standards from my actual usage"
"What are the main themes in my recent coding discussions?"
你可以要求AI助手完成以下任务:
git clone https://github.com/vltansky/cursor-chat-history-mcp
cd cursor-chat-history-mcp
yarn install
yarn build
上述的 npx 配置会自动处理安装过程。
{
"mcpServers": {
"cursor-chat-history": {
"command": "npx",
"args": ["-y", "--package=cursor-chat-history-mcp", "cursor-chat-history-mcp"]
}
}
}
"Analyze my React conversations and create component guidelines"
"Find debugging patterns in my chat history"
"Generate TypeScript coding standards from my actual usage"
"What are the main themes in my recent coding discussions?"
list_conversations - 可通过过滤选项浏览对话,并可选择对项目相关性进行评分。get_conversation - 检索包含代码和文件引用的完整对话内容。search_conversations - 支持多关键字、LIKE模式和文本搜索的增强搜索功能。get_conversation_analytics - 提供全面的分析,包括使用模式、文件活动、编程语言分布和时间趋势。find_related_conversations - 查找通过共享文件、文件夹、语言、大小或时间接近度相关联的对话。extract_conversation_elements - 灵活分组提取文件、代码块、语言、元数据和对话结构。export_conversation_data - 以JSON、CSV或图形格式导出聊天数据,以便进行外部分析和可视化。"Create TypeScript interface naming conventions from my conversations"
"Extract error handling patterns and create guidelines"
"Find all my discussions about testing and create best practices"
"Show me how I typically use React hooks in my projects"
"Find patterns in my state management discussions"
"Analyze my class inheritance usage and create guidelines"
"Find conversations where I discussed specific functions or patterns"
"Search for file-specific discussions across my projects"
"Compare how I've approached similar problems over time"
"Generate API documentation from my service discussions"
"Create technical docs from my auth module conversations"
"Find similar debugging sessions and extract solutions"
"Analyze my performance optimization discussions"
"Get comprehensive analytics on my coding patterns over the last 3 months"
"Export all conversations with React code to CSV for analysis"
"Find conversations similar to this database migration discussion"
所有工具都支持通过 outputMode 参数以JSON格式输出:
json(默认) - 格式良好、具有适当缩进的JSON,便于阅读。compact-json - 无格式的压缩JSON,尺寸最小。list_conversations
limit(默认值:10) - 要返回的对话数量。includeAiSummaries(默认值:true) - 包含AI生成的摘要,以便高效浏览。projectPath - 按项目路径过滤。includeRelevanceScore(默认值:false) - 按项目路径过滤时包含相关性分数。hasCodeBlocks - 过滤包含/不包含代码的对话。keywords - 按关键字搜索。filePattern - 按文件模式过滤。get_conversation
conversationId(必需) - 要检索的对话。summaryOnly(默认值:false) - 获取增强摘要而不获取完整内容,以节省上下文。includeMetadata(默认值:false) - 包含额外的元数据。search_conversations - 支持多种方法的增强搜索
query - 基本文本搜索(向后兼容)。keywords 数组,搭配 keywordOperator('AND'/'OR')。likePattern - SQL LIKE模式(% = 任意字符,_ = 单个字符)。searchType(默认值:'all') - 'all'、'project'、'files'、'code'。maxResults(默认值:10) - 最大结果数。includeCode(默认值:true) - 包含代码块。get_conversation_analytics
scope(默认值:'all') - 'all'、'recent'、'project'。projectPath - 关注特定项目(当 scope='project' 时必需)。recentDays(默认值:30) - 近期范围的时间窗口。includeBreakdowns(默认值:['files', 'languages']) - 分析类型:'files'、'languages'、'temporal'、'size'。find_related_conversations
referenceConversationId(必需) - 起始对话。relationshipTypes(默认值:['files']) - 'files'、'folders'、'languages'、'size'、'temporal'。maxResults(默认值:10) - 结果数量。minScore(默认值:0.1) - 最小相似度分数(0 - 1)。includeScoreBreakdown(默认值:false) - 显示单个关系分数。extract_conversation_elements
conversationIds - 特定对话(可选,若为空则处理所有对话)。elements(默认值:['files', 'codeblocks']) - 'files'、'folders'、'languages'、'codeblocks'、'metadata'、'structure'。includeContext(默认值:false) - 包含周围的消息文本。groupBy(默认值:'conversation') - 'conversation'、'element'、'none'。filters - 按代码长度、文件扩展名或语言过滤。export_conversation_data
conversationIds - 特定对话(可选,若为空则导出所有对话)。format(默认值:'json') - 'json'、'csv'、'graph'。includeContent(默认值:false) - 包含完整的消息文本。includeRelationships(默认值:false) - 计算文件/文件夹连接。flattenStructure(默认值:false) - 扁平化以兼容CSV。filters - 按大小、代码块或项目路径过滤。自动检测的位置如下:
| 属性 | 详情 |
|---|---|
| macOS | ~/Library/Application Support/Cursor/User/globalStorage/state.vscdb |
| Windows | %APPDATA%/Cursor/User/globalStorage/state.vscdb |
| Linux | ~/.config/Cursor/User/globalStorage/state.vscdb |
本项目采用MIT许可证。