go install github.com/sjzar/chatlog@latest
访问 Releases 页面下载适合您系统的预编译版本。
下载并安装微信客户端
手机微信上操作 我 - 设置 - 通用 - 聊天记录迁移与备份 - 迁移 - 迁移到电脑
,这一步的目的是将手机中的聊天记录传输到电脑上。可以放心操作,不会影响到手机上的聊天记录。
下载 chatlog
预编译版本或从源码安装,推荐使用 go 进行安装。
运行 chatlog
,按照提示进行操作,解密数据并开启 HTTP 服务后,即可通过浏览器或 AI 助手访问聊天记录。
# 1. 进入恢复模式
Apple Intel Mac: 关机后,按住 Command + R 键开机,直到出现苹果标志和进度条。
Apple Silicon Mac: 关机后,按住开机键不松开,直到出现苹果标志和进度条。
# 2. 打开终端
选项 - 实用工具 - 终端
# 3. 关闭 SIP
输入以下命令关闭 SIP:
csrutil disable
# 4. 重启系统
目前的 macOS 版本方案依赖 lldb
工具,所以需要安装 Xcode,可以从 App Store 进行下载。
仅获取数据密钥步骤需要关闭 SIP;获取数据密钥后即可重新打开 SIP,不影响解密数据和 HTTP 服务的运行。
./chatlog
Enter
选择菜单项Esc
返回上一级菜单Ctrl+C
退出程序获取微信数据密钥:
./chatlog key
解密数据库文件:
./chatlog decrypt
启动 HTTP 服务后,可以通过以下 API 访问数据:
GET /api/v1/chatlog?time=2023-01-01&talker=wxid_xxx&limit=100&offset=0&format=json
参数说明:
time
: 时间范围,格式为 YYYY-MM-DD
或 YYYY-MM-DD~YYYY-MM-DD
talker
: 聊天对象的 ID,不知道 ID 的话也可以尝试备注名、昵称、群聊 ID等limit
: 返回记录数量限制offset
: 分页偏移量format
: 输出格式,支持 json
、csv
或纯文本GET /api/v1/contact
GET /api/v1/chatroom
GET /api/v1/session
支持 MCP SSE 协议,启动 HTTP 服务后,通过 SSE Endpoint 访问服务:
GET /sse
提供了 4 个 tool 用于与 AI 助手集成:
chatlog
: 查询聊天记录query_contact
: 查询联系人query_chat_room
: 查询群聊query_recent_chat
: 查询最近会话以 ChatWise 工具为例,在 设置 - 工具
下新建工具,类型为 sse
,ID 为 chatlog
,URL 为 http://127.0.0.1:5030/sse
,勾选自动执行工具,即可使用。
部分 AI 聊天工具暂时不支持 MCP SSE 协议,可以通过 mcp-proxy
工具转发请求,以 Claude Desktop 为例,在安装好 mcp-proxy
后,将 mcp-proxy
配置到 Claude Desktop
的 config.json
文件中,即可使用:
{
"mcpServers": {
"mcp-proxy": {
"command": "/Users/sarv/.local/bin/mcp-proxy",
"args": [
"http://localhost:5030/sse"
],
"env": {}
}
},
"globalShortcut": ""
}
chatlog
是在 Apache-2.0 许可下的开源软件。
{
"mcpServers": {
"mcp-proxy": {
"env": {},
"args": [
"http://localhost:5030/sse"
],
"command": "/Users/sarv/.local/bin/mcp-proxy"
}
}
}
Seamless access to top MCP servers powering the future of AI integration.