Wechat Devtools MCP
This MCP server provides tools to automate and control a WeChat Mini Program running in WeChat DevTools, covering connection management, app-level operations, page and element interactions, API mocking, network monitoring, and log collection.
Connection & Lifecycle: launch, connect, status, disconnect, close, release_handles
App-Level Operations: navigate_to, redirect_to, navigate_back, re_launch, switch_tab, current_page, page_stack, system_info, evaluate (execute JavaScript in AppService), page_scroll_to, screenshot, get/set/refresh ticket, call/mock/restore wx methods, monitor network requests (start, retrieve logs, clear)
Page Operations: query elements (WXSS selector, XPath, text; single/all), page_tree, page_call_method, page_wait_for, page_data, page_set_data, page_size, page_scroll_top
Element Operations: element_query (children), element_tap, element_longpress, element_input, element_trigger, element_text, element_attribute, element_property, element_value, element_style, element_size, element_offset, element_wxml, element_call_method, element_data, element_set_data, element_scroll_width/height, element_scroll_to, element_swipe_to, element_move_to, element_slide_to, element_call_context_method, element_touch
Logging: console_messages (up to 500), exception_messages (up to 500), clear_event_logs
Provides tools for automating WeChat Mini Programs through WeChat Developer Tools, including launching/connecting, page navigation, element interaction, screenshots, and log retrieval.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Wechat Devtools MCP start the mini program and take a screenshot of the home page"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
@purea/wechat-devtools-mcp
基于微信官方 miniprogram-automator SDK 封装的 MCP 服务器, 将微信小程序自动化能力暴露为 MCP 工具,供 AI 助手通过 stdio 调用,控制微信开发者工具中运行的小程序。
使用前提
微信开发者工具开启「设置 -> 安全设置 -> 服务端口」(CLI/HTTP 调用)
小程序已编译(uni-app 项目请先执行
uni build,projectPath指向unpackage/dist/build/mp-weixin;原生小程序指向含project.config.json的目录)
Related MCP server: weapp-agent-mcp
MCP 客户端配置示例
已发布至 npmjs,直接通过 npx 拉起:
{
"mcpServers": {
"Wechat Devtools Mcp": {
"command": "npx",
"args": ["-y", "@purea/wechat-devtools-mcp@latest"],
"env": {},
"disabled": false
}
}
}可通过 args 追加默认参数,作为 launch / connect 工具参数的默认值(工具参数传入时优先):
参数 | 说明 |
| 小程序项目路径(缺省自动探测当前工作区) |
| 微信开发者工具 CLI 路径(缺省自动探测默认安装位置) |
| 启动最长等待时间(ms),默认 30000 |
| 自动化 WebSocket 端口 |
| 用户 openid(多账号调试) |
| 开发者工具登录票据 |
| 自动信任项目 |
{
"mcpServers": {
"Wechat Devtools Mcp": {
"command": "npx",
"args": [
"-y",
"@purea/wechat-devtools-mcp@latest",
"--projectPath=E:/MyProgram/demo/unpackage/dist/build/mp-weixin",
"--cliPath=C:/Program Files (x86)/Tencent/微信web开发者工具/cli.bat",
"--trust-project"
],
"env": {},
"disabled": false
}
}
}提供的能力
连接 / 生命周期:
launch/connect/status/disconnect/close/release_handles小程序级操作:
page_stack/navigate_to/redirect_to/navigate_back/re_launch/switch_tab/current_page/system_info/evaluate/page_scroll_to/screenshot/ 票据(get_ticket/set_ticket/refresh_ticket)/ wx 方法(call_wx_method/mock_wx_method/restore_wx_method)/ 网络监控(network_start/network_log/network_clear)页面级操作:
page_query/page_query_all/page_query_xpath/page_query_xpath_all/page_tree/page_query_by_text/page_call_method/page_wait_for/page_data/page_set_data/page_size/page_scroll_top元素级操作:
element_query/element_tap/element_input/element_text/element_trigger/element_info等 26 个运行日志:
console_messages/exception_messages/clear_event_logs
说明
句柄数量有上限(页面 500 / 元素 1000),超出后按 FIFO 淘汰最旧句柄;也可随时用
release_handles手动清理。status在连接失效时返回connected: false并附带原因,而不是直接报错。
Available Tools
61 toolscall_wx_methodB
在 AppService 中调用 wx 全局方法并返回结果
Inputs: method (required), args.
clear_event_logsA
清空已收集的控制台日志与异常记录
Inputs: no named parameters.
closeA
断开连接并关闭开发者工具中的项目窗口
Inputs: no named parameters.
connectA
连接到已在微信开发者工具中运行的小程序(缺省连接本机 --port 端口)
Inputs: wsEndpoint.
console_messagesA
获取小程序运行产生的控制台日志(连接后自动收集,最多 500 条)
Inputs: no named parameters.
current_pageA
获取当前活动页面(返回 page_id 句柄)
Inputs: no named parameters.
disconnectA
断开小程序连接(开发者工具窗口保持打开)
Inputs: no named parameters.
element_attributeB
获取元素特性值(如 class / id / src)
Inputs: name (required), element_id (required).
element_call_context_methodB
调用 video 组件上下文 Context 方法
Inputs: method (required), element_id (required), args.
element_call_methodC
调用自定义组件实例方法
Inputs: method (required), element_id (required), args.
element_dataA
获取自定义组件 data(可指定路径,仅自定义组件可用)
Inputs: element_id (required), path.
element_inputB
向 input/textarea 组件输入文本
Inputs: value (required), element_id (required).
element_longpressD
长按元素
Inputs: element_id (required).
element_move_toC
移动 movable-view 到指定位置
Inputs: x (required), y (required), element_id (required).
element_offsetB
获取元素位置偏移(相对视口)
Inputs: element_id (required).
element_propertyB
获取元素属性值(如 input 组件的 value)
Inputs: name (required), element_id (required).
element_queryB
在元素内按 WXSS 选择器查询首个匹配子元素
Inputs: selector (required), element_id (required).
element_query_allA
在元素内按 WXSS 选择器查询所有匹配子元素(返回 element_id 句柄数组;超 1000 个时仅末尾 1000 个句柄可用)
Inputs: selector (required), element_id (required).
element_scroll_heightB
获取元素可滚动高度(scrollHeight)
Inputs: element_id (required).
element_scroll_toA
滚动 scroll-view 到指定位置
Inputs: x (required), y (required), element_id (required).
element_scroll_widthB
获取元素可滚动宽度(scrollWidth)
Inputs: element_id (required).
element_set_dataA
修改自定义组件 data(仅自定义组件可用)
Inputs: data (required), element_id (required).
element_sizeA
获取元素尺寸(宽高)
Inputs: element_id (required).
element_slide_toC
设置 slider 组件的值
Inputs: value (required), element_id (required).
element_styleB
获取元素样式值(如 color / fontSize)
Inputs: name (required), element_id (required).
element_swipe_toC
滑动 swiper 到指定滑块
Inputs: index (required), element_id (required).
element_tapC
点击元素
Inputs: element_id (required).
element_textB
获取元素文本内容
Inputs: element_id (required).
element_touchB
触发元素触摸事件(touchstart / touchmove / touchend)
Inputs: type (required), element_id (required), touches, changedTouches.
element_triggerB
触发元素事件(如 change / blur)
Inputs: type (required), element_id (required), detail.
element_valueB
获取元素值(input/textarea 等表单组件)
Inputs: element_id (required).
element_wxmlA
获取元素 WXML 结构(默认内部 WXML,includeSelf=true 返回包含自身的 outerWXML)
Inputs: element_id (required), includeSelf.
evaluateA
注入函数源码在 AppService 中执行并返回结果(可访问 getApp/getCurrentPages 等全局)
Inputs: code (required), args.
exception_messagesA
获取小程序运行产生的异常日志(连接后自动收集,最多 500 条)
Inputs: no named parameters.
get_ticketA
获取开发者工具登录票据(有效期两小时)
Inputs: no named parameters.
launchB
启动微信开发者工具并连接小程序(支持项目路径、cli 路径、端口、票据等参数)
Inputs: port, ticket, account, cliPath, +3 more.
mock_wx_methodA
覆盖 wx 方法并返回固定结果(用于模拟第三方依赖)
Inputs: method (required), result (required).
page_call_methodB
调用页面实例方法(含 onPullDownRefresh 等事件方法与自定义方法)
Inputs: method (required), page_id (required), args.
page_dataB
获取页面渲染数据(可指定路径,不传返回全部)
Inputs: page_id (required), path.
page_queryB
在页面中按 WXSS 选择器查询首个匹配元素(返回 element_id 句柄)
Inputs: page_id (required), selector (required).
page_query_allA
在页面中按 WXSS 选择器查询所有匹配元素(返回 element_id 句柄数组;超 1000 个时仅末尾 1000 个句柄可用)
Inputs: page_id (required), selector (required).
page_query_xpathA
在页面中按 XPath 表达式查询首个匹配元素(返回 element_id 句柄)
Inputs: xpath (required), page_id (required).
page_query_xpath_allA
在页面中按 XPath 表达式查询所有匹配元素(返回 element_id 句柄数组;超 1000 个时仅末尾 1000 个句柄可用)
Inputs: xpath (required), page_id (required).
page_scroll_toC
将当前页面滚动到指定位置
Inputs: scrollTop (required).
page_scroll_topA
获取页面滚动位置(scrollTop)
Inputs: page_id (required).
page_set_dataA
修改页面渲染数据(直接改 data,不触发组件响应式更新,适合调试)
Inputs: data (required), page_id (required).
page_sizeC
获取页面尺寸(宽高)
Inputs: page_id (required).
page_stackA
获取当前页面栈(所有已打开页面,并注册 page_id 句柄)
Inputs: no named parameters.
page_wait_forC
等待条件满足:数字=等待毫秒数,字符串=等待元素选择器出现
Inputs: page_id (required), condition (required), timeout.
redirect_toA
重定向到应用内非 tabBar 页面(关闭当前页面,替换栈顶)
Inputs: url (required).
refresh_ticketA
刷新登录票据(过期时间重置为两小时)
Inputs: no named parameters.
re_launchA
关闭所有页面并重新打开指定页面
Inputs: url (required).
release_handlesA
清理缓存的 page / element 句柄,防止句柄无限增长
Inputs: scope.
restore_wx_methodA
恢复被 mock 的 wx 方法为原始实现
Inputs: method (required).
screenshotA
对小程序当前页面截图(传 path 保存到文件,否则返回图片 base64)
Inputs: path.
set_ticketC
设置开发者工具登录票据
Inputs: ticket (required).
statusB
查询当前连接状态与页面栈信息
Inputs: no named parameters.
switch_tabA
切换到 tabBar 页面(url 需以 / 开头)
Inputs: url (required).
system_infoA
获取小程序运行环境系统信息(机型、系统版本、微信版本等)
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 61 tools
Each tool has a distinct purpose, but some overlap exists between element_value, element_property, and element_attribute, as well as between page_query and element_query, which could cause misselection without careful reading. Overall, descriptions clarify the differences.
Tool names are mostly consistent with a verb_noun pattern and snake_case, using page_ and element_ prefixes. Minor deviations like 'status', 'screenshot', and 'evaluate' break the pattern slightly but are still readable.
With 61 tools, this server is far too large for an MCP server. Many tools could be consolidated with parameters (e.g., query selector type), and the sheer number makes it difficult for agents to choose appropriately.
The tool set covers the full lifecycle: connection, navigation, page inspection, element interaction, logging, mocking, and evaluation. There appear to be no major gaps for the stated purpose of controlling WeChat DevTools.
Maintenance
Related MCP Connectors
Live browser debugging for AI assistants — DOM, console, network via MCP.
Automate 1,000+ services from any MCP-compatible AI agent: build Applets, run actions and queries.
Web scraping, browser automation, screenshots and AI data extraction for AI agents via MCP.
A paid remote MCP for AI agent browser DevTools MCP, built to return verdicts, receipts, usage logs,
Related MCP Servers
- AlicenseBqualityCmaintenanceEnables AI assistants to automate WeChat Developer Tools for mini programs, allowing navigation, inspection, and manipulation of pages and components through the miniprogram-automator API.2770 npm174MIT
- AlicenseAqualityCmaintenanceMCP server for WeChat Mini Program debugging and automation, enabling agents to perform UI operations, screenshots, and regression testing through natural language commands.44107 npm23MIT
- AlicenseBqualityCmaintenanceEnables automated testing of WeChat mini-programs via Model Context Protocol, providing tools for connecting to WeChat Developer Tools, querying and interacting with page elements, making assertions, navigating, and debugging.2032 npm78MIT
- -licenseNot gradedqualityNot gradedmaintenanceEnables AI agents to debug and control WeChat Mini Programs through WeChat DevTools, including direct automator operations and CLI-backed features like screenshots, logs, previews, and uploads.-