@creatoria/miniapp-mcp 0.1.2 → 0.2.0

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.
Files changed (247) hide show
  1. package/README.md +14 -3
  2. package/dist/app/cli/index.d.ts +6 -0
  3. package/dist/app/cli/index.d.ts.map +1 -0
  4. package/dist/app/cli/index.js +6 -0
  5. package/dist/app/cli/index.js.map +1 -0
  6. package/dist/app/index.d.ts +6 -0
  7. package/dist/app/index.d.ts.map +1 -0
  8. package/dist/app/index.js +6 -0
  9. package/dist/app/index.js.map +1 -0
  10. package/dist/app/server/index.d.ts +7 -0
  11. package/dist/app/server/index.d.ts.map +1 -0
  12. package/dist/app/server/index.js +6 -0
  13. package/dist/app/server/index.js.map +1 -0
  14. package/dist/capabilities/assert/index.d.ts +5 -0
  15. package/dist/capabilities/assert/index.d.ts.map +1 -0
  16. package/dist/capabilities/assert/index.js +5 -0
  17. package/dist/capabilities/assert/index.js.map +1 -0
  18. package/dist/capabilities/automator/index.d.ts +6 -0
  19. package/dist/capabilities/automator/index.d.ts.map +1 -0
  20. package/dist/capabilities/automator/index.js +6 -0
  21. package/dist/capabilities/automator/index.js.map +1 -0
  22. package/dist/capabilities/automator/schemas/close.d.ts +5 -0
  23. package/dist/capabilities/automator/schemas/close.d.ts.map +1 -0
  24. package/dist/capabilities/automator/schemas/close.js +11 -0
  25. package/dist/capabilities/automator/schemas/close.js.map +1 -0
  26. package/dist/capabilities/automator/schemas/connect.d.ts +11 -0
  27. package/dist/capabilities/automator/schemas/connect.d.ts.map +1 -0
  28. package/dist/capabilities/automator/schemas/connect.js +19 -0
  29. package/dist/capabilities/automator/schemas/connect.js.map +1 -0
  30. package/dist/capabilities/automator/schemas/disconnect.d.ts +5 -0
  31. package/dist/capabilities/automator/schemas/disconnect.d.ts.map +1 -0
  32. package/dist/capabilities/automator/schemas/disconnect.js +11 -0
  33. package/dist/capabilities/automator/schemas/disconnect.js.map +1 -0
  34. package/dist/capabilities/automator/schemas/index.d.ts +4 -0
  35. package/dist/capabilities/automator/schemas/index.d.ts.map +1 -0
  36. package/dist/capabilities/automator/schemas/index.js +12 -0
  37. package/dist/capabilities/automator/schemas/index.js.map +1 -0
  38. package/dist/capabilities/automator/schemas/launch.d.ts +17 -0
  39. package/dist/capabilities/automator/schemas/launch.d.ts.map +1 -0
  40. package/dist/capabilities/automator/schemas/launch.js +26 -0
  41. package/dist/capabilities/automator/schemas/launch.js.map +1 -0
  42. package/dist/capabilities/element/index.d.ts +5 -0
  43. package/dist/capabilities/element/index.d.ts.map +1 -0
  44. package/dist/capabilities/element/index.js +5 -0
  45. package/dist/capabilities/element/index.js.map +1 -0
  46. package/dist/capabilities/index.d.ts +15 -0
  47. package/dist/capabilities/index.d.ts.map +1 -0
  48. package/dist/capabilities/index.js +14 -0
  49. package/dist/capabilities/index.js.map +1 -0
  50. package/dist/capabilities/miniprogram/index.d.ts +5 -0
  51. package/dist/capabilities/miniprogram/index.d.ts.map +1 -0
  52. package/dist/capabilities/miniprogram/index.js +5 -0
  53. package/dist/capabilities/miniprogram/index.js.map +1 -0
  54. package/dist/capabilities/network/index.d.ts +5 -0
  55. package/dist/capabilities/network/index.d.ts.map +1 -0
  56. package/dist/capabilities/network/index.js +5 -0
  57. package/dist/capabilities/network/index.js.map +1 -0
  58. package/dist/capabilities/page/index.d.ts +5 -0
  59. package/dist/capabilities/page/index.d.ts.map +1 -0
  60. package/dist/capabilities/page/index.js +5 -0
  61. package/dist/capabilities/page/index.js.map +1 -0
  62. package/dist/capabilities/record/index.d.ts +5 -0
  63. package/dist/capabilities/record/index.d.ts.map +1 -0
  64. package/dist/capabilities/record/index.js +5 -0
  65. package/dist/capabilities/record/index.js.map +1 -0
  66. package/dist/capabilities/schema-registry.d.ts +4 -0
  67. package/dist/capabilities/schema-registry.d.ts.map +1 -0
  68. package/dist/capabilities/schema-registry.js +18 -0
  69. package/dist/capabilities/schema-registry.js.map +1 -0
  70. package/dist/capabilities/schema-types.d.ts +22 -0
  71. package/dist/capabilities/schema-types.d.ts.map +1 -0
  72. package/dist/capabilities/schema-types.js +2 -0
  73. package/dist/capabilities/schema-types.js.map +1 -0
  74. package/dist/capabilities/snapshot/index.d.ts +5 -0
  75. package/dist/capabilities/snapshot/index.d.ts.map +1 -0
  76. package/dist/capabilities/snapshot/index.js +5 -0
  77. package/dist/capabilities/snapshot/index.js.map +1 -0
  78. package/dist/config/loader.js +1 -1
  79. package/dist/config/loader.js.map +1 -1
  80. package/dist/core/element-ref.d.ts +1 -43
  81. package/dist/core/element-ref.d.ts.map +1 -1
  82. package/dist/core/element-ref.js +1 -212
  83. package/dist/core/element-ref.js.map +1 -1
  84. package/dist/core/logger.d.ts +1 -54
  85. package/dist/core/logger.d.ts.map +1 -1
  86. package/dist/core/logger.js +1 -377
  87. package/dist/core/logger.js.map +1 -1
  88. package/dist/core/output.d.ts +1 -20
  89. package/dist/core/output.d.ts.map +1 -1
  90. package/dist/core/output.js +1 -55
  91. package/dist/core/output.js.map +1 -1
  92. package/dist/core/report-generator.d.ts +1 -23
  93. package/dist/core/report-generator.d.ts.map +1 -1
  94. package/dist/core/report-generator.js +1 -211
  95. package/dist/core/report-generator.js.map +1 -1
  96. package/dist/core/session.d.ts +2 -82
  97. package/dist/core/session.d.ts.map +1 -1
  98. package/dist/core/session.js +2 -305
  99. package/dist/core/session.js.map +1 -1
  100. package/dist/core/timeout.d.ts +1 -48
  101. package/dist/core/timeout.d.ts.map +1 -1
  102. package/dist/core/timeout.js +1 -66
  103. package/dist/core/timeout.js.map +1 -1
  104. package/dist/core/tool-logger.d.ts +1 -82
  105. package/dist/core/tool-logger.d.ts.map +1 -1
  106. package/dist/core/tool-logger.js +1 -452
  107. package/dist/core/tool-logger.js.map +1 -1
  108. package/dist/core/validation.d.ts +1 -38
  109. package/dist/core/validation.d.ts.map +1 -1
  110. package/dist/core/validation.js +1 -92
  111. package/dist/core/validation.js.map +1 -1
  112. package/dist/runtime/element/element-ref.d.ts +44 -0
  113. package/dist/runtime/element/element-ref.d.ts.map +1 -0
  114. package/dist/runtime/element/element-ref.js +214 -0
  115. package/dist/runtime/element/element-ref.js.map +1 -0
  116. package/dist/runtime/element/index.d.ts +2 -0
  117. package/dist/runtime/element/index.d.ts.map +1 -0
  118. package/dist/runtime/element/index.js +2 -0
  119. package/dist/runtime/element/index.js.map +1 -0
  120. package/dist/runtime/index.d.ts +10 -0
  121. package/dist/runtime/index.d.ts.map +1 -0
  122. package/dist/runtime/index.js +10 -0
  123. package/dist/runtime/index.js.map +1 -0
  124. package/dist/runtime/logging/index.d.ts +3 -0
  125. package/dist/runtime/logging/index.d.ts.map +1 -0
  126. package/dist/runtime/logging/index.js +3 -0
  127. package/dist/runtime/logging/index.js.map +1 -0
  128. package/dist/runtime/logging/logger.d.ts +55 -0
  129. package/dist/runtime/logging/logger.d.ts.map +1 -0
  130. package/dist/runtime/logging/logger.js +379 -0
  131. package/dist/runtime/logging/logger.js.map +1 -0
  132. package/dist/runtime/logging/tool-logger.d.ts +83 -0
  133. package/dist/runtime/logging/tool-logger.d.ts.map +1 -0
  134. package/dist/runtime/logging/tool-logger.js +454 -0
  135. package/dist/runtime/logging/tool-logger.js.map +1 -0
  136. package/dist/runtime/outputs/index.d.ts +3 -0
  137. package/dist/runtime/outputs/index.d.ts.map +1 -0
  138. package/dist/runtime/outputs/index.js +3 -0
  139. package/dist/runtime/outputs/index.js.map +1 -0
  140. package/dist/runtime/outputs/output-manager.d.ts +12 -0
  141. package/dist/runtime/outputs/output-manager.d.ts.map +1 -0
  142. package/dist/runtime/outputs/output-manager.js +39 -0
  143. package/dist/runtime/outputs/output-manager.js.map +1 -0
  144. package/dist/runtime/outputs/report-generator.d.ts +5 -0
  145. package/dist/runtime/outputs/report-generator.d.ts.map +1 -0
  146. package/dist/runtime/outputs/report-generator.js +175 -0
  147. package/dist/runtime/outputs/report-generator.js.map +1 -0
  148. package/dist/runtime/session/index.d.ts +3 -0
  149. package/dist/runtime/session/index.d.ts.map +1 -0
  150. package/dist/runtime/session/index.js +3 -0
  151. package/dist/runtime/session/index.js.map +1 -0
  152. package/dist/runtime/session/store.d.ts +28 -0
  153. package/dist/runtime/session/store.d.ts.map +1 -0
  154. package/dist/runtime/session/store.js +154 -0
  155. package/dist/runtime/session/store.js.map +1 -0
  156. package/dist/runtime/session/utils/cleanup.d.ts +3 -0
  157. package/dist/runtime/session/utils/cleanup.d.ts.map +1 -0
  158. package/dist/runtime/session/utils/cleanup.js +78 -0
  159. package/dist/runtime/session/utils/cleanup.js.map +1 -0
  160. package/dist/runtime/timeout/index.d.ts +2 -0
  161. package/dist/runtime/timeout/index.d.ts.map +1 -0
  162. package/dist/runtime/timeout/index.js +2 -0
  163. package/dist/runtime/timeout/index.js.map +1 -0
  164. package/dist/runtime/timeout/timeout.d.ts +49 -0
  165. package/dist/runtime/timeout/timeout.d.ts.map +1 -0
  166. package/dist/runtime/timeout/timeout.js +67 -0
  167. package/dist/runtime/timeout/timeout.js.map +1 -0
  168. package/dist/runtime/validation/index.d.ts +2 -0
  169. package/dist/runtime/validation/index.d.ts.map +1 -0
  170. package/dist/runtime/validation/index.js +2 -0
  171. package/dist/runtime/validation/index.js.map +1 -0
  172. package/dist/runtime/validation/validation.d.ts +39 -0
  173. package/dist/runtime/validation/validation.d.ts.map +1 -0
  174. package/dist/runtime/validation/validation.js +93 -0
  175. package/dist/runtime/validation/validation.js.map +1 -0
  176. package/dist/schemas/automator/miniprogram_close.json +12 -0
  177. package/dist/schemas/automator/miniprogram_connect.json +19 -0
  178. package/dist/schemas/automator/miniprogram_disconnect.json +12 -0
  179. package/dist/schemas/automator/miniprogram_launch.json +30 -0
  180. package/dist/server.js +1 -1
  181. package/dist/server.js.map +1 -1
  182. package/dist/tools/index.d.ts.map +1 -1
  183. package/dist/tools/index.js +3 -3
  184. package/dist/tools/index.js.map +1 -1
  185. package/dist/tools/miniprogram.d.ts +2 -1
  186. package/dist/tools/miniprogram.d.ts.map +1 -1
  187. package/dist/tools/miniprogram.js +19 -24
  188. package/dist/tools/miniprogram.js.map +1 -1
  189. package/dist/tools/page.js +2 -2
  190. package/dist/tools/page.js.map +1 -1
  191. package/docs/directory-structure-and-code-style-best-practices.md +91 -0
  192. package/docs/migration/README.md +34 -0
  193. package/docs/migration/TC-ALIGN-01-notes.md +35 -0
  194. package/docs/migration/runtime-skeleton.md +50 -0
  195. package/docs/migration/tool-schema-strategy.md +75 -0
  196. package/docs//345/256/214/346/225/264/345/256/236/347/216/260/346/226/271/346/241/210.md +14 -14
  197. package/docs//347/254/254/344/270/200/347/211/210/346/234/254/346/226/271/346/241/210.md +7 -7
  198. package/package.json +4 -2
  199. package/docs/SIMPLE_USAGE.md +0 -210
  200. package/docs/architecture.E-Docs.md +0 -1359
  201. package/docs/architecture.F1.md +0 -720
  202. package/docs/architecture.F2.md +0 -871
  203. package/docs/architecture.F3.md +0 -905
  204. package/docs/architecture.md +0 -90
  205. package/docs/charter.A1.align.yaml +0 -170
  206. package/docs/charter.A2.align.yaml +0 -199
  207. package/docs/charter.A3.align.yaml +0 -242
  208. package/docs/charter.A4.align.yaml +0 -227
  209. package/docs/charter.B1.align.yaml +0 -179
  210. package/docs/charter.B2.align.yaml +0 -200
  211. package/docs/charter.B3.align.yaml +0 -200
  212. package/docs/charter.B4.align.yaml +0 -188
  213. package/docs/charter.C1.align.yaml +0 -190
  214. package/docs/charter.C2.align.yaml +0 -202
  215. package/docs/charter.C3.align.yaml +0 -211
  216. package/docs/charter.C4.align.yaml +0 -263
  217. package/docs/charter.C5.align.yaml +0 -220
  218. package/docs/charter.D1.align.yaml +0 -190
  219. package/docs/charter.D2.align.yaml +0 -234
  220. package/docs/charter.D3.align.yaml +0 -206
  221. package/docs/charter.E-Docs.align.yaml +0 -294
  222. package/docs/charter.F1.align.yaml +0 -193
  223. package/docs/charter.F2.align.yaml +0 -248
  224. package/docs/charter.F3.align.yaml +0 -287
  225. package/docs/charter.G.align.yaml +0 -174
  226. package/docs/charter.align.yaml +0 -111
  227. package/docs/maintenance.md +0 -682
  228. package/docs/playwright-mcp/350/260/203/347/240/224.md +0 -53
  229. package/docs/setup-guide.md +0 -775
  230. package/docs/tasks.A1.atomize.md +0 -296
  231. package/docs/tasks.A2.atomize.md +0 -408
  232. package/docs/tasks.A3.atomize.md +0 -564
  233. package/docs/tasks.A4.atomize.md +0 -496
  234. package/docs/tasks.B1.atomize.md +0 -352
  235. package/docs/tasks.B2.atomize.md +0 -561
  236. package/docs/tasks.B3.atomize.md +0 -508
  237. package/docs/tasks.B4.atomize.md +0 -504
  238. package/docs/tasks.C1.atomize.md +0 -540
  239. package/docs/tasks.C2.atomize.md +0 -665
  240. package/docs/tasks.C3.atomize.md +0 -745
  241. package/docs/tasks.C4.atomize.md +0 -908
  242. package/docs/tasks.C5.atomize.md +0 -755
  243. package/docs/tasks.D1.atomize.md +0 -547
  244. package/docs/tasks.D2.atomize.md +0 -619
  245. package/docs/tasks.D3.atomize.md +0 -790
  246. package/docs/tasks.E-Docs.atomize.md +0 -1204
  247. package/docs/tasks.atomize.md +0 -189
@@ -1,775 +0,0 @@
1
- # Setup Guide - Complete Environment Configuration
2
-
3
- > ⏱️ **Estimated Time**: 15 minutes from zero to running
4
-
5
- This guide walks you through setting up `creatoria-miniapp-mcp` for automated WeChat Mini Program testing via MCP.
6
-
7
- ---
8
-
9
- ## System Requirements
10
-
11
- ### Operating Systems
12
- - **macOS**: 12.0+ (Monterey or later)
13
- - **Windows**: 10/11 (64-bit)
14
- - **Linux**: Ubuntu 20.04+, Debian 11+, or equivalent
15
-
16
- ### Required Software
17
- - **Node.js**: 18.0.0 or later (LTS recommended)
18
- - **pnpm**: 9.0.0+ (package manager)
19
- - **WeChat Developer Tools**: Latest stable version
20
- - **MCP Client**: Claude Desktop, Cline, or custom implementation
21
-
22
- ---
23
-
24
- ## Step 1: Install Runtime Environment
25
-
26
- ### 1.1 Node.js
27
-
28
- **Check Current Version:**
29
- ```bash
30
- node --version # Should output v18.0.0 or higher
31
- ```
32
-
33
- **Installation (if needed):**
34
-
35
- **Option A: Using nvm (Recommended)**
36
- ```bash
37
- # Install nvm (if not installed)
38
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
39
-
40
- # Install Node.js 18 LTS
41
- nvm install 18
42
- nvm use 18
43
- nvm alias default 18
44
- ```
45
-
46
- **Option B: Official Installer**
47
- - Download from [nodejs.org](https://nodejs.org/)
48
- - Choose LTS version (18.x or 20.x)
49
- - Follow installation wizard
50
-
51
- **Verification:**
52
- ```bash
53
- node --version # v18.x.x or v20.x.x
54
- npm --version # Should come with Node
55
- ```
56
-
57
- ---
58
-
59
- ### 1.2 pnpm Package Manager
60
-
61
- **Why pnpm?** This project enforces `pnpm@9.0.0` via `packageManager` field in `package.json`. Using npm or yarn will fail.
62
-
63
- **Installation:**
64
- ```bash
65
- # Install pnpm globally
66
- npm install -g pnpm@9.0.0
67
-
68
- # Verify installation
69
- pnpm --version # 9.0.0
70
- ```
71
-
72
- **Alternative (using Corepack - Node 16.13+):**
73
- ```bash
74
- corepack enable
75
- corepack prepare pnpm@9.0.0 --activate
76
- ```
77
-
78
- ---
79
-
80
- ### 1.3 WeChat Developer Tools (微信开发者工具)
81
-
82
- **Download:**
83
- - Official page: https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html
84
- - Choose version for your OS (macOS/Windows/Linux)
85
-
86
- **Installation Paths:**
87
- - **macOS**: `/Applications/wechatwebdevtools.app`
88
- - **Windows**: `C:\Program Files (x86)\Tencent\微信web开发者工具`
89
- - **Linux**: `/opt/wechatwebdevtools` (or custom path)
90
-
91
- **Version Compatibility:**
92
- - Minimum: 1.02.1904090 (supports `miniprogram-automator`)
93
- - Recommended: Latest stable (1.06.x or newer)
94
-
95
- **Post-Install:**
96
- 1. Launch WeChat DevTools
97
- 2. Log in with WeChat account
98
- 3. Create or open a Mini Program project (needed for testing)
99
-
100
- ---
101
-
102
- ## Step 2: Configure WeChat DevTools Automation
103
-
104
- WeChat Developer Tools must enable automation API access via WebSocket.
105
-
106
- ### 2.1 Enable Automation Port
107
-
108
- **Option A: Automated Setup (Recommended)**
109
- ```bash
110
- cd creatoria-miniapp-mcp
111
-
112
- # Use default port (9420)
113
- ./scripts/setup-devtools-port.sh
114
-
115
- # Or specify custom port
116
- ./scripts/setup-devtools-port.sh 9421
117
- ```
118
-
119
- **Option B: Manual Setup**
120
- 1. Launch WeChat Developer Tools
121
- 2. Click **Settings** (设置) in top menu
122
- 3. Navigate to **Security** (安全设置) tab
123
- 4. Find **Service Port** (服务端口) section
124
- 5. **Check** "Enable Service Port" checkbox
125
- 6. Enter port number: `9420` (default) or custom port
126
- 7. Click **OK** to save
127
-
128
- **Security Note**: The automation port only accepts connections from `localhost`. No external access is allowed.
129
-
130
- ---
131
-
132
- ### 2.2 Configure CLI Access (Optional but Recommended)
133
-
134
- Enable CLI control for programmatic launching:
135
-
136
- **macOS/Linux:**
137
- 1. Open Settings → Security
138
- 2. Enable "Allow CLI/HTTP calls" (允许 CLI/HTTP 调用)
139
- 3. Save and restart DevTools
140
-
141
- **CLI Path Detection:**
142
- - macOS: Auto-detected at `/Applications/wechatwebdevtools.app/Contents/MacOS/cli`
143
- - Windows: Usually at `C:\Program Files (x86)\Tencent\微信web开发者工具\cli.bat`
144
- - Linux: Custom path (you'll need to specify via config)
145
-
146
- **Test CLI:**
147
- ```bash
148
- # macOS
149
- /Applications/wechatwebdevtools.app/Contents/MacOS/cli --version
150
-
151
- # Windows
152
- "C:\Program Files (x86)\Tencent\微信web开发者工具\cli.bat" --version
153
- ```
154
-
155
- ---
156
-
157
- ## Step 3: Install & Build MCP Server
158
-
159
- ### 3.1 Clone and Install
160
-
161
- ```bash
162
- # Clone repository
163
- git clone https://github.com/rn1024/creatoria-miniapp-mcp.git
164
- cd creatoria-miniapp-mcp
165
-
166
- # Install dependencies (uses pnpm)
167
- pnpm install
168
-
169
- # Build TypeScript to JavaScript
170
- pnpm build
171
- ```
172
-
173
- **Build Output**: Compiled files will be in `dist/` directory.
174
-
175
- ---
176
-
177
- ### 3.2 Run Tests (Optional)
178
-
179
- Verify installation by running the test suite:
180
-
181
- ```bash
182
- pnpm test
183
- ```
184
-
185
- **Expected Output:**
186
- ```
187
- Test Suites: 9 passed, 9 total
188
- Tests: 290 passed, 290 total
189
- Time: ~6s
190
-
191
- ✅ 100% test pass rate
192
- ```
193
-
194
- If tests fail, check:
195
- - Node version (`node --version` >= 18.0.0)
196
- - pnpm version (`pnpm --version` = 9.0.0)
197
- - No missing dependencies
198
-
199
- ---
200
-
201
- ## Step 4: Configure MCP Client
202
-
203
- Choose one of the following MCP clients to connect to the server.
204
-
205
- ### 4.1 Claude Desktop (Recommended)
206
-
207
- **Installation:**
208
- - Download from: https://claude.ai/download
209
- - Available for macOS, Windows, Linux
210
-
211
- **Configuration:**
212
-
213
- 1. Locate Claude Desktop config file:
214
- - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
215
- - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
216
- - **Linux**: `~/.config/Claude/claude_desktop_config.json`
217
-
218
- 2. Add MCP server configuration:
219
- ```json
220
- {
221
- "mcpServers": {
222
- "miniprogram": {
223
- "command": "node",
224
- "args": ["/absolute/path/to/creatoria-miniapp-mcp/dist/cli.js"],
225
- "env": {
226
- "PROJECT_PATH": "/absolute/path/to/your/miniprogram"
227
- }
228
- }
229
- }
230
- }
231
- ```
232
-
233
- 3. **Replace paths**:
234
- - First path: Absolute path to `dist/cli.js` (e.g., `/Users/you/creatoria-miniapp-mcp/dist/cli.js`)
235
- - `PROJECT_PATH`: Absolute path to your Mini Program project folder
236
-
237
- 4. **Restart Claude Desktop** to load the server
238
-
239
- **Verification:**
240
- - Open Claude Desktop
241
- - Type: "List available MCP servers"
242
- - You should see `miniprogram` server with 65 tools
243
-
244
- ---
245
-
246
- ### 4.2 Cline (VS Code Extension)
247
-
248
- **Installation:**
249
- 1. Open VS Code
250
- 2. Install "Cline" extension from marketplace
251
- 3. Reload VS Code
252
-
253
- **Configuration:**
254
-
255
- 1. Open VS Code settings (`Cmd/Ctrl + ,`)
256
- 2. Search for "Cline: MCP Servers"
257
- 3. Click "Edit in settings.json"
258
- 4. Add configuration:
259
- ```json
260
- {
261
- "cline.mcpServers": {
262
- "miniprogram": {
263
- "command": "node",
264
- "args": ["/absolute/path/to/creatoria-miniapp-mcp/dist/cli.js"],
265
- "env": {
266
- "PROJECT_PATH": "/absolute/path/to/your/miniprogram"
267
- }
268
- }
269
- }
270
- }
271
- ```
272
-
273
- 5. Restart VS Code
274
-
275
- ---
276
-
277
- ### 4.3 Custom MCP Client
278
-
279
- For custom integrations, use MCP SDK:
280
-
281
- ```typescript
282
- import { Client } from '@modelcontextprotocol/sdk/client/index.js'
283
- import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'
284
-
285
- const transport = new StdioClientTransport({
286
- command: 'node',
287
- args: ['/path/to/creatoria-miniapp-mcp/dist/cli.js'],
288
- env: {
289
- PROJECT_PATH: '/path/to/miniprogram'
290
- }
291
- })
292
-
293
- const client = new Client({
294
- name: 'my-custom-client',
295
- version: '1.0.0'
296
- }, {
297
- capabilities: {
298
- tools: {}
299
- }
300
- })
301
-
302
- await client.connect(transport)
303
-
304
- // List available tools
305
- const tools = await client.request({ method: 'tools/list' }, {})
306
- console.log(tools) // 65 tools
307
- ```
308
-
309
- ---
310
-
311
- ## Step 5: Configuration Options
312
-
313
- All configuration can be provided via:
314
- 1. **Environment variables** (in MCP client config)
315
- 2. **Config file** (`.mcp.json` in project root - optional)
316
- 3. **CLI arguments** (if invoking directly)
317
-
318
- ### 5.1 Environment Variables
319
-
320
- Add to your MCP client's `env` section:
321
-
322
- ```json
323
- {
324
- "env": {
325
- "PROJECT_PATH": "/path/to/miniprogram",
326
- "CLI_PATH": "/custom/path/to/cli",
327
- "OUTPUT_DIR": "/custom/output/dir",
328
- "SESSION_TIMEOUT": "1800000",
329
- "CAPABILITIES": "core,assert,snapshot,record"
330
- }
331
- }
332
- ```
333
-
334
- **Available Variables:**
335
-
336
- | Variable | Description | Default | Required |
337
- |----------|-------------|---------|----------|
338
- | `PROJECT_PATH` | Mini Program project directory | - | ❌ (can be set per-session) |
339
- | `CLI_PATH` | WeChat DevTools CLI path | Auto-detected (macOS) | ❌ |
340
- | `OUTPUT_DIR` | Output directory for screenshots/snapshots | `.mcp-artifacts` | ❌ |
341
- | `SESSION_TIMEOUT` | Session auto-cleanup timeout (ms) | `1800000` (30 min) | ❌ |
342
- | `CAPABILITIES` | Comma-separated tool capabilities | `core,assert,snapshot,record` | ❌ |
343
-
344
- ---
345
-
346
- ### 5.2 Configuration File (.mcp.json)
347
-
348
- Create `.mcp.json` in project root (optional, for advanced users).
349
-
350
- **Configuration Templates**: See `examples/config/` for ready-to-use templates:
351
- - `basic.json`: Complete configuration with all options
352
- - `minimal.json`: Only required `projectPath`
353
- - `custom-capabilities.json`: Selective tool registration
354
- - `macos.json`: macOS-specific with CLI path
355
- - `testing.json`: Testing-focused configuration
356
- - `multi-project.json`: Multi-project setup with different ports
357
- - `ci-cd.json`: CI/CD configuration with environment variables
358
-
359
- **Configuration Priority**: CLI Arguments > Environment Variables > Config File > Defaults
360
-
361
- **Example (.mcp.json)**:
362
-
363
- ```json
364
- {
365
- "projectPath": "/path/to/miniprogram",
366
- "cliPath": "/custom/path/to/cli",
367
- "outputDir": ".mcp-artifacts",
368
- "sessionTimeout": 1800000,
369
- "capabilities": ["core", "assert", "snapshot", "record"]
370
- }
371
- ```
372
-
373
- **Note**: Environment variables override config file values.
374
-
375
- ---
376
-
377
- ### 5.3 Capabilities System
378
-
379
- Control which tool categories are loaded:
380
-
381
- **Available Capabilities:**
382
- - `core`: All 65 tools (default, includes all categories below)
383
- - `automator`: Connection & lifecycle (4 tools)
384
- - `miniprogram`: App-level operations (16 tools)
385
- - `page`: Page-level operations (8 tools)
386
- - `element`: Element interactions (23 tools)
387
- - `assert`: Assertion tools (9 tools)
388
- - `snapshot`: Snapshot tools (3 tools)
389
- - `record`: Recording/replay tools (6 tools)
390
- - `network`: Network mocking tools (6 tools)
391
-
392
- **Examples:**
393
- ```json
394
- // Load all 65 tools (default)
395
- "capabilities": ["core"]
396
-
397
- // Load specific categories (selective registration)
398
- "capabilities": ["automator", "miniprogram", "page", "element"]
399
-
400
- // Load only testing tools
401
- "capabilities": ["automator", "assert", "network"]
402
- ```
403
-
404
- ---
405
-
406
- ## Step 6: Verification & First Run
407
-
408
- ### 6.1 Verify WeChat DevTools Connection
409
-
410
- Test automation port before using MCP:
411
-
412
- ```bash
413
- # Test port (replace 9420 with your port)
414
- curl http://localhost:9420
415
- # Should return JSON with automation info
416
- ```
417
-
418
- Or use Node.js:
419
- ```bash
420
- node -e "const automator = require('miniprogram-automator'); \
421
- automator.connect({wsEndpoint: 'ws://localhost:9420'}) \
422
- .then(() => console.log('✅ Connected')) \
423
- .catch(e => console.error('❌ Failed:', e.message))"
424
- ```
425
-
426
- **Expected**: `✅ Connected`
427
-
428
- ---
429
-
430
- ### 6.2 Test MCP Server Manually
431
-
432
- Run server directly (without MCP client):
433
-
434
- ```bash
435
- cd creatoria-miniapp-mcp
436
- PROJECT_PATH=/path/to/miniprogram node dist/cli.js
437
- ```
438
-
439
- **Expected Output:**
440
- ```
441
- WeChat Mini Program MCP Server running on stdio
442
- Capabilities: core,assert,snapshot,record,network
443
- Tools registered: 65
444
- ```
445
-
446
- Press `Ctrl+C` to stop.
447
-
448
- ---
449
-
450
- ### 6.3 First Automation via MCP Client
451
-
452
- Open your MCP client (Claude Desktop or Cline) and try:
453
-
454
- **Test 1: List Tools**
455
- ```
456
- You: List all available Mini Program tools
457
-
458
- Claude: [Calls tools/list]
459
- I found 65 tools across 8 categories:
460
- - Automator (4): launch, connect, disconnect, close
461
- - MiniProgram (6): navigate, callWx, evaluate, ...
462
- - Page (8): query, queryAll, waitFor, ...
463
- - Element (23): tap, input, getText, ...
464
- - Assert (9): exists, text, attribute, ...
465
- - Snapshot (3): capture, restore, compare
466
- - Record (6): start, stop, list, replay, ...
467
- ```
468
-
469
- **Test 2: Launch Mini Program**
470
- ```
471
- You: Launch my mini program at /path/to/project
472
-
473
- Claude: [Calls automator.launch]
474
- ✅ WeChat DevTools launched successfully
475
- ✅ Mini Program loaded: /path/to/project
476
- ```
477
-
478
- **Test 3: Simple Automation**
479
- ```
480
- You: Navigate to /pages/index/index and query for element with selector ".title"
481
-
482
- Claude: [Calls miniprogram.navigate + page.query]
483
- ✅ Navigated to /pages/index/index
484
- ✅ Found element: { refId: "elem_abc123", selector: ".title" }
485
- ```
486
-
487
- ---
488
-
489
- ## Development Tools (Optional)
490
-
491
- If you plan to contribute or modify the server:
492
-
493
- ### Linting and Formatting
494
-
495
- ```bash
496
- # Check code style
497
- pnpm lint
498
- pnpm format:check
499
-
500
- # Auto-fix issues
501
- pnpm format
502
- ```
503
-
504
- ### Git Hooks
505
-
506
- Pre-commit hooks are automatically installed via Husky:
507
- - Code formatting check
508
- - TypeScript type checking
509
- - Linting
510
-
511
- ---
512
-
513
- ## Common Setup Issues & Troubleshooting
514
-
515
- ### Issue 1: "CLI not found" Error
516
-
517
- **Symptom:**
518
- ```
519
- Error: Failed to launch miniprogram: CLI not found at /Applications/wechatwebdevtools.app/...
520
- ```
521
-
522
- **Cause:** WeChat DevTools CLI path not auto-detected or installed in non-standard location.
523
-
524
- **Solutions:**
525
-
526
- **Option A: Specify CLI path via environment variable**
527
- ```json
528
- {
529
- "env": {
530
- "CLI_PATH": "/custom/path/to/cli"
531
- }
532
- }
533
- ```
534
-
535
- **Option B: Per-tool call (via MCP client)**
536
- ```
537
- You: Launch mini program at /path/to/project with custom CLI at /opt/wx-devtools/cli
538
-
539
- Claude: [Calls automator.launch with cliPath parameter]
540
- ```
541
-
542
- **Common CLI Paths:**
543
- - macOS: `/Applications/wechatwebdevtools.app/Contents/MacOS/cli`
544
- - Windows: `C:\Program Files (x86)\Tencent\微信web开发者工具\cli.bat`
545
- - Linux: `/opt/wechatwebdevtools/bin/cli`
546
-
547
- ---
548
-
549
- ### Issue 2: "Connection refused" Error
550
-
551
- **Symptom:**
552
- ```
553
- Error: connect ECONNREFUSED 127.0.0.1:9420
554
- ```
555
-
556
- **Cause:** WeChat DevTools automation port not enabled or not accessible.
557
-
558
- **Solutions:**
559
-
560
- 1. **Verify DevTools is running:**
561
- ```bash
562
- # Check if DevTools process exists
563
- ps aux | grep wechat # macOS/Linux
564
- tasklist | findstr wechat # Windows
565
- ```
566
-
567
- 2. **Check automation port is enabled:**
568
- - Open WeChat DevTools
569
- - Settings → Security → Service Port
570
- - Ensure "Enable Service Port" is checked
571
- - Port number matches your config (default: 9420)
572
-
573
- 3. **Test port manually:**
574
- ```bash
575
- curl http://localhost:9420
576
- # Should return JSON if port is accessible
577
- ```
578
-
579
- 4. **Restart DevTools:**
580
- - Close WeChat DevTools completely
581
- - Re-launch and re-enable automation port
582
-
583
- ---
584
-
585
- ### Issue 3: "Port already in use" Error
586
-
587
- **Symptom:**
588
- ```
589
- Error: listen EADDRINUSE: address already in use :::9420
590
- ```
591
-
592
- **Cause:** Another process (or previous DevTools instance) is using port 9420.
593
-
594
- **Solutions:**
595
-
596
- **Option A: Use different port**
597
- ```json
598
- {
599
- "env": {
600
- "PROJECT_PATH": "/path/to/project",
601
- "PORT": "9421"
602
- }
603
- }
604
- ```
605
-
606
- **Option B: Kill process using the port**
607
- ```bash
608
- # macOS/Linux
609
- lsof -ti:9420 | xargs kill
610
-
611
- # Windows
612
- netstat -ano | findstr :9420
613
- taskkill /PID <PID> /F
614
- ```
615
-
616
- ---
617
-
618
- ### Issue 4: MCP Server Not Showing in Claude Desktop
619
-
620
- **Symptom:** Claude Desktop doesn't recognize the miniprogram server.
621
-
622
- **Checks:**
623
-
624
- 1. **Verify config file path:**
625
- ```bash
626
- # macOS
627
- cat ~/Library/Application\ Support/Claude/claude_desktop_config.json
628
-
629
- # Windows
630
- type %APPDATA%\Claude\claude_desktop_config.json
631
- ```
632
-
633
- 2. **Check JSON syntax:**
634
- - Use JSON validator: https://jsonlint.com/
635
- - Ensure no trailing commas
636
- - Paths must use `/` even on Windows (or `\\` for escaped backslashes)
637
-
638
- 3. **Verify paths are absolute:**
639
- ```json
640
- {
641
- "args": ["/Users/you/creatoria-miniapp-mcp/dist/cli.js"] // ✅ Absolute
642
- // NOT: ["./dist/cli.js"] // ❌ Relative won't work
643
- }
644
- ```
645
-
646
- 4. **Restart Claude Desktop:**
647
- - Quit Claude Desktop completely
648
- - Relaunch (config is loaded on startup)
649
-
650
- 5. **Check server logs** (if available):
651
- - Claude Desktop may show MCP server stderr output
652
- - Look for startup messages or errors
653
-
654
- ---
655
-
656
- ### Issue 5: "Project path not found" Error
657
-
658
- **Symptom:**
659
- ```
660
- Error: Project path does not exist: /path/to/project
661
- ```
662
-
663
- **Cause:** Invalid or non-existent Mini Program project path.
664
-
665
- **Solutions:**
666
-
667
- 1. **Verify path exists:**
668
- ```bash
669
- ls -la /path/to/miniprogram # macOS/Linux
670
- dir "C:\path\to\miniprogram" # Windows
671
- ```
672
-
673
- 2. **Check for project.config.json:**
674
- ```bash
675
- # Valid Mini Program project should have:
676
- # - project.config.json
677
- # - app.json
678
- # - pages/ directory
679
- ```
680
-
681
- 3. **Use absolute path:**
682
- ```json
683
- {
684
- "PROJECT_PATH": "/Users/you/miniprogram-demo" // ✅ Absolute
685
- // NOT: "~/miniprogram-demo" // ❌ Shell expansion may not work
686
- }
687
- ```
688
-
689
- ---
690
-
691
- ### Issue 6: Permission Errors (macOS/Linux)
692
-
693
- **Symptom:**
694
- ```
695
- Error: EACCES: permission denied
696
- ```
697
-
698
- **Solutions:**
699
-
700
- 1. **Check file permissions:**
701
- ```bash
702
- ls -l /path/to/creatoria-miniapp-mcp/dist/cli.js
703
- # Should be readable: -rw-r--r-- or -rwxr-xr-x
704
- ```
705
-
706
- 2. **Fix permissions:**
707
- ```bash
708
- chmod +r /path/to/creatoria-miniapp-mcp/dist/cli.js
709
- ```
710
-
711
- 3. **Check output directory:**
712
- ```bash
713
- # Ensure MCP server can write to output directory
714
- mkdir -p .mcp-artifacts
715
- chmod 755 .mcp-artifacts
716
- ```
717
-
718
- ---
719
-
720
- ### Issue 7: Node Version Incompatibility
721
-
722
- **Symptom:**
723
- ```
724
- SyntaxError: Unexpected token '?.'
725
- ```
726
-
727
- **Cause:** Using Node.js <18.0.0 (project requires >=18).
728
-
729
- **Solution:**
730
- ```bash
731
- # Check version
732
- node --version
733
-
734
- # Upgrade if needed (using nvm)
735
- nvm install 18
736
- nvm use 18
737
- nvm alias default 18
738
- ```
739
-
740
- ---
741
-
742
- ### Issue 8: pnpm Not Found
743
-
744
- **Symptom:**
745
- ```
746
- Error: pnpm: command not found
747
- ```
748
-
749
- **Solution:**
750
- ```bash
751
- # Install pnpm globally
752
- npm install -g pnpm@9.0.0
753
-
754
- # Or use corepack (Node 16.13+)
755
- corepack enable
756
- corepack prepare pnpm@9.0.0 --activate
757
- ```
758
-
759
- ---
760
-
761
- ## Next Steps
762
-
763
- ### For Users
764
- - 📖 Read [API Documentation](./api/) for complete tool reference
765
- - 💡 Check [Usage Examples](../examples/) for real-world scenarios
766
- - ❓ Review [Troubleshooting Guide](./troubleshooting.md) for common errors
767
-
768
- ### For Contributors
769
- - 🏗️ Review [Architecture](./architecture.md) to understand system design
770
- - 🤝 Read [Contributing Guide](../CONTRIBUTING.md) for development workflow
771
- - 📋 Check [Task Breakdown](../docs/) for development roadmap (35 charter + task docs)
772
-
773
- ---
774
-
775
- **Setup Complete!** 🎉 You're ready to automate WeChat Mini Program testing with AI assistants.