Skip to main content
Glama
wmpf-mcp
by 852764

wmpf-mcp

wmpf-mcp is a dependency-free MCP stdio server for AI-assisted debugging of Windows WeChat Mini Programs through WMPFDebugger.

It connects to the CDP WebSocket exposed by WMPFDebugger, normally ws://127.0.0.1:62000, and exposes MCP tools for JavaScript evaluation, script inspection, breakpoints, debugger control, and network inspection.

Requirements

  • Windows WeChat and WMPFDebugger running successfully.

  • Node.js >=22 for the built-in WebSocket implementation.

  • A mini program that you own or are authorized to inspect.

Related MCP server: Excel WebView2 MCP

Quick Start

node .\src\server.js

Use a different local WebSocket URL with either option:

node .\src\server.js --ws ws://127.0.0.1:62000
$env:WMPF_CDP_WS="ws://127.0.0.1:62000"
node .\src\server.js

MCP Client Config

{
  "mcpServers": {
    "wmpf": {
      "command": "node",
      "args": [
        "C:\\path\\to\\wmpf-mcp\\src\\server.js"
      ],
      "env": {
        "WMPF_CDP_WS": "ws://127.0.0.1:62000"
      }
    }
  }
}

Tools

  • connect: Connect to the WMPFDebugger CDP WebSocket.

  • status: Show connection, cache, pause, and CDP domain status.

  • runtime_evaluate: Evaluate JavaScript through Runtime.evaluate.

  • cdp_call: Call a raw Chrome DevTools Protocol method.

  • list_scripts: List scripts observed from Debugger.scriptParsed.

  • get_script_source: Read source for a CDP scriptId.

  • search_scripts: Search loaded script sources by text or regular expression.

  • set_breakpoint_by_url: Set a breakpoint using a URL regex.

  • debugger_control: Pause, resume, step over, step into, or step out.

  • list_network_requests: List cached requests with sensitive data redacted by default.

  • get_response_body: Read a response body by CDP requestId.

  • last_events: Show recent raw CDP events for compatibility diagnostics.

Example network query:

{
  "limit": 100,
  "include_sensitive": false
}

Set include_sensitive to true only when the debugging task requires original authorization headers, cookies, or request bodies.

Security

  • WebSocket connections are restricted to localhost, 127.0.0.1, and ::1 by default.

  • Set WMPF_ALLOW_REMOTE=1 only when you intentionally need a remote debugger.

  • WebSocket URLs containing embedded credentials are rejected.

  • Authorization headers, cookies, and request bodies are redacted by default.

  • runtime_evaluate and cdp_call can execute code or mutate debugger state.

Configuration

Variable

Default

Description

WMPF_CDP_WS

ws://127.0.0.1:62000

Default debugger WebSocket URL.

WMPF_CDP_TIMEOUT_MS

10000

CDP connection and request timeout.

WMPF_MAX_SCRIPT_CACHE

2000

Maximum cached script metadata entries.

WMPF_MAX_NETWORK_CACHE

1000

Maximum cached network entries.

WMPF_MAX_EVENT_CACHE

200

Maximum recent CDP events.

WMPF_ALLOW_REMOTE

unset

Set to 1 to allow non-local WebSocket hosts.

Invalid numeric configuration values fall back to their safe defaults.

Development

npm run check
npm test

WMPFDebugger may not implement every CDP method exactly like a full Chrome browser. Use cdp_call and last_events to diagnose protocol compatibility issues.

AI 调试优化

v0.2.0 增加了一组更适合 AI 直接操作的小程序调试工具:

断点 / 单步

  • search_scripts: 在已加载脚本里按文本或正则搜索,可返回上下文。

  • set_breakpoint_on_text: 搜索匹配文本并直接打断点,适合让 AI 用函数名、接口名、关键变量名定位。

  • set_breakpoint_by_script_id: 已知 scriptId 和行号时精确打断点。

  • list_breakpoints / remove_breakpoint: 查看和移除本次 MCP 会话设置的断点。

  • paused_info: 断住后获取命中断点、调用栈和 callFrameId。

  • evaluate_on_callframe: 在暂停栈帧里执行表达式,查看局部变量、参数、this 等。

推荐流程:

{ "query": "functionNameOrApiKeyword", "filter": "appservice", "context_lines": 2 }
{ "query": "functionNameOrApiKeyword", "filter": "appservice", "occurrence": 1 }

断住后:

{ "include_scopes": true }
{ "call_frame_id": "CALL_FRAME_ID", "expression": "JSON.stringify({ arg0, thisKeys: Object.keys(this || {}) })" }

抓包 / HAR

  • network_capture_control: 开始、停止或清空网络抓包缓存。

  • list_network_requests: 按 URL、正则、method、status、type、mime、failed 过滤请求。

  • get_request_detail: 查看单个请求,可同时拉响应体。

  • export_network_har: 导出当前缓存为 HAR-like JSON,方便交给 AI 汇总接口行为。

推荐流程:

{ "action": "start", "clear": true, "disable_cache": true }

复现小程序操作后:

{ "url_filter": "/api/", "limit": 100, "include_sensitive": false }

再查看单条响应:

{ "request_id": "REQUEST_ID", "include_body": true, "include_sensitive": false }

Available Tools

21 tools
cdp_callC

Call any raw Chrome DevTools Protocol method.

Inputs: method (required), params, timeout_ms.

connectA

Connect to WMPFDebugger CDP WebSocket, default ws://127.0.0.1:62000.

Inputs: ws_url.

debugger_controlB

Control debugger execution: pause, resume, step_over, step_into, or step_out.

Inputs: action (required).

evaluate_on_callframeC

Evaluate an expression in a paused call frame to inspect local variables.

Inputs: expression (required), call_frame_id (required), silent, timeout_ms, +1 more.

export_network_harC

Export cached network requests as HAR-like JSON.

Inputs: limit, url_filter, include_sensitive.

get_request_detailC

Get one network request with optional response body.

Inputs: request_id (required), max_length, include_body, include_sensitive.

get_response_bodyC

Get response body for a Network requestId through Network.getResponseBody.

Inputs: request_id (required), max_length.

get_script_sourceC

Get JavaScript source for a Debugger scriptId.

Inputs: script_id (required), max_length.

last_eventsB

Show recent raw CDP events for troubleshooting protocol compatibility.

Inputs: limit.

list_breakpointsB

List breakpoints set through this MCP session.

Inputs: no named parameters.

list_network_requestsC

List cached Network requests observed since connection.

Inputs: type, limit, failed, method, +5 more.

list_scriptsA

List scripts observed from Debugger.scriptParsed events.

Inputs: filter.

network_capture_controlC

Start, stop, or clear CDP Network capture cache.

Inputs: action (required), clear, disable_cache.

paused_infoC

Show pause reason, hit breakpoints, call frames, and callFrameIds.

Inputs: include_scopes.

remove_breakpointC

Remove a breakpoint by CDP breakpointId.

Inputs: breakpoint_id (required).

runtime_evaluateC

Evaluate JavaScript in the mini program runtime through CDP Runtime.evaluate.

Inputs: expression (required), context_id, timeout_ms, await_promise, +1 more.

search_scriptsB

Search cached script sources by text or regular expression.

Inputs: query (required), regex, filter, max_results, +2 more.

set_breakpoint_by_script_idC

Set a breakpoint by CDP scriptId and zero-based line/column.

Inputs: script_id (required), line_number (required), condition, column_number.

set_breakpoint_by_urlC

Set a breakpoint by URL regex and zero-based line/column.

Inputs: url_regex (required), line_number (required), condition, column_number.

set_breakpoint_on_textC

Search loaded scripts and set a breakpoint at matching text/regex. Best for AI-driven debugging.

Inputs: query (required), regex, filter, condition, +2 more.

statusB

Show current WMPF CDP connection status and cached debug state.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 21 tools

    Disambiguation5/5

    Tools are clearly distinct: breakpoint setting is split by target (text, URL, scriptId), network tools separate control from inspection, and debugging actions are compartmentalized. No overlapping purposes.

    Naming Consistency5/5

    All tool names follow a consistent snake_case pattern, predominantly verb_noun or verb_preposition_noun (e.g., set_breakpoint_on_text, list_network_requests). Even single-word names like status and connect fit the overall style.

    Tool Count4/5

    21 tools is appropriate for a debugging and inspection server covering breakpoints, scripts, network, and raw CDP. It is slightly above a typical minimal set but remains well-scoped without being excessive.

    Completeness3/5

    The tool surface covers core debugging and network inspection, but lacks features like conditional breakpoints, breakpoint enable/disable, watch expressions, or a disconnect tool. These gaps may require agents to work around.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI coding assistants to debug and analyze WeChat MiniApp JavaScript code via Chrome DevTools Protocol. Supports network interception, breakpoint debugging, script analysis, and runtime inspection for reverse engineering purposes.
      19
      261
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Connects Claude Code to Microsoft Excel add-ins via the Chrome DevTools Protocol, enabling inspection, automation, and lifecycle management of add-ins running in WebView2.
      60 npm
      2
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Connects to Obsidian's Electron process via Chrome DevTools Protocol, enabling AI assistants to screenshot, execute JavaScript, capture console logs, and automate UI actions for debugging plugins and testing layouts.
      ISC
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables dynamic reverse engineering and debugging of WeChat MiniProgram JavaScript through the Chrome DevTools Protocol, letting AI agents enumerate and search scripts, set breakpoints, step through paused frames, trace function calls, hook miniprogram APIs such as wx.request, and capture network requests to analyze encryption, signing, and anti-scraping logic. It also works against Chrome, Node.js, and Electron runtimes, with tools for extracting code bundles and page business logic.
      1
      Apache 2.0