mcp-weapp-cli
v1.1.0微信小程序开发者工具 CLI 的 MCP 服务器实现
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
weapp_login
登录微信开发者工具。通过扫描二维码完成微信登录,支持多种二维码输出格式。
| Parameter | Type | Description |
|---|---|---|
qrFormat | string | 二维码格式:terminal-终端显示(默认),image-图片文件,base64-base64编码 |
qrOutput | string | 二维码输出路径(当 qrFormat 为 image 时有效) |
qrSize | string | 二维码大小(仅当 qrFormat 为 terminal 时有效):small-小尺寸,default-默认尺寸 |
resultOutput | string | 登录结果输出路径,用于保存登录后的用户信息 |
weapp_check_login
检查微信开发者工具的登录状态。返回当前是否已登录以及登录的用户信息。
weapp_preview
生成微信小程序预览二维码,用于在真机上预览小程序效果
| Parameter | Type | Description |
|---|---|---|
project * | string | 小程序项目路径,必须是包含 project.config.json 的目录 |
infoOutput | string | 预览信息输出文件路径(JSON格式) |
qrFormat | string | 二维码格式:terminal(终端输出)、image(图片文件)、base64(Base64编码) |
qrOutput | string | 二维码图片输出路径(当 qrFormat 为 image 时使用) |
weapp_auto_preview
自动预览小程序,将自动打开微信开发者工具并生成预览二维码
| Parameter | Type | Description |
|---|---|---|
project * | string | 小程序项目路径,必须是包含 project.config.json 的目录 |
infoOutput | string | 预览信息输出文件路径(JSON格式) |
weapp_upload
上传微信小程序代码到微信公众平台,用于提交审核或发布体验版
| Parameter | Type | Description |
|---|---|---|
desc * | string | 版本描述信息,将在微信公众平台显示 |
project * | string | 小程序项目路径,必须是包含 project.config.json 的目录 |
version * | string | 版本号,格式为 x.y.z(如 1.0.0) |
infoOutput | string | 上传信息输出文件路径(JSON格式) |
weapp_open_tool
启动微信开发者工具(不打开项目)。启动前会检测并关闭其他运行中的实例,确保只有一个实例运行。返回实际的 HTTP 服务端口号。
| Parameter | Type | Description |
|---|---|---|
debug | boolean | 开启调试模式(可选) |
httpPort | number | HTTP 服务端口(可选,默认自动分配)。注意:这是 HTTP 服务端口,不是自动化端口。 |
lang | string | 语言设置(可选) |
weapp_open_project
打开指定的小程序项目。会先确保没有其他项目实例运行,然后打开项目。返回实际的 HTTP 服务端口号。
| Parameter | Type | Description |
|---|---|---|
projectPath * | string | 项目路径(必填)。小程序项目根目录,包含 project.config.json 的目录 |
debug | boolean | 开启调试模式(可选) |
httpPort | number | HTTP 服务端口(可选) |
lang | string | 语言设置(可选) |
weapp_open_other
以其他模式打开微信小程序项目。会以独立窗口或不同模式打开项目,用于特殊场景下的开发调试。
| Parameter | Type | Description |
|---|---|---|
projectPath * | string | 项目路径(必填)。小程序项目根目录,包含 project.config.json 的目录 |
weapp_close
关闭微信小程序项目。可以关闭指定项目,或不指定项目路径时关闭当前活动项目。
| Parameter | Type | Description |
|---|---|---|
projectPath | string | 项目路径(可选)。指定要关闭的小程序项目路径 |
weapp_quit
完全退出微信开发者工具。此操作会关闭整个开发者工具进程,所有打开的项目都会被关闭。
weapp_reset_fileutils
重置微信开发者工具的文件监听。当文件监听出现异常或需要刷新文件状态时,可以使用此工具重置文件监听模块。
| Parameter | Type | Description |
|---|---|---|
projectPath | string | 项目路径(可选)。指定要重置文件监听的项目路径 |
weapp_http_detect_port
检测微信开发者工具 HTTP 服务的端口号。从用户目录下的 .ide 文件中读取。
weapp_build_npm
构建 npm 包,将 node_modules 中的依赖构建为小程序可用的模块
| Parameter | Type | Description |
|---|---|---|
compileType | string | 编译类型:miniprogram(普通小程序)或 plugin(插件)。默认为 miniprogram |
project | string | 小程序项目目录的绝对路径(与 projectPath 二选一) |
projectPath | string | 小程序项目目录的绝对路径(与 project 二选一,推荐使用 project) |
weapp_clear_cache
清除微信开发者工具的缓存数据
| Parameter | Type | Description |
|---|---|---|
clean | string | 要清除的缓存类型 |
weapp_auto
开启微信开发者工具的自动化功能,允许通过自动化脚本控制开发者工具。会检测自动化端口是否真正被监听,并返回实际监听状态。
| Parameter | Type | Description |
|---|---|---|
project * | string | 小程序项目路径,必须是包含 project.config.json 的目录 |
autoAccount | string | 自动化账号,用于标识自动化会话 |
autoPort | number | 自动化服务监听的端口号,范围为 1-65535。注意:这是自动化端口,不是 HTTP 端口。 |
ticket | string | 登录票据,用于验证身份 |
trustProject | boolean | 是否信任项目,启用后可跳过某些安全提示 |
weapp_auto_replay
执行自动化测试回放,根据录制好的测试用例自动运行测试
| Parameter | Type | Description |
|---|---|---|
project * | string | 小程序项目路径,必须是包含 project.config.json 的目录 |
replayAll | boolean | 是否回放所有测试用例,为 true 时回放全部,为 false 时根据配置文件回放 |
replayConfigPath | string | 回放配置文件的路径,指定要回放的测试用例配置 |
ticket | string | 登录票据,用于验证身份 |
trustProject | boolean | 是否信任项目,启用后可跳过某些安全提示 |
weapp_cloud_env_list
获取微信小程序云开发环境列表。返回当前小程序账号下的所有云开发环境信息。
| Parameter | Type | Description |
|---|---|---|
project * | string | 项目路径(必填)。小程序项目根目录,包含 project.config.json 的目录 |
weapp_cloud_functions_list
获取指定云环境下的云函数列表。返回该环境下所有已部署的云函数信息。
| Parameter | Type | Description |
|---|---|---|
env * | string | 云环境 ID(必填)。要查询的云开发环境标识 |
project * | string | 项目路径(必填)。小程序项目根目录,包含 project.config.json 的目录 |
weapp_cloud_functions_info
获取指定云函数的详细信息。包括函数配置、状态、运行环境等信息。
| Parameter | Type | Description |
|---|---|---|
env * | string | 云环境 ID(必填)。云函数所在的云开发环境标识 |
names * | array | 云函数名称列表(必填)。要查询的云函数名称数组 |
project * | string | 项目路径(必填)。小程序项目根目录,包含 project.config.json 的目录 |
weapp_cloud_functions_deploy
部署云函数到云端。可以将本地开发的云函数完整部署到指定的云环境中。
| Parameter | Type | Description |
|---|---|---|
env * | string | 云环境 ID(必填)。要部署到的云开发环境标识 |
project * | string | 项目路径(必填)。小程序项目根目录,包含 project.config.json 的目录 |
names | array | 云函数名称列表(与 paths 二选一)。要部署的云函数名称数组 |
paths | array | 云函数路径列表(与 names 二选一)。要部署的云函数本地路径数组 |
remoteNpmInstall | boolean | 是否在云端安装 npm 依赖(可选)。设为 true 时会在云端执行 npm install |
weapp_cloud_functions_inc_deploy
增量部署云函数到云端。只部署云函数的变更部分,速度更快。
| Parameter | Type | Description |
|---|---|---|
env * | string | 云环境 ID(必填)。要部署到的云开发环境标识 |
project * | string | 项目路径(必填)。小程序项目根目录,包含 project.config.json 的目录 |
names | array | 云函数名称列表(与 paths 二选一)。要增量部署的云函数名称数组 |
paths | array | 云函数路径列表(与 names 二选一)。要增量部署的云函数本地路径数组 |
remoteNpmInstall | boolean | 是否在云端安装 npm 依赖(可选)。设为 true 时会在云端执行 npm install |
weapp_cloud_functions_download
从云端下载云函数代码到本地。用于将已部署的云函数代码下载到本地进行查看或修改。
| Parameter | Type | Description |
|---|---|---|
env * | string | 云环境 ID(必填)。云函数所在的云开发环境标识 |
name * | string | 云函数名称(必填)。要下载的云函数名称 |
project * | string | 项目路径(必填)。小程序项目根目录,包含 project.config.json 的目录 |
weapp_status
检测微信开发者工具的运行状态、端口信息和进程情况
| Parameter | Type | Description |
|---|---|---|
checkAutoPort | number | 要检测的自动化端口(如 9420) |
checkHttpPort | boolean | 是否检测 HTTP Server 端口(默认 true) |
weapp_kill_all
强制关闭所有微信开发者工具实例(用于解决多实例冲突问题)
weapp_http_login
使用 HTTP API 登录微信开发者工具
| Parameter | Type | Description |
|---|---|---|
qrFormat | string | 二维码格式 |
qrOutput | string | 二维码输出路径 |
resultOutput | string | 登录结果输出路径 |
weapp_http_check_login
使用 HTTP API 检查微信开发者工具登录状态
weapp_http_preview
使用 HTTP API 生成小程序预览二维码
| Parameter | Type | Description |
|---|---|---|
project * | string | 项目路径(必填) |
compileCondition | string | 自定义编译条件(JSON 字符串) |
infoOutput | string | 预览信息输出路径 |
qrFormat | string | 二维码格式 |
qrOutput | string | 二维码输出路径 |
weapp_http_upload
使用 HTTP API 上传小程序代码到微信公众平台
| Parameter | Type | Description |
|---|---|---|
project * | string | 项目路径(必填) |
version * | string | 版本号(必填) |
desc | string | 版本描述 |
infoOutput | string | 上传信息输出路径 |
weapp_http_auto_preview
使用 HTTP API 自动预览小程序
| Parameter | Type | Description |
|---|---|---|
project * | string | 项目路径(必填) |
infoOutput | string | 预览信息输出路径 |
weapp_http_build_npm
使用 HTTP API 构建 npm
| Parameter | Type | Description |
|---|---|---|
project * | string | 项目路径(必填) |
compileType | string | 编译类型 |
weapp_http_clear_cache
使用 HTTP API 清除开发者工具缓存。相比 CLI 方式,HTTP 方式支持更精细的缓存类型控制。
| Parameter | Type | Description |
|---|---|---|
project * | string | 项目路径(必填) |
clean | string | 缓存类型 |
weapp_http_open
使用 HTTP API 打开微信开发者工具或指定项目
| Parameter | Type | Description |
|---|---|---|
project | string | 项目路径(可选) |
weapp_http_close
使用 HTTP API 关闭小程序项目
| Parameter | Type | Description |
|---|---|---|
project * | string | 项目路径(必填) |
weapp_http_quit
使用 HTTP API 退出微信开发者工具
weapp_http_reset_fileutils
使用 HTTP API 重置文件监听
weapp_http_cloud_env_list
使用 HTTP API 获取云开发环境列表
| Parameter | Type | Description |
|---|---|---|
project * | string | 项目路径(必填) |
weapp_http_cloud_functions_list
使用 HTTP API 获取云函数列表
| Parameter | Type | Description |
|---|---|---|
env * | string | 云环境 ID(必填) |
project * | string | 项目路径(必填) |