npm version node license

WeChat DevTools MCP

Drive WeChat DevTools with plain English โ€” debug mini-programs & mini-games via AI.

๐Ÿ‡จ๐Ÿ‡ณ ไธญๆ–‡ ยท ๐Ÿ‡บ๐Ÿ‡ธ English

--- Just talk to your AI in natural language. It connects, finds errors, and verifies by screenshot โ€” for you: > ๐Ÿ—ฃ๏ธ "Open my mini-program โ†’ go to home โ†’ tap login โ†’ screenshot it" > > ๐ŸŽฎ "Open the mini-game โ†’ tap cell (2,10) โ†’ screenshot โ†’ export logs" Works with WorkBuddy, Claude Code, Cursor, Cline, Zed, and any MCP client. --- ## ๐Ÿš€ Get started in 3 steps **1. Install** ```bash npx -y wechat-dev-mcp ``` **2. Plug into your client** (same command, only the config file location differs) Cursor example โ€” edit `~/.cursor/mcp.json`: ```json { "mcpServers": { "wechat-devtools": { "command": "npx", "args": ["-y", "wechat-dev-mcp"] } } } ``` > A ready-to-use `.cursor/mcp.json` / `.mcp.json` ships in the repo, or grab [`examples/cursor-mcp-config.json`](examples/cursor-mcp-config.json). Other clients (Claude Code / Desktop, Codex, Windsurf, Cline, Zed) use the same command. **3. Just talk to your AI** > "Open `/Users/you/project`, go to home, tap login, then screenshot it for me" That's it. --- ## โœ… Prerequisites (one-time) - **WeChat DevTools** installed, with **Service Port** enabled: `Settings โ†’ Security โ†’ Service Port` - **Node.js โ‰ฅ 18** > โš ๏ธ Without the Service Port you'll get `Connection refused`. --- ## ๐Ÿงฉ Companion Skill (optional, recommended) [wechat-dev-skill](https://github.com/jiawei686/wechat-dev-skill) wraps the "scan build / devtools / output / networks for errors" routine into one sentence. Install it, then just say "debug this project" and it locates errors for you. --- ## ๐Ÿ›  What it does (highlights) - ๐Ÿ“ธ **Screenshot**: live capture of mini-program pages / mini-game canvas - ๐Ÿ–ผ **Canvas export**: `export_canvas` dumps the **real content** of a page `` to a PNG - ๐Ÿ‘† **Touch**: tap / long-press / swipe (mini-game cell taps auto-compensated for precise hits) - ๐Ÿ“œ **Logs**: console / vConsole / network requests to locate errors - ๐Ÿ”„ **Restart**: re-open & recompile safely (no crash-prone `Page.reload`) - ๐Ÿงช **Verify**: auto-connects the simulator, runs flows, checks the UI > โš ๏ธ **Screenshots cannot see ``.** The automator's page screenshot composites regular nodes > only, so a canvas region comes out as flat background. Verified: painting an entire canvas solid red > left the resulting screenshot **byte-identical**. So on any page that draws into a canvas, never > judge "did it render?" from a screenshot โ€” use `export_canvas`. Full mini-game guide: [docs/MINIGAME_GUIDE.md](docs/MINIGAME_GUIDE.md) (Chinese). --- ## โ“ FAQ | Problem | Fix | |---------|-----| | `Connection refused` | DevTools running + Service Port enabled | | Launch fails with `make sure http port is open` | Cold-start race: the first `cli auto` launches the IDE then exits. Open the project manually once and retry, or run `cli auto --project --auto-port 9420` first and then `connect` | | Screenshot shows a flat block where the canvas is | Expected โ€” see the note above; use `export_canvas` instead | | `get_console_logs` reports nothing | Logs are collected **from the moment you connect**. To catch startup errors, connect first, then restart the project | | Mini-game tap does nothing | Get the game into an interactive screen first (e.g. "start game"), then ask AI to tap | | Tap lands off | Use `game_tap_grid` (compensated); re-calibrate if still off | | Game frozen | Ask AI to `restart_project`; **don't** use `Page.reload` | | `evaluate` returns undefined | The script is compiled as a function **body** (`new Function`), so it needs an explicit `return` โ€” write `return 1+1`, not `1+1` | | Firing several stateful calls (`navigate_to` / `tap_element` / `input_text`) at once โ€” only the first takes effect | Send these **one per message** and wait for each to return. Issued in parallel they overwrite each other, and **every one still reports success** โ€” the state is dropped silently, and only `get_page_stack` reveals where you actually landed | --- [MIT](LICENSE) ยฉ CuiJiawei ยท Issues & PRs welcome