<p align="center">
  <img src="https://img.shields.io/npm/v/wechat-dev-mcp.svg" alt="npm version" />
  <img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg" alt="node" />
  <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="license" />
</p>

<h1 align="center">WeChat DevTools MCP</h1>

<p align="center"><b>Drive WeChat DevTools with plain English — debug mini-programs & mini-games via AI.</b></p>

<p align="center">
  <a href="README.md">🇨🇳 中文</a> · 🇺🇸 English
</p>

---

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
- 👆 **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

Full mini-game guide: [docs/MINIGAME_GUIDE.md](docs/MINIGAME_GUIDE.md) (Chinese).

---

## ❓ FAQ

| Problem | Fix |
|---------|-----|
| `Connection refused` | DevTools running + Service Port enabled |
| 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` |

---

[MIT](LICENSE) © CuiJiawei · Issues & PRs welcome
