聊天历史查询服务

连接ChatLab与AI助手的MCP服务器,支持通过自然语言查询本地聊天历史记录。

  • by gamesme
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 gamesme/chatlab-mcp-server

使用说明

聊天室mcp

英语 | 简体中文 | 繁体中文 | 日本语

连接的MCP服务器 聊天室 AI助手(Claude Desktop、Cursor、自定义代理)。使用自然语言查询您的本地聊天记录。

追踪聊天实验室v0.17.2

需求

  • 聊天室 已安装并正在运行
  • 在聊天室设置中启用API→ API,生成一个令牌
  • Node.js 18+

安装

npx(推荐)

无需安装。直接配置您的AI客户端:

{
  "mcpServers": {
    "chatlab": {
      "command": "npx",
      "args": ["-y", "chatlab-mcp"],
      "env": {
        "CHATLAB_TOKEN": "clb_xxxxxxxxxxxx",
        "CHATLAB_URL": "http://127.0.0.1:5200"
      }
    }
  }
}

来源

git clone https://github.com/gamesme/chatlab-mcp
cd chatlab-mcp
npm install && npm run build

克劳德桌面版

编辑 ~/Library/Application Support/Claude/claude_desktop_config.json:

使用npx:

{
  "mcpServers": {
    "chatlab": {
      "command": "npx",
      "args": ["-y", "chatlab-mcp"],
      "env": {
        "CHATLAB_TOKEN": "clb_xxxxxxxxxxxx",
        "CHATLAB_URL": "http://127.0.0.1:5200"
      }
    }
  }
}

从源代码(使用Homebrew节点避免版本问题):

{
  "mcpServers": {
    "chatlab": {
      "command": "/opt/homebrew/bin/node",
      "args": ["/absolute/path/to/chatlab-mcp/dist/index.js"],
      "env": {
        "CHATLAB_TOKEN": "clb_xxxxxxxxxxxx",
        "CHATLAB_URL": "http://127.0.0.1:5200"
      }
    }
  }
}

保存后重新启动Claude Desktop。这 chatlab 工具将出现在工具列表中。

工具

工具 说明
list_sessions 列出所有导入的聊天会话,包括名称、平台和消息计数
get_session 按ID获取单个会话的详细信息
get_messages 使用过滤器检索邮件:关键字、时间范围、发件人、分页(最多100个/呼叫)
get_members 列出会话中的所有成员及其平台ID和消息计数
get_stats_overview 统计概述:消息计数、成员活动、类型分布、时间范围
execute_sql 对会话数据库运行聚合查询(COUNT/GROUP BY)

备注

  • get_messages 每次呼叫最多返回100条消息。使用 page 要分页的参数。回应包括 has_more 和一个 hint 当存在更多结果时。
  • execute_sql 仅用于统计聚合(词频、活动细分、成员交互)。使用 get_messages 阅读消息内容。
  • 所有头像/二进制字段都从响应中删除,以尽量减少上下文使用。

CLI选项

node dist/index.js --token <token> --url <url>
# or via env vars
CHATLAB_TOKEN=clb_xxx CHATLAB_URL=http://127.0.0.1:5200 node dist/index.js

CHATLAB_URL 默认为 http://127.0.0.1:5200.

发展

npm test             # run all tests
npm run test:watch   # watch mode
npm run dev          # run with ts-node (no build step)
npm run build        # compile TypeScript → dist/