A privacy-first MCP server for controlling WeChat Mini Program DevTools from AI coding agents.
WeApp DevTools MCP connects an MCP client to a local WeChat Mini Program DevTools automation endpoint. It lets an agent navigate pages, inspect elements, collect logs, capture screenshots, monitor network requests, mock wx APIs, run local scripts, and call the official DevTools CLI without a hosted relay service.
- Control Mini Program pages through local WeChat DevTools automation.
- Navigate, tap, input, inspect elements, read page/component data, capture screenshots, and create compact page snapshots.
- Collect console logs and local network traffic from
wx.request,wx.uploadFile, andwx.downloadFile. - Mock and restore
wxAPIs, run Mini Program runtime evaluation, and call the local DevTools CLI when explicitly enabled. - Choose the tool surface with
WEAPP_TOOLS_PROFILE, category switches, and per-tool allow/deny lists. - Redact sensitive output by default, including tokens, tickets, cookies, sessions, phone numbers, email addresses, and local home paths.
- Save screenshots to local temp files by default instead of returning inline images.
- Require explicit consent for high-risk capabilities through per-call
riskConsentorWEAPP_ALLOW_*switches. - Patch vulnerable transitive dependency versions through npm
overrides. - Works with any MCP client that supports stdio servers.
- Node.js 18 or newer.
- WeChat Mini Program DevTools.
- A Mini Program project that can open in DevTools.
- DevTools security settings enabled:
- HTTP debugging
- Automation testing
macOS:
/Applications/wechatwebdevtools.app/Contents/MacOS/cli auto \
--project /path/to/your/project \
--auto-port 9420Windows:
"C:\Program Files (x86)\Tencent\微信web开发者工具\cli.bat" auto --project C:\path\to\your\project --auto-port 9420Use directly from GitHub:
{
"mcpServers": {
"weapp-dev": {
"command": "npx",
"args": ["-y", "github:Mileson/weapp-devtools-mcp"],
"env": {
"WEAPP_WS_ENDPOINT": "ws://localhost:9420"
}
}
}
}Local development:
git clone https://github.com/Mileson/weapp-devtools-mcp.git
cd weapp-devtools-mcp
npm ci
npm run build
WEAPP_WS_ENDPOINT=ws://localhost:9420 node dist/index.jsApplication tools:
mp_ensureConnection: verify the automation session and current page.mp_navigate: navigate withnavigateTo,redirectTo,reLaunch,switchTab, ornavigateBack.mp_screenshot: capture the current viewport. Saves locally by default.mp_callWx: call Mini Programwxmethods; high-risk methods requireriskConsentor an allow switch.mp_getLogs: read captured console logs.mp_currentPage: inspect current route, query, size, scroll position, and optional data.mp_listProjects: list recent projects discovered from local DevTools data.mp_setDefaultProject: store a default local project path.
Page tools:
page_snapshot,page_getElement,page_getElements,page_waitElement,page_waitTimeoutpage_getData,page_setData,page_callMethod
Element tools:
element_tap,element_input,element_callMethodelement_getData,element_setDataelement_getInnerElement,element_getInnerElementselement_getWxml,element_getStyleselement_scrollTo,element_getAttributes,element_getBoundingClientRect
Network and debugging tools:
mp_startNetwork,mp_stopNetwork,mp_getNetworkRequests,mp_getNetworkRequest,mp_clearNetworkRequestsassert_element: assert existence, text, value, attributes, and visibility by selector.mp_toolConfig: inspect the active tool profile and high-risk capability switches.
Runtime and CLI tools:
mp_evaluate: run a function in the Mini Program runtime.mp_mockWx,mp_restoreWx: mock or restorewxmethods.mp_runCli: run the local WeChat DevTools CLI without shell expansion.
The server is designed to avoid accidental data leakage in agent transcripts:
- Text and JSON outputs are redacted by default.
element_inputdoes not echo typed values.- Screenshots are saved to local temp files unless inline screenshots are explicitly enabled.
- High-risk
wx, evaluate, mock, and CLI capabilities require per-call consent or explicit environment switches. - DevTools launch logs redact account and ticket arguments.
- Local MCP config is written with
0600permissions.
For the full model and escape hatches, see docs/SECURITY_MODEL.md.
Connection:
WEAPP_WS_ENDPOINT: WebSocket endpoint for a running DevTools automation service. Recommended:ws://localhost:9420.WEAPP_AUTOMATOR_MODE:connectorlaunch.WEAPP_PROJECT_PATH: Mini Program project path.WECHAT_DEVTOOLS_CLI_PATH: DevTools CLI path.WEAPP_DEVTOOLS_PORT: preferred automation port.WEAPP_AUTOLAUNCH: set totrueto launch DevTools automatically.WEAPP_DEVTOOLS_TIMEOUT,WEAPP_LAUNCH_TIMEOUT,WEAPP_CONNECT_TIMEOUT: timeout controls.
Privacy:
WEAPP_ALLOW_INLINE_SCREENSHOT=true: allow inline image responses.WEAPP_ALLOW_HIGH_RISK_WX=true: allow high-riskwxcalls.WEAPP_ALLOWED_WX_METHODS=login,request: allow selected high-riskwxmethods.WEAPP_BLOCKED_WX_METHODS=requestPayment: always block selectedwxmethods.WEAPP_ALLOW_RISKY_TOOLS=true: allow all high-risk local-only tools.WEAPP_ALLOW_EVALUATE=true: allowmp_evaluate.WEAPP_ALLOW_MOCK_WX=true: allowmp_mockWxandmp_restoreWx.WEAPP_ALLOW_CLI_COMMANDS=true: allowmp_runCli.WEAPP_ALLOW_SENSITIVE_OUTPUT=true: disable output redaction.WEAPP_MASK_INPUT_VALUES=false: allowelement_inputto echo typed values.WEAPP_MAX_OUTPUT_CHARS,WEAPP_MAX_STRING_CHARS,WEAPP_MAX_ARRAY_ITEMS,WEAPP_MAX_OBJECT_KEYS: output size limits.
Tool surface:
WEAPP_TOOLS_PROFILE:full(default),core, orminimal.WEAPP_ENABLE_TOOL_CATEGORIES,WEAPP_DISABLE_TOOL_CATEGORIES: comma-separated categories such asnetwork,cli,experimental.WEAPP_ENABLE_TOOLS,WEAPP_DISABLE_TOOLS: comma-separated tool names.WEAPP_ENABLE_NETWORK_MONITORING=false: disable automatic network interception.WEAPP_MAX_NETWORK_LOGS: network log retention limit.
src/
config.ts Environment and per-call connection config
index.ts MCP server entry
security.ts Redaction, limits, and high-risk method policy
toolProfile.ts Tool profile and category filtering
weappClient.ts DevTools automation session manager
tools/ MCP tool definitions
docs/
SECURITY_MODEL.md Privacy and security model
releases/ Release notes
npm ci
npm run build
npm audit --omit=devSee CONTRIBUTING.md.
Please do not open public issues for suspected security problems. See SECURITY.md.
MIT. See LICENSE and THIRD_PARTY_NOTICES.md.