Sponsored by Deepsite.site

Chatlog

Created By
sjzar8 months ago
Content

Feature

  • 从本地数据库文件获取聊天数据
  • 支持 Windows / macOS 系统
  • 支持微信 3.x / 4.0 版本
  • 提供 Terminal UI 界面 & 命令行工具
  • 提供 HTTP API 服务,支持查询聊天记录、联系人、群聊、最近会话等信息
  • 支持 MCP SSE 协议,可与支持 MCP 的 AI 助手无缝集成
  • 支持多媒体消息,支持解密图片、语音
  • 支持自动解密数据,简化使用流程
  • 支持多账号管理,可在不同账号间切换

TODO

  • 聊天数据全文索引
  • 聊天数据统计 & Dashboard

Quick Start

基本步骤

  1. 安装 Chatlog下载预编译版本使用 Go 安装
  2. 运行程序:执行 chatlog 启动 Terminal UI 界面
  3. 解密数据:选择 解密数据 菜单项
  4. 开启 HTTP 服务:选择 开启 HTTP 服务 菜单项
  5. 访问数据:通过 HTTP APIMCP 集成 访问聊天记录

💡 提示:如果电脑端微信聊天记录不全,可以从手机端迁移数据

常见问题快速解决

安装指南

从源码安装

go install github.com/sjzar/chatlog@latest

下载预编译版本

访问 Releases 页面下载适合您系统的预编译版本。

使用指南

Terminal UI 模式

最简单的使用方式是通过 Terminal UI 界面操作:

chatlog

操作方法:

  • 使用 键选择菜单项
  • Enter 确认选择
  • Esc 返回上级菜单
  • Ctrl+C 退出程序

命令行模式

对于熟悉命令行的用户,可以直接使用以下命令:

# 获取微信数据密钥
chatlog key

# 解密数据库文件
chatlog decrypt

# 启动 HTTP 服务
chatlog server

从手机迁移聊天记录

如果电脑端微信聊天记录不全,可以从手机端迁移数据:

  1. 打开手机微信,进入 我 - 设置 - 通用 - 聊天记录迁移与备份
  2. 选择 迁移 - 迁移到电脑,按照提示操作
  3. 完成迁移后,重新运行 chatlog 获取密钥并解密数据

此操作不会影响手机上的聊天记录,只是将数据复制到电脑端

平台特定说明

Windows 版本说明

如遇到界面显示异常(如花屏、乱码等),请使用 Windows Terminal 运行程序

macOS 版本说明

macOS 用户在获取密钥前需要临时关闭 SIP(系统完整性保护):

  1. 关闭 SIP

    # 进入恢复模式
    # Intel Mac: 重启时按住 Command + R
    # Apple Silicon: 重启时长按电源键
    
    # 在恢复模式中打开终端并执行
    csrutil disable
    
    # 重启系统
    
  2. 安装必要工具

    # 安装 Xcode Command Line Tools
    xcode-select --install
    
  3. 获取密钥后:可以重新启用 SIP(csrutil enable),不影响后续使用

Apple Silicon 用户注意:确保微信、chatlog 和终端都不在 Rosetta 模式下运行

HTTP API

启动 HTTP 服务后(默认地址 http://127.0.0.1:5030),可通过以下 API 访问数据:

聊天记录查询

GET /api/v1/chatlog?time=2023-01-01&talker=wxid_xxx

参数说明:

  • time: 时间范围,格式为 YYYY-MM-DDYYYY-MM-DD~YYYY-MM-DD
  • talker: 聊天对象标识(支持 wxid、群聊 ID、备注名、昵称等)
  • limit: 返回记录数量
  • offset: 分页偏移量
  • format: 输出格式,支持 jsoncsv 或纯文本

其他 API 接口

  • 联系人列表GET /api/v1/contact
  • 群聊列表GET /api/v1/chatroom
  • 会话列表GET /api/v1/session

多媒体内容

聊天记录中的多媒体内容会通过 HTTP 服务进行提供,可通过以下路径访问:

  • 图片内容GET /image/<id>
  • 视频内容GET /video/<id>
  • 文件内容GET /file/<id>
  • 语音内容GET /voice/<id>
  • 多媒体内容GET /data/<data dir relative path>

当请求图片、视频、文件内容时,将返回 302 跳转到多媒体内容 URL。
当请求语音内容时,将直接返回语音内容,并对原始 SILK 语音做了实时转码 MP3 处理。
多媒体内容 URL 地址为基于数据目录的相对地址,请求多媒体内容将直接返回对应文件,并针对加密图片做了实时解密处理。

MCP 集成

Chatlog 支持 MCP (Model Context Protocol) SSE 协议,可与支持 MCP 的 AI 助手无缝集成。
启动 HTTP 服务后,通过 SSE Endpoint 访问服务:

GET /sse

快速集成

Chatlog 可以与多种支持 MCP 的 AI 助手集成,包括:

  • ChatWise: 直接支持 SSE,在工具设置中添加 http://127.0.0.1:5030/sse
  • Cherry Studio: 直接支持 SSE,在 MCP 服务器设置中添加 http://127.0.0.1:5030/sse

对于不直接支持 SSE 的客户端,可以使用 mcp-proxy 工具转发请求:

  • Claude Desktop: 通过 mcp-proxy 支持,需要配置 claude_desktop_config.json
  • Monica Code: 通过 mcp-proxy 支持,需要配置 VSCode 插件设置

详细集成指南

查看 MCP 集成指南 获取各平台的详细配置步骤和注意事项。

Server Config

{
  "mcpServers": {
    "chatlog": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "http://localhost:5030/sse"
      ],
      "_comment1": "This is a MCP SSE Server, must be installed locally to be used.",
      "_comment2": "Config Consultation: https://github.com/sjzar/chatlog/blob/main/docs/mcp.md"
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Tavily Mcp
CursorThe AI Code Editor
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Playwright McpPlaywright MCP server
WindsurfThe new purpose-built IDE to harness magic
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Serper MCP ServerA Serper MCP Server
Amap Maps高德地图官方 MCP Server
DeepChatYour AI Partner on Desktop
ChatWiseThe second fastest AI chatbot™
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"