光标聊天历史MCP
将Cursor对话连接到git历史记录。
为什么?
你做出承诺。几周后,你会想: *“我为什么这样写?”*
git消息说 fix auth bug 但真正的背景——调试会话、考虑的替代方案、人工智能建议——存在于你永远不会再找到的Cursor对话中。
此MCP服务器会自动将您的Cursor对话链接到git提交。当你重新审视代码时,人工智能助手可以调出原始讨论。
快速开始
添加到 .cursor/mcp.json:
{
"mcpServers": {
"cursor-chat-history": {
"command": "npx",
"args": ["-y", "--package=cursor-chat-history-mcp", "cursor-chat-history-mcp"]
}
}
}就是这样。钩子在第一次使用时会自动安装。
你能做什么
查找代码上下文
"What was the context behind commit abc123?"
"Find the conversation that led to this fix"
"Show discussions about auth.ts from the last month"搜索您的聊天记录
"Find all debugging sessions about performance"
"Search conversations mentioning useState"
"List recent conversations in this project"提取图案
"Create TypeScript guidelines from my actual usage"
"Extract error handling patterns from my conversations"
"Summarize my React patterns from chat history"可用工具
Git链接器
| 工具 | 目的 |
|---|---|
get_file_context | 获取与文件相关的对话和提交 |
get_commit_conversations | 查找与提交链接的对话 |
list_conversation_commits | 查找与对话链接的提交 |
link_conversation_commit | 手动链接对话↔ 承诺 |
聊天记录
| 工具 | 目的 |
|---|---|
list_conversations | 使用过滤器浏览(项目、关键字、文件) |
get_conversation | 获取完整的对话内容 |
search_conversations | 多关键字和模式搜索 |
get_conversation_analytics | 使用模式、文件活动、语言统计 |
隐私
- 100%本地 -没有外部服务,没有API密钥
- 您的数据保留在磁盘上 -仅限于SQLite数据库
- 开源 -自己审核代码
______________________________________________________________________
运作原理
MCP服务器启动时会自动安装挂钩:
- 光标挂钩 (
~/.cursor/hooks.json)-捕获文件编辑和会话结束 - Git提交后钩子 (当前仓库)-链接提交到对话
当您提交时,系统会使用以下命令查找相关对话:
- 文件重叠(70%):提交对话中讨论的触及文件
- 近期(30%):过去14天的对话
高效的上下文检索
大型对话不会直接加载到上下文中。相反:
- 使用
get_file_context随着keywords查找相关对话 - 呼叫
get_conversation-写信给~/.cursor-chat-history/context/conversations/.md - 使用Read/Grep工具高效地浏览markdown文件
CLI命令
# Query links
npx cursor-chat-history-mcp link list-conversation-links --conversation
npx cursor-chat-history-mcp link get-commit-links --hash
# Manual linking
npx cursor-chat-history-mcp link manual --conversation --commit 数据库位置
| 数据库 | macOS | Windows | Linux |
|---|---|---|---|
| 光标聊天 | ~/Library/Application Support/Cursor/User/globalStorage/state.vscdb | %APPDATA%/Cursor/... | ~/.config/Cursor/... |
| Git链接 | ~/Library/Application Support/CursorChatHistory/links.sqlite | %APPDATA%/CursorChatHistory/... | ~/.local/share/CursorChatHistory/... |
| 上下文文件 | ~/.cursor-chat-history/context/conversations/ | 相同 | 相同 |
覆盖 CURSOR_DB_PATH 或 CURSOR_LINKS_DB_PATH.
工具参考
Core Tools Parameters
list_conversations
limit(默认值:10)-结果数量projectPath-按项目筛选keywords-搜索关键字hasCodeBlocks-按代码存在进行筛选
get_conversation
conversationId(必填)-对话IDsummaryOnly-仅返回摘要(保存上下文)
search_conversations
query-文本搜索keywords+keywordOperator('AND'/'OR')-多关键字likePattern-SQL LIKE模式
get_conversation_analytics
scope-“全部”、“最近”、“项目”projectPath-按项目筛选includeBreakdowns-\[“文件”、“语言”、“时间”、“大小”\]
Git Linker Tools Parameters
get_file_context
filePath(必需)-获取上下文的文件keywords-按关键字过滤(例如。,["JWT", "auth"])-返回匹配的摘录limit-最大结果(默认值:5)
list_conversation_commits
conversationId-按对话筛选projectPath-按项目筛选filePath-按文件筛选
get_commit_conversations
commitHash(必填)-Git提交哈希
link_conversation_commit
conversationId(必填)commitHash(必填)confidence-链接置信度(0-1)
发展
git clone https://github.com/vltansky/cursor-chat-history-mcp
cd cursor-chat-history-mcp
yarn install
yarn build支持的AI助手
| 助理 | 状态 | 备注 |
|---|---|---|
| 光标 | ✅ 完整 | 聊天、作曲、代理模式 |
| 克劳德代码 | ✅ 完整 | VS代码扩展 |
| 克莱恩/鲁/基洛 | ✅ 完整 | 基于JSON任务的存储 |
| 帆板运动 | ✅ 完整 | SQLite(与游标模式相同) |
| GitHub Copilot 聊天助手 | ✅ 完整 | VS代码本机 |
路线图
- \[ \] 知识图提取 -从对话中提取实体和关系(了解更多)
- \[x\] 多代理支持 -Cline,Windsurf,Copilot聊天
- \[x\] 质量评分 -优先考虑与解决方案的对话
- \[x\] 自然时间过滤器 -“上周”、“昨天”
- \[x\] 主题聚类 -按检测到的主题分组
- \[ \] 语义搜索 -通过嵌入找到类似的对话
技术说明
- 支持传统和现代Cursor对话格式
- 使用ROWID按时间顺序排序(UUID不是按时间顺序排列的)
- 关闭游标以避免数据库锁定问题
- 看 docs/SPEC.md 用于git链接器规范
许可证
麻省理工学院
