wxchat-mcp
v0.7.1微信聊天记录 MCP 服务器:密钥提取、离线解密、会话/联系人/朋友圈/资金/小程序只读查询 + 4.x 图片 .dat 容器逆向
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
guide
聊天记录解密方式说明与加密数据文件清单(字典)
snapshot
把加密数据(db_storage + 密钥载体;可选 msg 附件)完整拷贝一份到工作区。只有默认(工作区内)快照会更新「最新快照」指针;传 target_dir 另存到别处时不改指针,避免影响后续读取路径
| Parameter | Type | Description |
|---|---|---|
include_attachments | boolean | 是否连同 msg 附件一并拷贝,默认 false |
target_dir | string | 自定义目标目录,默认 work/snapshots/<时间戳> |
decrypt
统一解密接口(幂等自举):密钥缺失自动在线提取(初次解密)→ 快照缺失自动创建 → 离线解密;已解密则返回 already_decrypted。只读查询会自动选用最近一个已解密的快照(不一定是 LATEST 指针指向的那个)
| Parameter | Type | Description |
|---|---|---|
snapshot_dir | string | 指定快照目录,默认最新已解密快照,缺失则自动创建 |
extract_key
初次解密:微信登录态运行时在线提取数据库密钥,产出 work/keys.json(HMAC 校验 100% 匹配才算成功)
status
检查数据与解密状态机(微信进程/源数据/密钥/快照/明文库),并给出下一步动作建议——AI 决策前先调用
list_sessions
列出全部会话(昵称/备注已解析;读解密后数据)
get_messages
读取某会话的消息列表(文本/系统可读,二进制消息标注类型与大小)。图片消息 detail 含 aeskey/md5/length,并额外给出 mid_length(本地压缩档字节)、hd_length(更高保真副本字节)、has_hd(本机是否有更清晰档可拿)、source_md5;配合 get_session_media 可定位到磁盘文件
| Parameter | Type | Description |
|---|---|---|
session * | string | 会话用户名,如 53773913713@chatroom 或 wxid_xxx |
after | integer | 只返回 local_id 大于此值的消息(增量游标) |
limit | integer | 返回条数,默认 500 |
search
全库搜索消息文本(LIKE;微信私有 FTS tokenizer 不可用,全库约 1-2s)。返回项含 session(会话 md5)、session_user(会话用户名,可直接喂给 get_messages)、session_name
| Parameter | Type | Description |
|---|---|---|
q * | string | 搜索关键词 |
limit | integer | 返回条数,默认 100 |
stats
明文库数据概况(消息表数/消息总数/时间范围)
list_contacts
好友列表(仅好友:已排除群成员缓存/群聊/公众号/企业微信/系统账号;昵称/备注/微信号/头像),支持关键字过滤
| Parameter | Type | Description |
|---|---|---|
keyword | string | 按昵称/备注/微信号/用户名模糊过滤 |
get_contact
单个联系人详情(含 kind 分类、是否好友 is_friend、所属群列表);kind=friend 才是好友,stranger_cache 是群成员缓存
| Parameter | Type | Description |
|---|---|---|
username * | string | 联系人的 wxid 或 chatroom 用户名 |
contact_stats
联系人统计(可信口径):好友数 friends + 非好友分类(群成员缓存 stranger_caches / 群聊 / 公众号 / 企业微信 / 系统账号 / 已删除)。回答"有多少联系人/好友"必须以此为准,禁止用总条目数或群成员数充当好友数
list_chatrooms
群列表(群名/成员数/群主),按成员数降序
get_chatroom_members
群成员列表(成员 wxid/昵称/备注,标记自己)
| Parameter | Type | Description |
|---|---|---|
chatroom * | string | 群用户名,如 53773913713@chatroom |
get_session_media
某会话的图片清单(attach 目录,长期留存的那一份)。每条含 image_md5(与 get_messages 图片消息的 detail.md5 对齐)、local_id/message_time(落到具体消息)、variant(mid|hd|thumb|bubble)、has_mid/has_hd/has_thumb、best(该图本地最高档)、decodable。取最高清图:挑 best=hd/mid 的条目,把 file 交给 read_dat_image 解码
| Parameter | Type | Description |
|---|---|---|
session * | string | 会话用户名 |
list_media
全部媒体浏览:video/(标准 jpg/mp4)、file/(文档)、attach 私有图片计数
read_attachment
读取媒体文件(相对账号目录或相对 msg/,限 msg、cache、temp、business、resource 下)。magic 探测格式,返回 base64 与 base64_bytes;微信私有图片容器(.dat,07085632)会提示改用 read_dat_image 解码。注意 base64 膨胀约 4/3:客户端 stdio 读缓冲需大于该值(MCP SDK 默认 10MB)
| Parameter | Type | Description |
|---|---|---|
rel * | string | 相对路径,如 video/2026-09/xxx.mp4、attach/<会话md5>/2026-07/Img/xxx.dat、cache/2026-09/HttpResource/xxx、file/2026-09/xxx.pdf |
max_bytes | integer | 上限字节,默认 8MB |
get_recalled
撤回消息记录(系统消息中的撤回事件,可按会话过滤)。返回项含 session(会话 md5)、session_user(会话用户名,可直接喂给其它工具)、session_name
| Parameter | Type | Description |
|---|---|---|
limit | integer | 返回条数,默认 100 |
session | string | 限定会话,缺省扫全库 |
conversation_stats
会话统计:消息总数/类型分布/活跃天数/时间范围/文本字数/我的消息数
| Parameter | Type | Description |
|---|---|---|
session * | string | 会话用户名 |
list_moments
朋友圈动态(sns.db SnsTimeLine):作者/时间/正文/媒体列表/点赞用户/位置,按时间倒序
| Parameter | Type | Description |
|---|---|---|
limit | integer | 返回条数,默认 50 |
offset | integer | 跳过条数(分页),默认 0 |
moments_interactions
朋友圈评论/点赞(SnsMessage_tmp3):content 非空=评论,空=点赞;feed_id 关联动态
| Parameter | Type | Description |
|---|---|---|
after | integer | 只返回 local_id 大于此值(增量游标) |
limit | integer | 返回条数,默认 100 |
transfer_records
转账记录(general.db transferTable + wcpay 卡片金额):会话/付款方/收款方/时间/金额/状态,按开始时间倒序
| Parameter | Type | Description |
|---|---|---|
limit | integer | 返回条数,默认 100 |
session | string | 限定会话用户名 |
red_packets
红包记录(general.db redEnvelopeTable):会话/发送者/send_id/类型/状态。注意本地拿不到红包金额——红包卡片(wcpayinfo)不含金额字段,金额只在领取结果里由服务端下发,故 amount 通常为空属正常(转账才在卡片里带金额)
| Parameter | Type | Description |
|---|---|---|
limit | integer | 返回条数,默认 100 |
session | string | 限定会话用户名 |
mini_programs
小程序使用记录(WeAppBizAttrSyncBufferTableV02):用户名/名称/最后使用时间/版本,按最后使用倒序。表里是 gh_xxx@app,名称取自 contact.db 同名主体(name_from 标明来源);未使用过的小程序可能无名
| Parameter | Type | Description |
|---|---|---|
limit | integer | 返回条数,默认 100 |
favorites
收藏(favorite.db fav_db_item):标题/类型/来源/更新时间/内容预览
| Parameter | Type | Description |
|---|---|---|
limit | integer | 返回条数,默认 100 |
voice_messages
语音消息清单(扫描消息库 local_type=34 + media_0 音频存在性):时长/格式/会话,按时间倒序
| Parameter | Type | Description |
|---|---|---|
limit | integer | 返回条数,默认 100 |
session | string | 限定会话用户名 |
get_voice_audio
语音解码:media_0.db VoiceInfo 的 SILK v3 原始帧(0x02+#!SILK_V3 + 长度前缀帧,24000Hz/20ms/单声道/16bit)解码为 WAV,返回 base64 与时长/格式详情。定位二选一:server_id(voice_messages 输出),或 session + local_id。WAV 超 max_bytes 上限时返回 error 提示(不返回 base64)
| Parameter | Type | Description |
|---|---|---|
local_id | integer | 消息 local_id(与 session 组合定位) |
max_bytes | integer | WAV base64 大小上限,默认 8MB(约 2.7 分钟) |
server_id | string | 语音 svr_id(voice_messages 返回的 server_id) |
session | string | 会话用户名(与 local_id 组合定位) |
emoticons
表情包(emoticon.db):已装表情包/自定义表情/收藏表情数量
biz_accounts
公众号列表(contact.db biz_info):用户名/名称/类型/主页/头像
| Parameter | Type | Description |
|---|---|---|
limit | integer | 返回条数,默认 200 |
wecom_groups
企业微信(bizchat.db):企业群/成员列表(企业微信会话的消息在消息库,可用 get_messages 读取)
recent_records
最近记录(general.db):会话内搜索关键词/最近转发/搜一搜历史
get_avatar
联系人头像(head_image.db 本地缓存 JPEG,base64 返回)
| Parameter | Type | Description |
|---|---|---|
username * | string | 联系人的 wxid |
message_resources
消息资源(message_resource.db):附件文件名/类型/大小/时间(如文件、图片、视频资源实体)
| Parameter | Type | Description |
|---|---|---|
limit | integer | 返回条数,默认 100 |
session | string | 限定会话用户名 |
dat_info
解析微信 4.x 图片 .dat 容器结构:头部/尾部尺寸、明文大小、尾部 XOR 0xB9、头部加密状态、variant(mid|hd|thumb|bubble)、以及当前账号密钥是否配置/是否匹配容器(dat_key.configured / matches_container)。rel 为账号目录或 msg/ 下的相对路径(msg/attach、cache/Bubble、cache/Sns、business/favorite 等均可)。未配置密钥时按 note 指引获取(scripts/wx_dat_key_watch.py 截获后写入 work/dat_key.json 或设 WX_DAT_HEAD_KEY)
| Parameter | Type | Description |
|---|---|---|
rel * | string | 相对路径,如 attach/<会话md5>/2026-06/Img/xxxx.dat、cache/2026-09/Sns/Img/xx/<名字> |
list_decoded_images
列出两类可直接解码的图片:images=微信自身解码过的副本(cache/…/ImageTemp 等,非本服务器解码)、originals=本地更高保真的副本(msg/attach 下的 *_h.dat,即同一张图未缩放的档,通常比压缩档清晰得多)。summary.hd_originals 即原图数量;拿着 file 交给 read_dat_image 即可解码。dat_key_configured 表示 .dat 头部密钥是否就绪
read_decoded_image
读取微信自身解码过的图片副本(base64;image_md5 取自 list_decoded_images)。标准 JPEG/PNG 可直接显示,wxgf 为微信私有编码
| Parameter | Type | Description |
|---|---|---|
md5 * | string | 图像 md5(list_decoded_images 返回的 image_md5) |
max_bytes | integer | 上限字节,默认 8MB |
read_dat_image
离线解码图片 .dat 返回完整图像 base64(头部 AES-128-ECB 每账号密钥 + 尾部 XOR 0xB9)。rel 为账号目录或 msg/ 下的相对路径,覆盖 msg/attach 的 mid/hd/thumb 变体与 cache/Bubble、cache/Sns、business/favorite 下的容器。密钥按当前账号解析(WX_DAT_HEAD_KEY 或 work/dat_key.json),与容器常量字段核对;未配置或不匹配时返回获取指引。标准 JPEG/PNG 直接返回;inner_wxgf=true 时若本机有 ffmpeg 会自动转成 PNG(wxgf_transcoded=true),否则原样返回并注明(可用 WX_FFMPEG 指定 ffmpeg 路径)
| Parameter | Type | Description |
|---|---|---|
rel * | string | 相对路径,如 attach/<会话md5>/2026-07/Img/xxxx.dat、attach/<会话md5>/2026-07/Img/xxxx_h.dat |
max_bytes | integer | 上限字节,默认 16MB |
list_plaintext_images
列出微信落盘的图片,两类混排(container 字段区分):① 明文图(无需密钥):聊天缩略图、微信解码过的副本、头像、小程序图标、HTTP 资源、粘贴截图;② .dat 容器(cache/Bubble 聊天显示版与卡片封面、cache/Sns 朋友圈、business/favorite 收藏实体):需 .dat 头部密钥,拿到 rel 后交给 read_dat_image 解码。条目按时间倒序,尽量关联到会话与消息(local_id/message_time/message_type)
| Parameter | Type | Description |
|---|---|---|
kind | string | 只列某一类;缺省列出全部(含各类计数汇总) |
limit | integer | 返回条数,默认 200 |
read_plaintext_image
读取图片(base64)。rel 取自 list_plaintext_images 返回的 rel。容器条目(.dat)自动走离线解码,明文条目直接读取;路径限 cache/temp/business 下
| Parameter | Type | Description |
|---|---|---|
rel * | string | 相对路径,如 cache/2026-08/Message/<会话md5>/Thumb/1234_1780000000_thumb.jpg |
max_bytes | integer | 上限字节,默认 8MB |