对话历史搜索工具

一个用于搜索和参考Claude Code对话历史的工具,提供全文搜索、完整对话查看和按项目浏览功能。

  • by tim0120
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 tim0120/claude-code-history-mcp

使用说明

Claude代码历史MCP

🤖 使用克劳德代码构建 -整个项目是通过与Claude Code的结对编程创建的,展示了它构建增强自身功能的工具的能力!

直接从Claude搜索并引用您的Claude Code对话历史记录!

特性

  • 🔍 全文搜索 在您所有的Claude Code对话中
  • 📝 查看完整对话 根据上下文
  • 🏷️ 按项目浏览 看你所有的作品
  • ⚡ 快速关键字搜索 使用SQLite FTS5

安装

  1. 克隆此存储库:
git clone https://github.com/tim0120/claude-code-history-mcp.git
cd claude-code-history-mcp
  1. 安装依赖项并构建:
npm install
npm run build
  1. 添加到您的Claude Code MCP设置中(~/.claude/claude_desktop_config.json):
{
  "mcpServers": {
    "claude-history": {
      "command": "node",
      "args": ["/path/to/claude-code-history-mcp/dist/index.js"]
    }
  }
}
  1. 重新启动Claude代码

用法

首次设置

当你第一次使用MCP时,你需要对现有的对话进行索引:

Use the tool: index_conversations

这将扫描您的 ~/.claude/projects 对所有对话进行目录和索引。

搜索您的历史记录

搜索特定错误、代码模式或主题:

Use the tool: search_history with query: "CORS error"
Use the tool: search_history with query: "database connection"
Use the tool: search_history with query: "TypeError"

获取完整的对话详细信息

搜索后,您可以获得完整的对话:

Use the tool: get_conversation with conversationId: "abc123"

列出所有项目

查看您的所有索引项目:

Use the tool: list_projects

运作原理

MCP:

  1. 从以下位置读取您的Claude Code对话历史记录 ~/.claude/projects
  2. 为本地SQLite数据库中的对话建立索引
  3. 提供全文搜索功能
  4. 返回相关片段和完整的对话详细信息

数据存储

  • 数据库位置: ~/.claude-code-mcp/history.db
  • 没有数据发送到外部服务
  • 您的对话历史记录保持在本地

路线图(v2)

  • []使用嵌入的语义搜索
  • []使用文件监视器自动索引
  • []与GPT-4的对话总结
  • []导出/导入功能
  • []搜索筛选器(日期、项目、成功/失败)

贡献

欢迎投稿!请随时提交问题和PR。

许可证

麻省理工学院