@weadmin/weixin-minigame-helper-mcp 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +158 -0
- package/mcp/index.js +8 -0
- package/media/wx-compat.js +1 -0
- package/package.json +22 -0
- package/templates/game-host.html +1 -0
- package/templates/preview.html +5 -0
package/README.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# @weadmin/weixin-minigame-helper-mcp
|
|
2
|
+
|
|
3
|
+
WeChat Mini Game MCP Server — Preview, debug, real-device test and publish WeChat Mini Games from any MCP-compatible AI coding assistant.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package provides a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server that enables AI coding assistants (such as Claude, CodeBuddy, Cursor, etc.) to preview, hot-reload, real-device test, and publish WeChat Mini Games — all through natural language.
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
### Use with npx (recommended)
|
|
12
|
+
|
|
13
|
+
No installation needed. Configure your MCP client with:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"mcpServers": {
|
|
18
|
+
"weixin-minigame-helper": {
|
|
19
|
+
"command": "npx",
|
|
20
|
+
"args": [
|
|
21
|
+
"-y",
|
|
22
|
+
"@weadmin/weixin-minigame-helper-mcp@latest"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Global install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install -g @weadmin/weixin-minigame-helper-mcp
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Then configure your MCP client with:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"mcpServers": {
|
|
40
|
+
"weixin-minigame-helper": {
|
|
41
|
+
"command": "weixin-minigame-helper-mcp"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## MCP Tools
|
|
48
|
+
|
|
49
|
+
This server exposes the following tools:
|
|
50
|
+
|
|
51
|
+
### `run_game`
|
|
52
|
+
|
|
53
|
+
Start a WeChat Mini Game preview. Launches a local dev server and serves the game in a browser.
|
|
54
|
+
|
|
55
|
+
| Parameter | Type | Required | Description |
|
|
56
|
+
|---|---|---|---|
|
|
57
|
+
| `workspacePath` | string | ✅ | Absolute path to the Mini Game directory (must contain `game.js`) |
|
|
58
|
+
|
|
59
|
+
**Returns:** Local preview URL and port number.
|
|
60
|
+
|
|
61
|
+
### `reload_game`
|
|
62
|
+
|
|
63
|
+
Hot-reload the running game preview. If the game is not running yet, it starts automatically.
|
|
64
|
+
|
|
65
|
+
| Parameter | Type | Required | Description |
|
|
66
|
+
|---|---|---|---|
|
|
67
|
+
| `workspacePath` | string | Only if game not running | Absolute path to the Mini Game directory |
|
|
68
|
+
|
|
69
|
+
**Returns:** Confirmation with the preview URL.
|
|
70
|
+
|
|
71
|
+
### `get_logs`
|
|
72
|
+
|
|
73
|
+
Retrieve console log entries (log / warn / error) from the running game.
|
|
74
|
+
|
|
75
|
+
| Parameter | Type | Required | Description |
|
|
76
|
+
|---|---|---|---|
|
|
77
|
+
| `filter` | string | ❌ | JavaScript regex pattern to filter log messages (case-insensitive) |
|
|
78
|
+
|
|
79
|
+
**Returns:** Formatted log entries with timestamps and log levels.
|
|
80
|
+
|
|
81
|
+
### `real_device_preview`
|
|
82
|
+
|
|
83
|
+
Build and upload the game to WeChat servers for real device testing. Generates a QR code that can be scanned with WeChat.
|
|
84
|
+
|
|
85
|
+
| Parameter | Type | Required | Description |
|
|
86
|
+
|---|---|---|---|
|
|
87
|
+
| `workspacePath` | string | ✅ | Absolute path to the Mini Game directory |
|
|
88
|
+
|
|
89
|
+
**Requires:** AppID and upload private key (see [Configuration](#configuration)).
|
|
90
|
+
|
|
91
|
+
**Returns:** QR code displayed in the browser preview page.
|
|
92
|
+
|
|
93
|
+
### `publish`
|
|
94
|
+
|
|
95
|
+
Upload the game to the WeChat platform as a development version.
|
|
96
|
+
|
|
97
|
+
| Parameter | Type | Required | Description |
|
|
98
|
+
|---|---|---|---|
|
|
99
|
+
| `workspacePath` | string | ✅ | Absolute path to the Mini Game directory |
|
|
100
|
+
| `version` | string | ✅ | Version number (semver, e.g. `"1.0.0"`) |
|
|
101
|
+
| `desc` | string | ❌ | Optional release notes |
|
|
102
|
+
|
|
103
|
+
**Returns:** Upload confirmation with version and AppID info.
|
|
104
|
+
|
|
105
|
+
> **Note:** This uploads as a development version. To promote to experience/production, use the [WeChat MP Admin Console](https://mp.weixin.qq.com/).
|
|
106
|
+
|
|
107
|
+
## Configuration
|
|
108
|
+
|
|
109
|
+
For real-device preview and publish, you need to provide:
|
|
110
|
+
|
|
111
|
+
1. **AppID** — Your WeChat Mini Game AppID
|
|
112
|
+
2. **Upload Private Key** — The private key file for CI uploads (download from [WeChat MP Admin Console](https://mp.weixin.qq.com/) → Development → Development Settings → Mini Program Code Upload Key)
|
|
113
|
+
|
|
114
|
+
### Option 1: Browser UI
|
|
115
|
+
|
|
116
|
+
1. Start a preview with `run_game`
|
|
117
|
+
2. Click the ⚙️ settings button in the browser preview page
|
|
118
|
+
3. Fill in your AppID and upload the private key file
|
|
119
|
+
|
|
120
|
+
### Option 2: Environment Variables
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
export WECHAT_APPID="your_appid_here"
|
|
124
|
+
export WECHAT_PRIVATE_KEY_PATH="/path/to/private.key"
|
|
125
|
+
# Or provide the key content directly:
|
|
126
|
+
export WECHAT_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n..."
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### IP Whitelist
|
|
130
|
+
|
|
131
|
+
WeChat requires your server's public IP to be whitelisted for CI uploads. Add your IP in [WeChat MP Admin Console](https://mp.weixin.qq.com/) → Development → Development Settings → IP Whitelist.
|
|
132
|
+
|
|
133
|
+
> **Tip:** The preview page displays your current public IP in the top-right corner for easy copying.
|
|
134
|
+
|
|
135
|
+
## How It Works
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
AI Assistant ←→ MCP Protocol (stdio) ←→ This Server ←→ Local Dev Server + miniprogram-ci
|
|
139
|
+
↓
|
|
140
|
+
Browser Preview
|
|
141
|
+
Real Device QR
|
|
142
|
+
WeChat Upload
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
1. The MCP server starts a local Express dev server for game preview
|
|
146
|
+
2. Game source files are compiled (ES modules → WeChat-compatible JS) and served in browser
|
|
147
|
+
3. File changes are watched via chokidar for hot-reload
|
|
148
|
+
4. Real-device preview and publish use [miniprogram-ci](https://www.npmjs.com/package/miniprogram-ci) for WeChat platform integration
|
|
149
|
+
|
|
150
|
+
## Requirements
|
|
151
|
+
|
|
152
|
+
- **Node.js** >= 16
|
|
153
|
+
- A WeChat Mini Game project with `game.js` entry file
|
|
154
|
+
- For real-device / publish: WeChat AppID + upload private key
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
MIT
|