Skip to main content

wechat-clawbot

Python SDK for the WeChat ClawBot ilink API, with a built-in Claude Code Channel bridge.

Ported from @tencent-weixin/openclaw-weixin (TypeScript), synced with upstream v2.1.1.

WeChat (iOS) --> ClawBot --> ilink API --> [wechat-clawbot] --> Claude Code Session
                                                  |
Claude Code  <-- MCP Channel Protocol  <--  wechat_reply / wechat_send_file / wechat_typing

Features

  • Full ilink API client — getUpdates long-poll, sendMessage, getConfig, sendTyping, with iLink-App-Id / iLink-App-ClientVersion protocol headers
  • Multi-account support — QR code login with IDC redirect, credential storage, stale account cleanup
  • Media pipeline — AES-128-ECB encrypted CDN upload/download with full_url direct-URL support, image/video/file/voice
  • Context token persistence — survives process restarts, disk-backed with change detection
  • SILK transcoding — voice message to WAV conversion (optional)
  • Message processing — inbound conversion, slash commands, debug mode, error notices
  • Claude Code Channel — MCP server bridging WeChat messages into Claude Code sessions
  • Secure logging — automatic redaction of sensitive fields (tokens, authorization) in log output
  • Async-first — built on httpx + anyio with shared connection pools

Requirements

  • Python 3.10+
  • uv (recommended) or pip

Installation

uv add wechat-clawbot

Or with pip:

pip install wechat-clawbot

Optional extras:

uv add "wechat-clawbot[silk]"    # SILK voice transcoding
uv add "wechat-clawbot[socks]"   # SOCKS proxy support (e.g. behind a SOCKS5 proxy)

Quick Start — Claude Code Channel

1. Login with WeChat QR code

wechat-clawbot-cc setup

Scan the terminal QR code with WeChat. Credentials are saved to ~/.claude/channels/wechat/account.json.

2. Register the MCP server

claude mcp add wechat -- wechat-clawbot-cc serve

3. Start Claude Code with the WeChat channel

claude --channels server:wechat

Send a message in WeChat ClawBot, and Claude will reply.

Quick Start — Python SDK

import asyncio
from wechat_clawbot.api.client import WeixinApiOptions, get_updates, send_message
from wechat_clawbot.api.types import (
    MessageType, MessageState, MessageItemType,
    SendMessageReq, WeixinMessage, MessageItem, TextItem,
)

async def main():
    opts = WeixinApiOptions(base_url="https://ilinkai.weixin.qq.com", token="your-bot-token")

    # Long-poll for messages
    resp = await get_updates(base_url=opts.base_url, token=opts.token)
    for msg in resp.msgs or []:
        print(f"From: {msg.from_user_id}, Text: {msg.item_list}")

    # Send a reply
    await send_message(opts, SendMessageReq(msg=WeixinMessage(
        to_user_id="user@im.wechat",
        client_id="my-client-id",
        message_type=MessageType.BOT,
        message_state=MessageState.FINISH,
        item_list=[MessageItem(type=MessageItemType.TEXT, text_item=TextItem(text="Hello!"))],
        context_token="token-from-getupdates",
    )))

asyncio.run(main())

Project Structure

src/wechat_clawbot/
  api/              # ilink HTTP API client and protocol types
  auth/             # QR login, account storage, pairing
  cdn/              # AES-128-ECB crypto, CDN upload/download
  config/           # Pydantic configuration schema
  media/            # Media download, MIME types, SILK transcoding
  messaging/        # Inbound conversion, send, slash commands, process pipeline
  monitor/          # Long-poll monitor loop
  storage/          # State directory, sync buffer persistence
  util/             # Logger, ID generation, redaction
  claude_channel/   # Claude Code MCP Channel bridge (CLI + server)

Development

git clone https://github.com/nightsailer/wechat-clawbot.git
cd wechat-clawbot
uv sync

# Run tests
uv run pytest tests/ -v

# Lint
uv run ruff check src/ tests/

# Format
uv run ruff format src/ tests/

Documentation

License

MIT

Metadata

Release files for wechat-clawbot 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wechat-clawbot 0.3.0
File Size Uploaded Provenance Actions
wechat_clawbot-0.3.0.tar.gz 42.0 kB With provenance Details for wechat_clawbot-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wechat-clawbot 0.3.0
File Interpreter ABI Platform Actions
wechat_clawbot-0.3.0-py3-none-any.whl Python 3 none any Details for wechat_clawbot-0.3.0-py3-none-any.whl

Total release size: 101.3 kB

Release files / wechat_clawbot-0.3.0.tar.gz

Download URL wechat_clawbot-0.3.0.tar.gz
Size 42.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6ac19b1eee52c1bf199d7de6cb2166c3fa2e896a3f95889cc0cb227f82d4212b
BLAKE2b-256 checksum
How to use checksums
16e73b8ac278be66ccdb3151a0af2868a91b71b56de558e1e8a024df394972b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 29, 2026.

Transparency log

Release files / wechat_clawbot-0.3.0-py3-none-any.whl

Download URL wechat_clawbot-0.3.0-py3-none-any.whl
Size 59.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ffcc6d99229accbaf2ba5ca11423358ef280b3ceae94277ac76ea4db4996bbd5
BLAKE2b-256 checksum
How to use checksums
94645cc9183289c655f826bbc5e90ed54bf00910e6b89d1b4e14394ae202968f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 29, 2026.

Transparency log

Security for wechat-clawbot 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for wechat_clawbot-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page