cursor-chats-bridge
cursor-chats-bridge
一个只读桥接器,让 Claude Code 能够实时且跨会话地查看你在 Cursor 中的操作。
如果你同时使用 Claude Code 和 Cursor(例如:在 Cursor 中进行代理驱动的编辑,同时使用 Claude 进行规划/审计),此技能将 Cursor 的本地聊天数据库作为 MCP 服务器接入 Claude,并每 5 分钟记录一次新消息,以便 Claude 可以回答诸如“今天早上 Cursor 在做什么?”之类的问题,即使当时 Claude 并未运行。
设计上为只读。绝不会修改 Cursor 的数据。
你将获得什么
安装后,Claude Code 将获得七个工具(均以 mcp__cursor-chats__ 为前缀):
工具 | 功能 |
| 列出聊天记录中出现的所有 Cursor 工作区,包含哈希 ID 和路径。 |
| 列出 Cursor 聊天记录,可选择按工作区 ID、路径子字符串或通过 Claude 的 |
| 获取特定聊天记录的消息(通过 composer UUID)。 |
| 便捷功能:获取当前工作区中打开的 Cursor 聊天的实时消息。 |
| 在聊天名称、副标题和消息文本中进行子字符串搜索。 |
| 读取由后台轮询器捕获的新消息的追加日志。 |
| 在时间窗口内聚合统计信息:按角色分类的消息、涉及的对话、最近的文本片段。 |
此外还有一个 Windows 计划任务 ClaudeCursorChatPoller,每 5 分钟运行一次,检测每个工作区活动聊天中的新消息,并将它们追加到 ~/.claude/mcp/cursor-chats/journal.ndjson 下的 JSON 行日志中。
Related MCP server: cursor-history-mcp
为什么存在这个工具
Cursor 的聊天数据本地存储在 SQLite KV 存储中 (%APPDATA%\Cursor\User\globalStorage\state.vscdb),但有两个令人困扰的限制:
只有每个工作区当前打开的聊天会将消息存储在本地——旧的聊天记录会被归档到 Cursor 的云端,仅保留元数据。
没有公开 API。
因此,仅靠实时的 MCP 查询是不够的:如果你在下午 3 点问“今天早上 Cursor 做了什么?”,相关的消息可能已经被归档了。轮询器通过在消息出现时捕获它们来解决这个问题,并带有工作区标记,以便不同的 Claude 项目可以清晰地进行过滤。
架构
┌──────────────────────────────────────────────────────────────────┐
│ Windows Task Scheduler >> pythonw poller.py >> /5 min, 24/7│
└──────────────────────────────────────────────────────────────────┘
│
▼ (read mode=ro,immutable=1)
┌──────────────────────────────────┐
│ Cursor SQLite globalStorage │ ← live, written by Cursor
│ state.vscdb / cursorDiskKV │
└──────────────────┬───────────────┘
│
▼ (append-only)
┌──────────────────────────────────┐
│ ~/.claude/mcp/cursor-chats/ │
│ ├─ active_snapshot.json │
│ ├─ journal.ndjson │
│ └─ poller.log (errors) │
└──────────────────┬───────────────┘
│
▼ (on-demand)
┌──────────────────────────────────┐
│ MCP server (server.py) │
│ exposes 7 tools │
└──────────────────┬───────────────┘
│
▼
Claude Code有关更深入的内部结构(SQLite 键模式、工作区识别、边缘情况),请参阅 references/architecture.md。
要求
Windows 10 / 11(暂不支持 Linux/macOS — 使用了
schtasks和 Windows Cursor 路径)Python 3.10+,且需具备
pythonw.exe(用于计划任务的静默运行)Claude Code CLI 位于
PATH中(claude --version应能正常工作)Cursor 已安装并至少打开过一次(SQLite 在首次运行时创建)
安装程序会检查所有这些要求,如果缺少任何内容,会快速失败并提供可操作的错误信息。
安装
作为 Claude Code 技能(推荐)
将文件夹放入你的 Claude Code 技能目录:
~/.claude/skills/cursor-chats-bridge/在 Windows 上:
C:\Users\<you>\.claude\skills\cursor-chats-bridge\。重启 Claude Code(或直接打开一个新会话)。
向 Claude 询问类似“install the cursor-chats bridge”或“set up the Claude-Cursor connection”的内容——技能描述已针对这些措辞进行了优化。
Claude 会读取
SKILL.md,运行scripts/install.ps1,并报告结果。重启 Claude Desktop(从系统托盘完全退出)以加载 MCP 服务器。
手动安装(无需 Claude)
如果你想跳过代理步骤:
powershell -ExecutionPolicy Bypass -File "C:\Users\<you>\.claude\skills\cursor-chats-bridge\scripts\install.ps1"该脚本:
验证先决条件(Python,
pythonw.exe,claudeCLI, Cursor SQLite 路径)将
server.py和poller.py复制到~/.claude/mcp/cursor-chats/如果缺失,通过 pip 安装 Python
mcp包移除任何先前的
cursor-chatsMCP 注册,然后添加它(默认作用域:local)创建/更新
ClaudeCursorChatPoller计划任务(每 5 分钟一次,通过pythonw.exe静默运行)运行一次轮询器以初始化快照/日志
重新运行是安全的:每一步都使用强制覆盖语义。状态文件(active_snapshot.json, journal.ndjson)会被保留。
安装程序标志
标志 | 效果 |
| 禁止进度输出。 |
| 跳过创建计划任务(一次性使用/调试)。 |
| MCP 注册作用域。默认为 |
验证
安装并重启 Claude 后:
claude mcp list
schtasks /Query /TN ClaudeCursorChatPoller /FO LIST两者都应显示条目;claude mcp list 行应报告 cursor-chats 为 ✓ Connected。
在 Claude 会话中,你可以询问:
“List my Cursor workspaces.” “What's the latest message from my Cursor agent?” “Summarize what I did with Cursor this morning.”
Claude 如何使用它(典型模式)
MCP 不会自行轮询——Claude 在有意义时会调用这些工具。后台轮询器(独立进程)处理持续捕获,因此日志查询可以在不保持实时对话的情况下回答“在你没看的时候发生了什么”。
示例:
接手 — “continue what I was doing with Cursor” → Claude 调用
get_active_chat获取实时对话,进行总结,并询问从哪里接手。回顾 — “recap of my Cursor activity since 9 AM” → Claude 调用
get_journal_summary(window_minutes=N)并引导你了解发生了什么变化。交叉检查 — “is what Cursor is suggesting consistent with our plan?” → Claude 读取最新的 Cursor 消息,与自己的上下文进行比较,并标记差异。
搜索 — “where did I discuss the SQL backfill with Cursor?” → Claude 调用
search_chats("backfill"),然后使用get_chat深入查看匹配项。
隐私与安全
通过 SQLite 强制只读 (
mode=ro,immutable=1)。即使是有 Bug 的脚本也无法修改 Cursor 的数据。所有数据保留在本地。 日志和快照位于
~/.claude/下,受用户配置文件级别的 Windows ACL 保护。不会上传任何内容。凭据警告。 你的 Cursor 聊天记录可能包含粘贴的 API 密钥、密码等。日志会逐字存储消息文本。如果这令人担忧,请谨慎选择粘贴到 Cursor 中的内容,或事后过滤日志。
MCP 作用域。 默认的
local意味着桥接器仅在你运行安装程序的项目中处于活动状态。使用-Scope user使其全局化。
卸载
powershell -ExecutionPolicy Bypass -File "<skill-dir>\scripts\uninstall.ps1"默认情况下,移除计划任务,从 Claude 取消注册 MCP,并删除 ~/.claude/mcp/cursor-chats/。传递 -KeepData 以保留 active_snapshot.json 和 journal.ndjson。
限制与已知问题
仅限 Windows。 macOS/Linux 变体是可行的(使用 cron 代替
schtasks,macOS 上使用~/Library/Application Support/Cursor/...路径),但尚未实现。Cursor 模式依赖。 该桥接器读取未记录的 Cursor 内部结构。如果 Cursor 重命名
cursorDiskKV或在版本之间更改了 composer JSON 形状,脚本可能需要打补丁。如果日志停止增长,请检查poller.log。仅限活动聊天。 旧的/已归档的聊天仅提供元数据。实时消息仅存在于每个工作区当前打开的聊天中。
无回填。 轮询器在首次看到工作区时会跳过历史消息(否则会淹没日志)。仅捕获未来的消息。
Cursor 必须打开,新消息才能进入 SQLite。如果 Cursor 关闭,轮询器仍能正常运行,但不会写入新条目。
项目布局
cursor-chats-bridge/
├── SKILL.md # YAML frontmatter + Claude-facing instructions
├── README.md # this file
├── scripts/
│ ├── server.py # MCP server (Python, ~300 lines)
│ ├── poller.py # Background poller (Python, ~180 lines)
│ ├── install.ps1 # Idempotent installer
│ └── uninstall.ps1 # Clean removal
└── references/
└── architecture.md # Deep technical doc (SQLite layout, edge cases)贡献
欢迎提交 Pull Request — 特别是针对:
macOS / Linux 支持 (cron + Library/Application Support 路径)
模式弹性:尽早检测 Cursor 版本更改的辅助工具
可选的日志轮转/压缩
在非法语查询中更好地触发技能
许可证
MIT — 做你想做的,不提供任何保证。请参阅 LICENSE。
免责声明
这是一个第三方工具,不隶属于 Anthropic 或 Cursor。它通过非官方手段读取 Cursor 的本地数据,可能会随着 Cursor 的未来版本而失效。请自行承担使用风险,特别是在处理敏感数据的机器上。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Search your AI chat history (ChatGPT, Claude, Codex) from any MCP client. Remote, private, read-only
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Hosted Airtable MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA Python server implementing the Model Context Protocol that exposes tools for querying external APIs, compatible with Claude Desktop and ChatGPT Desktop.-
- AlicenseAqualityBmaintenanceMCP server for browsing, searching, exporting, and backing up your Cursor AI chat history directly into Claude via natural language.866 npm34MIT
- AlicenseNot gradedqualityCmaintenanceLocal MCP server for CairnOS, a local-first productivity app. Exposes 13 tools that let Claude read and write the same local SQLite "brain" the app uses — create and update tasks, projects, reminders, ideas, and notes; classify natural-language brain dumps; and query overdue/today tasks and project context.MIT
- AlicenseNot gradedqualityCmaintenanceMCP server for unified full-text search across chat histories from Claude Code, Codex, Cursor CLI, and Antigravity CLI, using SQLite FTS5. Provides read-only tools to search sessions, list conversations, and retrieve session details.MIT