@creatoria/miniapp-mcp 0.1.1 → 0.1.2
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 +190 -353
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,57 +1,56 @@
|
|
|
1
|
-
#
|
|
1
|
+
# WeChat Mini Program MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Model Context Protocol (MCP) server for WeChat Mini Program automation using the official `miniprogram-automator` SDK.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@creatoria/miniapp-mcp)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
---
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
## Features
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
- 🤖 **LLM-Friendly**: 65 AI-optimized tools for natural language automation
|
|
13
|
+
- 🎯 **Complete Coverage**: Automator, MiniProgram, Page, Element, Assert, Snapshot, Record, Network tools
|
|
14
|
+
- 🔧 **Zero Config**: Auto-detects project path from `project.config.json` or `app.json`
|
|
15
|
+
- 📦 **npx Ready**: No installation needed, just `npx -y @creatoria/miniapp-mcp`
|
|
16
|
+
- 🧪 **Test Automation**: Built-in assertion and recording capabilities
|
|
17
|
+
- 🎨 **TypeScript**: Full type definitions with 545 passing tests
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
### Installation
|
|
14
22
|
|
|
23
|
+
Use with npx (recommended):
|
|
15
24
|
```bash
|
|
16
|
-
# Using npx (recommended - no installation needed)
|
|
17
25
|
npx -y @creatoria/miniapp-mcp
|
|
26
|
+
```
|
|
18
27
|
|
|
19
|
-
|
|
28
|
+
Or install globally:
|
|
29
|
+
```bash
|
|
20
30
|
npm install -g @creatoria/miniapp-mcp
|
|
21
|
-
|
|
22
|
-
# Or install locally
|
|
23
|
-
npm install @creatoria/miniapp-mcp
|
|
24
31
|
```
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
## ✨ Core Features
|
|
29
|
-
|
|
30
|
-
- 🎯 **65 AI-Friendly Tools**: Complete coverage across 8 categories (Automator, MiniProgram, Page, Element, Assert, Snapshot, Record, Network)
|
|
31
|
-
- 🤖 **Natural Language Testing**: Describe tests in plain English, let AI write automation code
|
|
32
|
-
- 🔧 **MCP Native**: Seamlessly integrates with Claude Desktop, Cline, and any MCP client
|
|
33
|
-
- 🧪 **Test Automation**: 9 assertion tools + 6 recording tools for robust test workflows
|
|
34
|
-
- 📸 **Debug Snapshots**: Capture page/app/element state for troubleshooting
|
|
35
|
-
- 🎨 **TypeScript First**: Full type definitions, 545 tests, 100% pass rate
|
|
36
|
-
- 🔄 **Session Isolation**: Multi-session support with automatic 30-min cleanup
|
|
37
|
-
- ⚙️ **Flexible Config**: Environment variables, config files, or CLI arguments
|
|
33
|
+
### Configuration
|
|
38
34
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
## 📋 前置要求
|
|
42
|
-
|
|
43
|
-
- **Node.js**: >= 18.0.0
|
|
44
|
-
- **微信开发者工具**: 已安装并启用 CLI([下载地址](https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html))
|
|
45
|
-
- **小程序项目**: 用于测试的微信小程序项目目录
|
|
46
|
-
- **pnpm**: 推荐使用 pnpm 作为包管理器(`npm install -g pnpm`)
|
|
35
|
+
Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json`):
|
|
47
36
|
|
|
48
|
-
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"mcpServers": {
|
|
40
|
+
"miniprogram": {
|
|
41
|
+
"command": "npx",
|
|
42
|
+
"args": ["-y", "@creatoria/miniapp-mcp"]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
49
47
|
|
|
50
|
-
|
|
48
|
+
**That's it!** The server will automatically detect your mini program project.
|
|
51
49
|
|
|
52
|
-
|
|
50
|
+
<details>
|
|
51
|
+
<summary>Advanced Configuration</summary>
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
#### Custom Project Path
|
|
55
54
|
|
|
56
55
|
```json
|
|
57
56
|
{
|
|
@@ -62,32 +61,27 @@ Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_
|
|
|
62
61
|
"-y",
|
|
63
62
|
"@creatoria/miniapp-mcp",
|
|
64
63
|
"--project-path",
|
|
65
|
-
"/path/to/your/miniprogram"
|
|
66
|
-
|
|
67
|
-
"9420"
|
|
68
|
-
],
|
|
69
|
-
"env": {}
|
|
64
|
+
"/path/to/your/miniprogram"
|
|
65
|
+
]
|
|
70
66
|
}
|
|
71
67
|
}
|
|
72
68
|
}
|
|
73
69
|
```
|
|
74
70
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
### 2. Alternative: Using Config File
|
|
71
|
+
#### Using Config File
|
|
78
72
|
|
|
79
|
-
Create
|
|
73
|
+
Create `.mcp.json` in your project root:
|
|
80
74
|
|
|
81
75
|
```json
|
|
82
76
|
{
|
|
83
|
-
"projectPath": "/path/to/
|
|
77
|
+
"projectPath": "/path/to/miniprogram",
|
|
84
78
|
"cliPath": "/Applications/wechatwebdevtools.app/Contents/MacOS/cli",
|
|
85
79
|
"port": 9420,
|
|
86
|
-
"capabilities": ["core", "assert", "snapshot"]
|
|
80
|
+
"capabilities": ["core", "assert", "snapshot", "record", "network"]
|
|
87
81
|
}
|
|
88
82
|
```
|
|
89
83
|
|
|
90
|
-
Then use
|
|
84
|
+
Then use:
|
|
91
85
|
|
|
92
86
|
```json
|
|
93
87
|
{
|
|
@@ -100,370 +94,213 @@ Then use simplified config:
|
|
|
100
94
|
}
|
|
101
95
|
```
|
|
102
96
|
|
|
103
|
-
|
|
97
|
+
#### Environment Variables
|
|
104
98
|
|
|
105
|
-
|
|
99
|
+
```bash
|
|
100
|
+
export MCP_PROJECT_PATH=/path/to/miniprogram
|
|
101
|
+
export MCP_PORT=9420
|
|
102
|
+
export MCP_CAPABILITIES=core,assert,snapshot
|
|
103
|
+
```
|
|
106
104
|
|
|
107
|
-
|
|
105
|
+
</details>
|
|
108
106
|
|
|
109
|
-
|
|
110
|
-
You: Launch my mini program and navigate to the product list page
|
|
107
|
+
## How It Works
|
|
111
108
|
|
|
112
|
-
|
|
113
|
-
✅ Mini program launched
|
|
114
|
-
✅ Navigated to pages/product/list
|
|
109
|
+
The server wraps WeChat's official `miniprogram-automator` SDK, exposing it through the Model Context Protocol. This allows AI assistants like Claude to:
|
|
115
110
|
|
|
116
|
-
|
|
111
|
+
1. **Connect** to WeChat DevTools automation interface
|
|
112
|
+
2. **Control** mini program UI through natural language
|
|
113
|
+
3. **Verify** behavior with built-in assertions
|
|
114
|
+
4. **Debug** with snapshots and recordings
|
|
117
115
|
|
|
118
|
-
|
|
119
|
-
✅ Found element with text: "iPhone 15 Pro"
|
|
120
|
-
✅ Assertion passed: text contains "iPhone"
|
|
121
|
-
```
|
|
116
|
+
### Auto-Detection
|
|
122
117
|
|
|
123
|
-
|
|
118
|
+
The server automatically searches for mini program projects:
|
|
124
119
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
// Launch and navigate to a page
|
|
128
|
-
await automator.launch({ projectPath: "/path/to/project" })
|
|
129
|
-
await miniprogram.navigate({ url: "/pages/home/home" })
|
|
130
|
-
```
|
|
120
|
+
- Current directory (checks for `project.config.json` or `app.json`)
|
|
121
|
+
- Common subdirectories: `dist/`, `build/`, `miniprogram/`, `src/`
|
|
131
122
|
|
|
132
|
-
|
|
133
|
-
```javascript
|
|
134
|
-
// Find element, tap it, and input text
|
|
135
|
-
const btn = await page.query({ selector: ".search-btn" })
|
|
136
|
-
await element.tap({ refId: btn.refId })
|
|
137
|
-
await element.input({ selector: ".search-input", value: "iPhone" })
|
|
138
|
-
```
|
|
123
|
+
## Available Tools
|
|
139
124
|
|
|
140
|
-
|
|
141
|
-
```javascript
|
|
142
|
-
// Verify element exists and has correct text
|
|
143
|
-
await assert.exists({ selector: ".product-title" })
|
|
144
|
-
await assert.text({ selector: ".product-title", expected: "iPhone 15" })
|
|
145
|
-
```
|
|
125
|
+
### Core Tools (65 total)
|
|
146
126
|
|
|
147
|
-
|
|
127
|
+
<details>
|
|
128
|
+
<summary><strong>Automator (4 tools)</strong> - Connection & Lifecycle</summary>
|
|
148
129
|
|
|
149
|
-
|
|
130
|
+
- `miniprogram_launch` - Launch WeChat Mini Program
|
|
131
|
+
- `miniprogram_connect` - Connect to running DevTools instance
|
|
132
|
+
- `miniprogram_disconnect` - Disconnect but keep IDE running
|
|
133
|
+
- `miniprogram_close` - Close session and cleanup resources
|
|
150
134
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
### Automator (4 tools) - Connection & Lifecycle
|
|
154
|
-
|
|
155
|
-
| Tool | Description |
|
|
156
|
-
|------|-------------|
|
|
157
|
-
| `miniprogram.launch` | Launch WeChat Mini Program with automator |
|
|
158
|
-
| `miniprogram.connect` | Connect to an already running WeChat DevTools instance |
|
|
159
|
-
| `miniprogram.disconnect` | Disconnect from miniprogram but keep IDE running |
|
|
160
|
-
| `miniprogram.close` | Close current mini program session and cleanup all resources |
|
|
161
|
-
|
|
162
|
-
### MiniProgram (6 tools) - App-Level Operations
|
|
163
|
-
|
|
164
|
-
| Tool | Description |
|
|
165
|
-
|------|-------------|
|
|
166
|
-
| `miniprogram.navigate` | Navigate to a page using various navigation methods (navigateTo, redirectTo, reLaunch, switchTab, navigateBack) |
|
|
167
|
-
| `miniprogram.call.wx` | Call a WeChat API method (wx.*) in the mini program |
|
|
168
|
-
| `miniprogram.evaluate` | Evaluate JavaScript code in the mini program context |
|
|
169
|
-
| `miniprogram.screenshot` | Take a screenshot of the mini program |
|
|
170
|
-
| `miniprogram.get.page.stack` | Get the current page stack |
|
|
171
|
-
| `miniprogram.get.system.info` | Get system information |
|
|
172
|
-
|
|
173
|
-
### Page (8 tools) - Page-Level Operations
|
|
174
|
-
|
|
175
|
-
| Tool | Description |
|
|
176
|
-
|------|-------------|
|
|
177
|
-
| `page.query` | Query a single element on the page |
|
|
178
|
-
| `page.query.all` | Query all matching elements on the page |
|
|
179
|
-
| `page.wait.for` | Wait for a condition to be met (selector or timeout) |
|
|
180
|
-
| `page.get.data` | Get page data (optionally at a specific path) |
|
|
181
|
-
| `page.set.data` | Set page data |
|
|
182
|
-
| `page.call.method` | Call a method on the page |
|
|
183
|
-
| `page.get.size` | Get page size (width, height, scrollHeight) |
|
|
184
|
-
| `page.get.scroll.top` | Get page scroll position |
|
|
185
|
-
|
|
186
|
-
### Element (23 tools) - Element-Level Operations
|
|
187
|
-
|
|
188
|
-
| Tool | Description |
|
|
189
|
-
|------|-------------|
|
|
190
|
-
| `element.tap` | Tap (click) an element |
|
|
191
|
-
| `element.longpress` | Long press an element |
|
|
192
|
-
| `element.input` | Input text into an element (input/textarea only) |
|
|
193
|
-
| `element.get.text` | Get element text content |
|
|
194
|
-
| `element.get.attribute` | Get element attribute (特性) |
|
|
195
|
-
| `element.get.property` | Get element property (属性) |
|
|
196
|
-
| `element.get.value` | Get element value |
|
|
197
|
-
| `element.get.size` | Get element size (width, height) |
|
|
198
|
-
| `element.get.offset` | Get element offset (position) |
|
|
199
|
-
| `element.trigger` | Trigger an event on the element |
|
|
200
|
-
| `element.get.style` | Get element style value |
|
|
201
|
-
| `element.touchstart` | Touch start on element |
|
|
202
|
-
| `element.touchmove` | Touch move on element |
|
|
203
|
-
| `element.touchend` | Touch end on element |
|
|
204
|
-
| `element.scroll.to` | Scroll to position (ScrollView only) |
|
|
205
|
-
| `element.scroll.width` | Get scroll width (ScrollView only) |
|
|
206
|
-
| `element.scroll.height` | Get scroll height (ScrollView only) |
|
|
207
|
-
| `element.swipe.to` | Swipe to index (Swiper only) |
|
|
208
|
-
| `element.move.to` | Move to position (MovableView only) |
|
|
209
|
-
| `element.slide.to` | Slide to value (Slider only) |
|
|
210
|
-
| `element.call.context.method` | Call context method (ContextElement only) |
|
|
211
|
-
| `element.set.data` | Set data on custom element (CustomElement only) |
|
|
212
|
-
| `element.call.method` | Call method on custom element (CustomElement only) |
|
|
213
|
-
|
|
214
|
-
### Assert (9 tools) - Testing & Verification
|
|
215
|
-
|
|
216
|
-
| Tool | Description |
|
|
217
|
-
|------|-------------|
|
|
218
|
-
| `assert.exists` | Assert that an element exists on the page |
|
|
219
|
-
| `assert.not.exists` | Assert that an element does not exist on the page |
|
|
220
|
-
| `assert.text` | Assert element text equals expected value |
|
|
221
|
-
| `assert.text.contains` | Assert element text contains expected substring |
|
|
222
|
-
| `assert.value` | Assert element value equals expected value |
|
|
223
|
-
| `assert.attribute` | Assert element attribute equals expected value |
|
|
224
|
-
| `assert.property` | Assert element property equals expected value |
|
|
225
|
-
| `assert.data` | Assert page data equals expected value |
|
|
226
|
-
| `assert.visible` | Assert element is visible (has non-zero size) |
|
|
227
|
-
|
|
228
|
-
### Snapshot (3 tools) - State Capture & Debugging
|
|
229
|
-
|
|
230
|
-
| Tool | Description |
|
|
231
|
-
|------|-------------|
|
|
232
|
-
| `snapshot.page` | Capture complete page snapshot (data + screenshot) |
|
|
233
|
-
| `snapshot.full` | Capture complete application snapshot (system info + page stack + current page) |
|
|
234
|
-
| `snapshot.element` | Capture element snapshot (properties + optional screenshot) |
|
|
235
|
-
|
|
236
|
-
### Record (6 tools) - Action Recording & Replay
|
|
237
|
-
|
|
238
|
-
| Tool | Description |
|
|
239
|
-
|------|-------------|
|
|
240
|
-
| `record.start` | Start recording user actions for later replay |
|
|
241
|
-
| `record.stop` | Stop the current recording and save the sequence |
|
|
242
|
-
| `record.list` | List all saved action sequences |
|
|
243
|
-
| `record.get` | Get details of a specific sequence |
|
|
244
|
-
| `record.delete` | Delete a saved sequence |
|
|
245
|
-
| `record.replay` | Replay a recorded action sequence |
|
|
246
|
-
|
|
247
|
-
### Network (6 tools) - Network Mock & Testing
|
|
248
|
-
|
|
249
|
-
| Tool | Description |
|
|
250
|
-
|------|-------------|
|
|
251
|
-
| `network.mock.wx.method` | Mock a WeChat API method (wx.*) for testing |
|
|
252
|
-
| `network.restore.wx.method` | Restore a previously mocked WeChat API method |
|
|
253
|
-
| `network.mock.request` | Mock wx.request to return specific data (convenience wrapper) |
|
|
254
|
-
| `network.mock.request.failure` | Mock wx.request to fail with specific error |
|
|
255
|
-
| `network.restore.request` | Restore wx.request to original behavior |
|
|
256
|
-
| `network.restore.all.mocks` | Restore all mocked WeChat API methods at once |
|
|
135
|
+
</details>
|
|
257
136
|
|
|
258
|
-
|
|
137
|
+
<details>
|
|
138
|
+
<summary><strong>MiniProgram (6 tools)</strong> - App-Level Operations</summary>
|
|
259
139
|
|
|
260
|
-
|
|
261
|
-
-
|
|
262
|
-
-
|
|
263
|
-
-
|
|
140
|
+
- `miniprogram_navigate` - Navigate using navigateTo/redirectTo/reLaunch/switchTab/navigateBack
|
|
141
|
+
- `miniprogram_call_wx` - Call WeChat API methods (wx.*)
|
|
142
|
+
- `miniprogram_evaluate` - Execute JavaScript in mini program context
|
|
143
|
+
- `miniprogram_screenshot` - Take screenshots
|
|
144
|
+
- `miniprogram_get_page_stack` - Get current page stack
|
|
145
|
+
- `miniprogram_get_system_info` - Get system information
|
|
264
146
|
|
|
265
|
-
|
|
147
|
+
</details>
|
|
266
148
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
├── src/ # 源代码
|
|
270
|
-
│ ├── server.ts # MCP 服务器入口
|
|
271
|
-
│ ├── cli.ts # CLI 入口
|
|
272
|
-
│ ├── types.ts # TypeScript 类型定义
|
|
273
|
-
│ ├── config/ # 配置管理
|
|
274
|
-
│ │ └── index.ts # 配置加载和验证
|
|
275
|
-
│ ├── core/ # 核心模块
|
|
276
|
-
│ │ ├── session.ts # 会话管理器
|
|
277
|
-
│ │ ├── output.ts # 输出管理器(截图、快照)
|
|
278
|
-
│ │ └── element-ref.ts # 元素引用解析器
|
|
279
|
-
│ └── tools/ # MCP 工具实现
|
|
280
|
-
│ ├── index.ts # 工具注册器(65 个工具)
|
|
281
|
-
│ ├── automator.ts # Automator 工具(4 个)
|
|
282
|
-
│ ├── miniprogram.ts # MiniProgram 工具(6 个)
|
|
283
|
-
│ ├── page.ts # Page 工具(8 个)
|
|
284
|
-
│ ├── element.ts # Element 工具(23 个)
|
|
285
|
-
│ ├── assert.ts # Assert 工具(9 个)
|
|
286
|
-
│ ├── snapshot.ts # Snapshot 工具(3 个)
|
|
287
|
-
│ └── record.ts # Record 工具(6 个)
|
|
288
|
-
│
|
|
289
|
-
├── tests/ # 测试文件
|
|
290
|
-
│ ├── unit/ # 单元测试(545 个测试)
|
|
291
|
-
│ │ ├── session.test.ts
|
|
292
|
-
│ │ ├── output.test.ts
|
|
293
|
-
│ │ ├── element-ref.test.ts
|
|
294
|
-
│ │ ├── automator.test.ts
|
|
295
|
-
│ │ ├── miniprogram.test.ts
|
|
296
|
-
│ │ ├── page.test.ts
|
|
297
|
-
│ │ ├── element.test.ts
|
|
298
|
-
│ │ ├── assert.test.ts
|
|
299
|
-
│ │ ├── snapshot.test.ts
|
|
300
|
-
│ │ ├── record.test.ts
|
|
301
|
-
│ │ └── tool-registration.test.ts
|
|
302
|
-
│ └── integration/ # 集成测试(需要测试小程序项目)
|
|
303
|
-
│
|
|
304
|
-
├── docs/ # 文档
|
|
305
|
-
│ ├── setup-guide.md # 配置指南
|
|
306
|
-
│ ├── architecture.md # 系统架构
|
|
307
|
-
│ ├── troubleshooting.md # 故障排除
|
|
308
|
-
│ ├── charter.*.yaml # 任务对齐文档
|
|
309
|
-
│ ├── tasks.*.atomize.md # 任务分解文档
|
|
310
|
-
│ └── api/ # API 参考文档
|
|
311
|
-
│ ├── README.md # API 文档索引
|
|
312
|
-
│ ├── automator.md
|
|
313
|
-
│ ├── miniprogram.md
|
|
314
|
-
│ ├── page.md
|
|
315
|
-
│ ├── element.md
|
|
316
|
-
│ ├── assert.md
|
|
317
|
-
│ └── snapshot.md
|
|
318
|
-
│
|
|
319
|
-
├── examples/ # 使用示例
|
|
320
|
-
│ ├── README.md # 示例索引
|
|
321
|
-
│ ├── 01-basic-navigation.md
|
|
322
|
-
│ ├── 02-form-interaction.md
|
|
323
|
-
│ ├── 03-assertion-testing.md
|
|
324
|
-
│ ├── 04-snapshot-debugging.md
|
|
325
|
-
│ └── 05-advanced-automation.md
|
|
326
|
-
│
|
|
327
|
-
├── scripts/ # 脚本
|
|
328
|
-
│ ├── launch-wx-devtools.sh # 启动微信开发者工具
|
|
329
|
-
│ └── setup-devtools-port.sh # 配置自动化端口
|
|
330
|
-
│
|
|
331
|
-
├── .llm/ # LLM 工作流程文档(6A 工作法)
|
|
332
|
-
│ ├── state.json # 项目状态(SSOT)
|
|
333
|
-
│ ├── prompts/ # 工作流程规范
|
|
334
|
-
│ ├── session_log/ # 会话日志
|
|
335
|
-
│ └── qa/ # 验收文档
|
|
336
|
-
│
|
|
337
|
-
├── dist/ # 构建输出
|
|
338
|
-
├── package.json # 项目配置
|
|
339
|
-
├── tsconfig.json # TypeScript 配置
|
|
340
|
-
├── jest.config.js # Jest 测试配置
|
|
341
|
-
└── README.md # 本文件
|
|
342
|
-
```
|
|
149
|
+
<details>
|
|
150
|
+
<summary><strong>Page (8 tools)</strong> - Page-Level Operations</summary>
|
|
343
151
|
|
|
344
|
-
|
|
152
|
+
- `page_query` - Query single element
|
|
153
|
+
- `page_query_all` - Query all matching elements
|
|
154
|
+
- `page_wait_for` - Wait for condition or selector
|
|
155
|
+
- `page_get_data` - Get page data
|
|
156
|
+
- `page_set_data` - Set page data
|
|
157
|
+
- `page_call_method` - Call page methods
|
|
158
|
+
- `page_get_size` - Get page dimensions
|
|
159
|
+
- `page_get_scroll_top` - Get scroll position
|
|
345
160
|
|
|
346
|
-
|
|
161
|
+
</details>
|
|
347
162
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
- [**API Reference**](./docs/api/) - Complete API docs for all 65 tools
|
|
351
|
-
- [**Usage Examples**](./examples/) - Real-world automation scenarios
|
|
352
|
-
- [**Troubleshooting**](./docs/troubleshooting.md) - Common issues and solutions
|
|
163
|
+
<details>
|
|
164
|
+
<summary><strong>Element (23 tools)</strong> - Element-Level Operations</summary>
|
|
353
165
|
|
|
354
|
-
|
|
355
|
-
-
|
|
166
|
+
- `element_tap` - Tap/click element
|
|
167
|
+
- `element_longpress` - Long press element
|
|
168
|
+
- `element_input` - Input text (input/textarea)
|
|
169
|
+
- `element_get_text` - Get text content
|
|
170
|
+
- `element_get_attribute` - Get element attribute
|
|
171
|
+
- `element_get_property` - Get element property
|
|
172
|
+
- `element_get_value` - Get element value
|
|
173
|
+
- `element_trigger` - Trigger custom events
|
|
174
|
+
- Component-specific: ScrollView, Swiper, MovableView, Slider methods
|
|
356
175
|
|
|
357
|
-
|
|
358
|
-
- [**Architecture**](./docs/architecture.md) - System design and technical decisions
|
|
359
|
-
- [**Contributing Guide**](./CONTRIBUTING.md) - How to contribute to the project
|
|
360
|
-
- [**Task Breakdown**](./docs/) - Development tasks and progress tracking (35 charter + task docs)
|
|
176
|
+
</details>
|
|
361
177
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
- [`.llm/prompts/`](./.llm/prompts/) - 6A workflow specifications
|
|
365
|
-
- [`.llm/session_log/`](./.llm/session_log/) - Development session logs
|
|
366
|
-
- [`.llm/qa/`](./.llm/qa/) - Acceptance documentation
|
|
178
|
+
<details>
|
|
179
|
+
<summary><strong>Assert (9 tools)</strong> - Testing & Verification</summary>
|
|
367
180
|
|
|
368
|
-
|
|
181
|
+
- `assert_exists` - Assert element exists
|
|
182
|
+
- `assert_not_exists` - Assert element doesn't exist
|
|
183
|
+
- `assert_text` - Assert text equals expected
|
|
184
|
+
- `assert_text_contains` - Assert text contains substring
|
|
185
|
+
- `assert_value` - Assert value equals expected
|
|
186
|
+
- `assert_attribute` - Assert attribute equals expected
|
|
187
|
+
- `assert_property` - Assert property equals expected
|
|
188
|
+
- `assert_data` - Assert page data equals expected
|
|
189
|
+
- `assert_visible` - Assert element is visible
|
|
369
190
|
|
|
370
|
-
|
|
191
|
+
</details>
|
|
371
192
|
|
|
372
|
-
|
|
193
|
+
<details>
|
|
194
|
+
<summary><strong>Snapshot (3 tools)</strong> - State Capture</summary>
|
|
373
195
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
196
|
+
- `snapshot_page` - Capture page snapshot (data + screenshot)
|
|
197
|
+
- `snapshot_full` - Capture full app snapshot (system + page stack)
|
|
198
|
+
- `snapshot_element` - Capture element snapshot
|
|
377
199
|
|
|
378
|
-
|
|
379
|
-
pnpm dev
|
|
200
|
+
</details>
|
|
380
201
|
|
|
381
|
-
|
|
382
|
-
|
|
202
|
+
<details>
|
|
203
|
+
<summary><strong>Record (6 tools)</strong> - Action Recording</summary>
|
|
383
204
|
|
|
384
|
-
|
|
385
|
-
|
|
205
|
+
- `record_start` - Start recording actions
|
|
206
|
+
- `record_stop` - Stop and save recording
|
|
207
|
+
- `record_list` - List saved recordings
|
|
208
|
+
- `record_get` - Get recording details
|
|
209
|
+
- `record_delete` - Delete recording
|
|
210
|
+
- `record_replay` - Replay recorded actions
|
|
386
211
|
|
|
387
|
-
|
|
388
|
-
pnpm typecheck
|
|
212
|
+
</details>
|
|
389
213
|
|
|
390
|
-
|
|
391
|
-
|
|
214
|
+
<details>
|
|
215
|
+
<summary><strong>Network (6 tools)</strong> - Mock & Testing</summary>
|
|
392
216
|
|
|
393
|
-
|
|
394
|
-
|
|
217
|
+
- `network_mock_wx_method` - Mock WeChat API methods
|
|
218
|
+
- `network_restore_wx_method` - Restore mocked methods
|
|
219
|
+
- `network_mock_request` - Mock wx.request responses
|
|
220
|
+
- `network_mock_request_failure` - Mock request failures
|
|
221
|
+
- `network_restore_request` - Restore wx.request
|
|
222
|
+
- `network_restore_all_mocks` - Restore all mocks
|
|
395
223
|
|
|
396
|
-
|
|
397
|
-
pnpm format:check
|
|
398
|
-
```
|
|
224
|
+
</details>
|
|
399
225
|
|
|
400
|
-
|
|
226
|
+
## Requirements
|
|
401
227
|
|
|
402
|
-
|
|
403
|
-
|
|
228
|
+
- **Node.js**: >= 18.0.0
|
|
229
|
+
- **WeChat DevTools**: [Download](https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html)
|
|
230
|
+
- Enable CLI/HTTP calls in Settings → Security
|
|
231
|
+
- Default automation port: 9420
|
|
232
|
+
- **Mini Program Project**: Any WeChat mini program with `project.config.json` or `app.json`
|
|
404
233
|
|
|
405
|
-
|
|
406
|
-
Tests: 545 passed, 545 total
|
|
407
|
-
Snapshots: 0 total
|
|
408
|
-
Time: ~6s
|
|
234
|
+
## Examples
|
|
409
235
|
|
|
410
|
-
|
|
411
|
-
```
|
|
236
|
+
### Natural Language Testing
|
|
412
237
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
- Tool implementations: Automator, MiniProgram, Page, Element
|
|
416
|
-
- Capabilities: Assert, Snapshot, Record, Network
|
|
417
|
-
- Infrastructure: Config, Tool registration, Helpers
|
|
418
|
-
- Quality: Smoke tests, Release scripts
|
|
238
|
+
```
|
|
239
|
+
You: "Launch the mini program and navigate to the product list page"
|
|
419
240
|
|
|
420
|
-
|
|
241
|
+
Claude: [Calls miniprogram_connect + miniprogram_navigate]
|
|
242
|
+
✅ Connected to DevTools
|
|
243
|
+
✅ Navigated to pages/product/list
|
|
421
244
|
|
|
422
|
-
|
|
245
|
+
You: "Find the first product title and verify it contains 'iPhone'"
|
|
423
246
|
|
|
424
|
-
|
|
247
|
+
Claude: [Calls page_query + element_get_text + assert_text_contains]
|
|
248
|
+
✅ Found element with text: "iPhone 15 Pro"
|
|
249
|
+
✅ Assertion passed: text contains "iPhone"
|
|
250
|
+
```
|
|
425
251
|
|
|
426
|
-
|
|
252
|
+
### Programmatic Usage
|
|
427
253
|
|
|
428
|
-
|
|
254
|
+
See [examples/](./examples/) directory for complete workflows:
|
|
429
255
|
|
|
430
|
-
-
|
|
431
|
-
-
|
|
432
|
-
-
|
|
433
|
-
-
|
|
256
|
+
- [Basic Navigation](./examples/01-basic-navigation.md)
|
|
257
|
+
- [Element Interaction](./examples/02-element-interaction.md)
|
|
258
|
+
- [Assertion Testing](./examples/03-assertion-testing.md)
|
|
259
|
+
- [Snapshot Debugging](./examples/04-snapshot-debugging.md)
|
|
260
|
+
- [Action Recording](./examples/05-record-replay.md)
|
|
434
261
|
|
|
435
|
-
|
|
262
|
+
## Documentation
|
|
436
263
|
|
|
437
|
-
|
|
264
|
+
- [API Reference](./docs/api/) - Complete API docs for all 65 tools
|
|
265
|
+
- [Setup Guide](./docs/setup-guide.md) - Detailed setup instructions
|
|
266
|
+
- [Troubleshooting](./docs/troubleshooting.md) - Common issues and solutions
|
|
267
|
+
- [Architecture](./docs/architecture.md) - System design and technical decisions
|
|
438
268
|
|
|
439
|
-
|
|
269
|
+
## Development
|
|
440
270
|
|
|
441
|
-
|
|
271
|
+
```bash
|
|
272
|
+
# Install dependencies
|
|
273
|
+
pnpm install
|
|
442
274
|
|
|
443
|
-
|
|
275
|
+
# Build
|
|
276
|
+
pnpm build
|
|
444
277
|
|
|
445
|
-
|
|
278
|
+
# Run tests
|
|
279
|
+
pnpm test
|
|
446
280
|
|
|
447
|
-
|
|
281
|
+
# Type check
|
|
282
|
+
pnpm typecheck
|
|
448
283
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
- [Claude Desktop](https://claude.ai/download)
|
|
284
|
+
# Lint
|
|
285
|
+
pnpm lint
|
|
286
|
+
```
|
|
453
287
|
|
|
454
|
-
|
|
288
|
+
## Contributing
|
|
455
289
|
|
|
456
|
-
|
|
290
|
+
Contributions welcome! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
|
|
457
291
|
|
|
458
|
-
|
|
459
|
-
- **Discussions**: [GitHub Discussions](https://github.com/your-org/creatoria-miniapp-mcp/discussions)
|
|
292
|
+
## License
|
|
460
293
|
|
|
461
|
-
|
|
294
|
+
MIT License - see [LICENSE](./LICENSE) file for details.
|
|
462
295
|
|
|
463
|
-
|
|
296
|
+
## Links
|
|
464
297
|
|
|
465
|
-
|
|
298
|
+
- [npm Package](https://www.npmjs.com/package/@creatoria/miniapp-mcp)
|
|
299
|
+
- [GitHub Repository](https://github.com/rn1024/creatoria-miniapp-mcp)
|
|
300
|
+
- [Model Context Protocol](https://modelcontextprotocol.io/)
|
|
301
|
+
- [WeChat Mini Program Automator](https://developers.weixin.qq.com/miniprogram/dev/devtools/auto/)
|
|
302
|
+
- [WeChat DevTools](https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html)
|
|
466
303
|
|
|
467
304
|
---
|
|
468
305
|
|
|
469
|
-
Made with ❤️
|
|
306
|
+
Made with ❤️ for the WeChat Mini Program developer community
|