Skip to main content

LingTai WeChat MCP server — iLink Bot API client with LICC inbox callback.

Project description

lingtai-wechat

LingTai WeChat MCP server — iLink Bot API client with QR-code login, multi-modal messaging, and LICC inbox callback.

This is the canonical setup, configuration, and troubleshooting doc for the lingtai-wechat MCP. It is fetched by LingTai agents (or anyone else) when they need to install or configure this server.

MCP / LICC contract spec: see the lingtai-anatomy skill, reference/mcp-protocol.md, for the canonical specification of the catalog → registry → activation chain, environment-variable injection, and the LICC v1 inbox callback protocol. The reference client implementation is src/lingtai_wechat/licc.py in this repo (vendored verbatim into all first-party LingTai MCP repos — copy it if you're writing your own).

Tools

One omnibus MCP tool: wechat(action=...). Actions: send, check, read, reply, search, contacts, add_contact, remove_contact. Supports text, images, voice, video, and files (auto-detected from media_path extension).

Inbound messages (LICC)

Inbound WeChat messages flow into the host agent's inbox via the LingTai Inbox Callback Contract. Each new message is delivered as a LICC event with:

  • from — contact alias (or raw wxid_... if no contact saved).
  • subject"wechat message from <name>".
  • body — a ~300 char preview, including bracketed media references like [Image: /path], [Voice: /path], [Video: /path].
  • metadata.message_id — for reply.
  • metadata.from_user_id — raw wxid_....
  • metadata.item_types — list of message item types (text, image, voice, video, file).

Session expiry events are also delivered via LICC with metadata.event_type: "session_expired" so the agent knows to ask for re-login.

Install

# Into the LingTai agent's venv (typically ~/.lingtai-tui/runtime/venv/)
pip install git+https://github.com/Lingtai-AI/lingtai-wechat.git

After install, python -m lingtai_wechat (or the lingtai-wechat script) starts the MCP server over stdio.

QR-code login (one-time, before first use)

WeChat doesn't issue static bot tokens. Authenticate by scanning a QR code with the WeChat mobile app. From a shell on your agent's machine:

python -c "from lingtai_wechat.login import cli_login; cli_login('.secrets')"

This prints a QR code in the terminal (or saves a PNG, depending on your OS). Scan it with WeChat. On success, credentials.json is written into the directory you passed (.secrets in this example), containing bot_token, user_id, and base_url.

Sessions expire periodically (typically ~30 days). When expired, you'll see a LICC event with metadata.event_type: "session_expired" — re-run the login command.

Configure

The server reads two files from the directory pointed at by LINGTAI_WECHAT_CONFIG:

  • config.json — user-controlled options.
  • credentials.json — written by cli_login. Don't edit by hand.

config.json schema

{
  "poll_interval": 1.0,
  "allowed_users": ["wxid_abc123"],
  "cdn_base_url": "https://..."
}
  • poll_interval — seconds between iLink long-polls (default 1.0).
  • allowed_users — optional allow-list of WeChat user IDs. When set, messages from other senders are silently ignored. Omit to accept any sender.
  • cdn_base_url — usually omit; the default works.

Activation in LingTai

{
  "addons": ["wechat"],
  "mcp": {
    "wechat": {
      "type": "stdio",
      "command": "/path/to/your/python",
      "args": ["-m", "lingtai_wechat"],
      "env": {
        "LINGTAI_WECHAT_CONFIG": ".secrets/config.json"
      }
    }
  }
}

Then run system(action="refresh") from the agent. The MCP subprocess starts, the iLink long-poll begins, and the omnibus wechat tool becomes available.

Troubleshooting

  • LINGTAI_WECHAT_CONFIG env var not set — your init.json mcp.wechat.env entry is missing the LINGTAI_WECHAT_CONFIG key.
  • WeChat config not found — the path resolves but no file exists. Relative paths are resolved against LINGTAI_AGENT_DIR.
  • WeChat credentials not found — config exists but credentials.json doesn't. Run the QR-code login flow above.
  • WeChat session expired event in agent inbox — re-run the QR-code login flow.
  • All connection attempts failed in stderr — usually a stale base_url in credentials. Re-run login.
  • MCP server failed to start — usually the command path in init.json doesn't have lingtai_wechat installed. Confirm with <command> -m lingtai_wechat --help from a shell.
  • Tool calls return WeChat manager not initialized — server boot failed (missing config or expired creds). Check stderr.

License

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lingtai_wechat-0.1.0.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lingtai_wechat-0.1.0-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file lingtai_wechat-0.1.0.tar.gz.

File metadata

  • Download URL: lingtai_wechat-0.1.0.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for lingtai_wechat-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ca2b44ff2bed07fb92f45909c41bcef7f7f2514062a6421fd3756a8900fcbd9c
MD5 a9937c6861c738e78d3c57ece689948f
BLAKE2b-256 14fd3e97acd2c92409492f8d8f8a311b454999311353b6f8110711a7467ed47a

See more details on using hashes here.

File details

Details for the file lingtai_wechat-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lingtai_wechat-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for lingtai_wechat-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac3466b95561f4c02ef9499092aff6aca0476b1a42956b7e3e26f7e5b5188d82
MD5 49a1cfdef0ba75f241dbf8e3c067e2d4
BLAKE2b-256 1701cd6c47a473d607ee5f0190bf43c377d6d7e9c68680c53e9e80c66e597895

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page