| name | wechat-devtools-mcp |
| description | WeChat Mini Program development automation via MCP - IDE control, debugging, testing, and deployment workflows |
| triggers | ["debug the WeChat mini program","preview the mini program QR code","check console errors in the WeChat IDE","upload this mini program to WeChat","test all pages for errors","take a screenshot of the current page","navigate to the login page and check logs","mock the WeChat payment API"] |
wechat-devtools-mcp
Skill by ara.so โ Devtools Skills collection.
Overview
wechat-devtools-mcp wraps the WeChat Developer Tools CLI as an MCP (Model Context Protocol) server, enabling AI coding agents to control the WeChat IDE programmatically. It provides 7 aggregated tools covering the full mini program lifecycle: IDE management, build/deploy, automated testing, debugging, screenshots, and file operations.
Architecture: Thin MCP (7 tools) + Fat Skill (SOPs, parameter references, guardrails). The Skill is required โ without it, AI agents cannot execute standard workflows correctly.
Platform: Cross-platform (Windows/macOS). Published to official MCP Registry.
Installation
1. Install MCP Server
pip install uv
uv tool install wechat-devtools-mcp --force
Upgrade:
taskkill /F /IM "wechat-devtools-mcp*" 2>/dev/null
uv tool upgrade wechat-devtools-mcp
2. Enable WeChat IDE Service Port
Critical: Open WeChat Developer Tools โ Settings โ Security โ Service Port โ Enable.
Verify with wechat_ide(action='status') โ connection failure means the port is disabled.
3. Configure MCP Client
Claude Desktop / Antigravity (claude_desktop_config.json):
{
"mcpServers": {
"wechat-devtools": {
"command": "uvx",
"args": ["wechat-devtools-mcp"],
"env": {
"WECHAT_DEVTOOLS_CLI": "C:\\Program Files (x86)\\Tencent\\ๅพฎไฟกwebๅผๅ่
ๅทฅๅ
ท\\cli.bat",
"WECHAT_PROJECT_PATH": "D:\\Projects\\my-miniapp"
}
}
}
}
macOS (Claude Code .mcp.json in project root):
{
"mcpServers": {
"wechat-devtools": {
"command": "/opt/homebrew/bin/uvx",
"args": ["wechat-devtools-mcp"],
"env": {
"PATH": "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin",
"WECHAT_DEVTOOLS_CLI": "/Applications/wechatwebdevtools.app/Contents/MacOS/cli",
"WECHAT_PROJECT_PATH": "/Users/you/Projects/my-miniapp",
"NODE_PATH": "/opt/homebrew/bin/node"
}
}
}
}
Environment Variables:
WECHAT_DEVTOOLS_CLI: Absolute path to CLI (cli.bat on Windows, cli on macOS)
WECHAT_PROJECT_PATH: Absolute path to mini program project root
- Windows: Escape backslashes (
\\), macOS: Use forward slashes
4. Install Skill (Required)
Claude Code:
npx -y skills add WaterTian/wechat-devtools-mcp/.agents/skills/wechat-devtools
Other clients (place in .agents/skills/):
git clone --depth 1 https://github.com/WaterTian/wechat-devtools-mcp.git .wdm-tmp
mkdir -p .agents/skills
cp -r .wdm-tmp/.agents/skills/wechat-devtools .agents/skills/
rm -rf .wdm-tmp
Result:
project/
โโโ .agents/skills/
โโโ wechat-devtools/
โโโ SKILL.md # Main SOPs + capability map
โโโ references/
โโโ tool_reference.md # Full API parameter docs
Core Tools
1. wechat_ide โ IDE Lifecycle
Actions: open, login, is_login, close, quit, status
wechat_ide(action='open')
wechat_ide(action='is_login')
wechat_ide(action='status')
wechat_ide(action='close')
wechat_ide(action='quit')
Key patterns:
- Always call
status first to verify IDE connectivity
open is idempotent โ won't fail if already open
- Use
close between test sessions, quit only when necessary
2. wechat_build โ Build & Deploy
Actions: compile, preview, upload, build_npm, cache_clean
wechat_build(action='compile')
result = wechat_build(
action='preview',
extra_args={
'qr_format': 'terminal',
'qr_output': '/tmp/qr.png',
'compile_condition': '{"pathName":"pages/index/index"}'
}
)
wechat_build(
action='upload',
extra_args={
'version': '1.0.0',
'desc': 'Initial release'
}
)
wechat_build(action='build_npm')
wechat_build(action='cache_clean')
QR formats:
terminal: ASCII art in console
image: Save to qr_output path
base64: Data URI string
3. wechat_automator โ Automated Testing
Actions: start, tap, input, element_info, set_data, call_method, call_wx, mock_wx, evaluate, page_stack, page_data, system_info, storage
wechat_automator(action='start')
wechat_automator(
action='tap',
extra_args={
'selector': '.login-btn',
'wait_for': 2000
}
)
wechat_automator(
action='input',
extra_args={
'selector': 'input.username',
'text': 'testuser'
}
)
wechat_automator(
action='element_info',
extra_args={'selector': '.status-text'}
)
wechat_automator(
action='mock_wx',
extra_args={
'api': 'request',
'result': 'success',
'data': '{"code": 200, "data": {"user": "mock"}}'
}
)
wechat_automator(action='page_data')
wechat_automator(
action='evaluate',
extra_args={'code': 'getCurrentPages()[0].data.userInfo'}
)
Selector syntax:
.class-name โ Class selector
#id โ ID selector
view.item[data-id="123"] โ Attribute selector
- Use
>>> for shadow DOM: custom-component >>> .inner-element
4. wechat_inspector โ Runtime Logs
Actions: console, cdp
logs = wechat_inspector(
action='console',
extra_args={'duration': 10}
)
cdp_logs = wechat_inspector(
action='cdp',
extra_args={
'duration': 5,
'events': ['Network.requestWillBeSent', 'Runtime.consoleAPICalled']
}
)
Use cases:
- Detect runtime errors before they crash
- Monitor network requests during user flow
- Capture console.log/warn/error for debugging
5. wechat_screenshot โ Visual Testing
wechat_screenshot(extra_args={'full_page': True})
wechat_screenshot(extra_args={
'selector': '.product-list',
'full_page': False
})
Returns base64-encoded PNG. For long pages, automatically stitches scrolling captures.
6. wechat_navigate โ Navigation + Log Capture
wechat_navigate(extra_args={
'page': 'pages/detail/detail',
'query': 'id=123',
'log_duration': 3
})
Combines wx.navigateTo() + wechat_inspector(cdp) in one call.
7. wechat_file โ Project Introspection
Actions: project_info, list_pages, read_page, read_file
wechat_file(action='project_info')
wechat_file(action='list_pages')
wechat_file(
action='read_page',
extra_args={'page_path': 'pages/index/index'}
)
wechat_file(
action='read_file',
extra_args={'file_path': 'utils/request.js'}
)
Standard Operating Procedures (SOPs)
SOP A: Initial Setup Verification
wechat_ide(status) โ Verify IDE connectivity
wechat_file(project_info) โ Confirm project loaded
wechat_ide(is_login) โ Check login status
- If not logged in:
wechat_ide(login) and wait for user scan
SOP B: UI Debugging Workflow
wechat_automator(start) โ Begin session
wechat_navigate(page='target/page', log_duration=3)
wechat_screenshot(full_page=True) โ Capture UI state
wechat_inspector(console, duration=5) โ Check for errors
wechat_automator(page_data) โ Inspect data bindings
SOP C: Error Investigation
wechat_inspector(console, duration=10) โ Capture logs
wechat_automator(page_stack) โ Check navigation state
wechat_file(read_page, page_path=<current>) โ Review source
wechat_automator(evaluate, code='getApp().globalData') โ Check global state
SOP D: Full Page Health Check
pages = wechat_file(action='list_pages')
for page in pages['pages']:
wechat_navigate(extra_args={'page': page, 'log_duration': 2})
logs = wechat_inspector(action='console', extra_args={'duration': 2})
if 'error' in logs.lower():
print(f"โ {page}: {logs}")
else:
print(f"โ
{page}: OK")
SOP E: Mock-Based Integration Test
wechat_automator(start)
wechat_automator(mock_wx, api='request', result='success', data=<mock_json>)
wechat_automator(tap, selector='.trigger-request-btn')
wechat_inspector(console, duration=3) โ Verify mock response handling
wechat_automator(page_data) โ Check UI updated correctly
SOP F: Deployment Workflow
wechat_build(cache_clean) โ Fresh build
wechat_build(compile) โ Check for errors
- If errors: Stop and report
wechat_build(preview) โ Generate test QR
- User scans and validates
wechat_build(upload, version=<semver>, desc=<changelog>)
SOP G: Page Parameter Discovery
source = wechat_file(action='read_page', extra_args={'page_path': 'pages/detail/detail'})
Configuration Patterns
Multi-Project Setup
For multiple mini programs, create project-specific .mcp.json:
{
"mcpServers": {
"wechat-shop": {
"command": "uvx",
"args": ["wechat-devtools-mcp"],
"env": {
"WECHAT_DEVTOOLS_CLI": "C:\\...\\cli.bat",
"WECHAT_PROJECT_PATH": "D:\\Projects\\shop-miniapp"
}
},
"wechat-admin": {
"command": "uvx",
"args": ["wechat-devtools-mcp"],
"env": {
"WECHAT_DEVTOOLS_CLI": "C:\\...\\cli.bat",
"WECHAT_PROJECT_PATH": "D:\\Projects\\admin-miniapp"
}
}
}
}
Switch projects by calling the corresponding server's tools.
Custom Compile Conditions
wechat_build(
action='preview',
extra_args={
'compile_condition': json.dumps({
'pathName': 'pages/cart/cart',
'query': 'from=share&id=456',
'scene': 1007
})
}
)
Troubleshooting
"Connection refused" on all commands
Cause: Service port not enabled in IDE.
Fix: Settings โ Security โ Service Port โ Enable. Restart IDE.
wechat_automator commands timeout
Cause: Page not fully loaded or selector invalid.
Fix:
- Add
wait_for delay: {'selector': '.btn', 'wait_for': 2000}
- Verify selector with
wechat_automator(element_info)
- Check page stack:
wechat_automator(page_stack)
Preview QR not generating
Cause: Compilation errors or missing qr_format.
Fix:
- Run
wechat_build(compile) first
- Specify
qr_format: 'terminal', 'image', or 'base64'
- For
image, provide qr_output absolute path
Screenshots are blank
Cause: Page render incomplete or IDE minimized.
Fix:
- Add 2-3s delay before screenshot:
wechat_navigate() then wait
- Ensure IDE window is visible (not minimized)
- Check if
selector exists: wechat_automator(element_info)
Mock not working
Cause: API name typo or wrong mock timing.
Fix:
- Use exact API name:
request, getStorage, showToast (case-sensitive)
- Call
mock_wx before triggering the API
- Verify with
wechat_inspector(console) to see actual API calls
File operations return "not found"
Cause: Incorrect path format or file outside project.
Fix:
- Use forward slashes:
pages/index/index
- No leading slash:
utils/api.js not /utils/api.js
- Path relative to
WECHAT_PROJECT_PATH root
Best Practices
- Always start with
status: Verify IDE connectivity before workflows
- Log everything: Capture console/CDP logs before and after critical operations
- Use
close not quit: Preserve IDE state between test runs
- Mock early: Set up
mock_wx before navigating to pages
- Screenshot + logs: Combine visual + text evidence for bug reports
- Clean cache on errors: Run
cache_clean + compile if builds behave oddly
- Version everything: Use semantic versioning in
upload action
- Test preview first: Never
upload without validating via preview QR
- Read source before mocking: Use
read_page to understand data flow
- Automate health checks: Run SOP D daily to catch regressions early
Integration with Other MCPs
- CloudBase MCP: Use for cloud functions/database (replaces deprecated
wechat_cloud)
- Chrome DevTools MCP: Cross-reference CDP logs for H5 pages
- File system MCP: Batch edit mini program source files
Example: Complete Bug Fix Workflow
status = wechat_ide(action='status')
assert status['connected']
wechat_navigate(extra_args={
'page': 'pages/order/order',
'query': 'id=789',
'log_duration': 5
})
screenshot_before = wechat_screenshot(extra_args={'full_page': True})
logs_before = wechat_inspector(action='console', extra_args={'duration': 3})
source = wechat_file(action='read_page', extra_args={'page_path': 'pages/order/order'})
wechat_build(action='compile')
wechat_navigate(extra_args={'page': 'pages/order/order', 'query': 'id=789'})
screenshot_after = wechat_screenshot(extra_args={'full_page': True})
logs_after = wechat_inspector(action='console', extra_args={'duration': 3})
assert 'error' not in logs_after.lower()
wechat_build(action='preview', extra_args={'qr_format': 'terminal'})
wechat_build(action='upload', extra_args={'version': '1.0.1', 'desc': 'Fix order page crash'})
Version Compatibility
- MCP Server: v0.9.7+
- WeChat DevTools: 1.06.2302270+ (stable channel)
- Python: 3.8+ (automatically managed by
uv)
- Node.js: 14+ (for
npx skills command)
Check current MCP version: wechat_ide(action='status')['mcp_version']
Additional Resources