Skip to main content
Glama

MiniApp CDP MCP

English | Chinese

WeChat MiniApp reverse engineering MCP server, allowing your AI coding assistant (such as Claude, Cursor, Antigravity) to directly debug and analyze JavaScript code in WeChat MiniApps (including WeChat DevTools or PC WeChat MiniApps) via the Chrome DevTools Protocol (CDP).

Features

  • Multi-target Debugging: Seamlessly switch between AppService (logic layer) and WebView (rendering layer) targets.

  • Network Interception: Capture, monitor, and filter XHR/Fetch requests initiated by the MiniApp.

  • Breakpoint Debugging: Set/remove code breakpoints and XHR breakpoints, with support for precise positioning in minified/obfuscated code.

  • Execution Control: Pause/resume execution, step debugging (over/into/out), and return source code context.

  • Script Analysis: List all loaded JS scripts, search code, and retrieve/save source code.

  • Runtime Inspection: Evaluate expressions at breakpoints, and inspect call stacks and scope variables.

  • WebSocket Analysis: Monitor WebSocket connections and message patterns.

Related MCP server: JS Reverse MCP

System Requirements

  • Python 3.11 or newer

  • uv (Required, ultra-fast Python package and environment manager)

  • Running WeChat DevTools (with debug port enabled) or PC WeChat MiniApp (with remote debugging mechanism enabled)

Prerequisite 1: Enable MiniApp Debug Port

Before using this MCP, you need to expose the WeChat MiniApp's CDP debug port using an injection tool. Depending on your OS and WeChat version, you can choose one of the following open-source tools to perform the Hook and port exposure (usually exposed on port 62000):

Prerequisite 2: Install uv

This project achieves zero-configuration "out-of-the-box" usage via uvx. If you haven't installed uv yet, please execute the following command based on your system:

macOS / Linux:

curl -LsSf https://astral.sh/uv/install.sh | sh

Windows:

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Quick Start (uvx zero-install)

No need to clone the code locally; you can directly leverage uv's capabilities by adding the following to your AI assistant's MCP configuration file:

{
  "mcpServers": {
    "miniapp-cdp": {
      "command": "uvx",
      "args": ["--from", "miniapp-cdp", "miniapp-cdp-mcp"]
    }
  }
}

Claude Desktop

Modify ~/Library/Application Support/Claude/claude_desktop_config.json and add the configuration above.

Cursor

Go to Cursor Settings -> Features -> MCP -> Add new MCP server:

  • Type: command

  • Name: miniapp-cdp

  • Command: uvx --from miniapp-cdp miniapp-cdp-mcp

Local Installation (Optional)

If you want to modify or develop locally:

git clone https://github.com/yourusername/miniapp-cdp-py.git
cd miniapp-cdp-py
uv sync

Then use the local execution method in your MCP configuration:

{
  "mcpServers": {
    "miniapp-cdp": {
      "command": "uv",
      "args": ["run", "run_mcp_server.py"],
      "cwd": "/你的路径/miniapp-cdp-py"
    }
  }
}

Tool List

Target and Context Management

Tool

Description

list_targets

List all available targets in the debugger (AppService thread, WebView thread, etc.)

switch_target

Switch CDP connection to a different target thread for debugging context switching

Network and WebSocket

Tool

Description

list_network_requests

List MiniApp network requests (supports pagination), or get details for a single request

get_request_initiator

Get the JavaScript call stack that initiated the network request

get_response_body

Get the full response body of a network request

get_websocket_messages

List WebSocket connections or get message details for a specific connection

Script Analysis

Tool

Description

list_scripts

List all JavaScript scripts loaded in the current page

get_script_source

Get script source code snippets, supports line ranges or character offsets

save_script_source

Save the full script source code to a local file (suitable for extracting full packages or core risk control code)

search_in_sources

Search for strings or regular expressions across all scripts

Breakpoints and Execution Control

Tool

Description

set_breakpoint_on_text

Automatically set breakpoints by searching code text (do not set breakpoints directly on anonymous function declarations)

break_on_xhr

Set XHR/Fetch breakpoints by URL pattern

remove_breakpoints

Remove specified breakpoints, or clear all breakpoint environments instantly with clear_all=True

list_breakpoints

List all active breakpoints

get_paused_info

Get pause status, call stack, and scope variables

resume_execution

Release breakpoints and resume code execution

step

Step debugging (over/into/out), returns position and source code context

Inspection Tools

Tool

Description

evaluate_script

Execute JavaScript expressions in the current context (supported while paused at a breakpoint)

Usage Examples

Basic MiniApp Reverse Engineering Workflow

  1. Connection and Target Switching

列出所有小程序目标,并切换到 AppService (逻辑层) 线程
  1. Finding Target Functions and Code

在所有脚本中搜索包含 "encrypt" 的代码,并获取相关脚本的上下文源码
  1. Setting Breakpoints

在加密函数的具体执行语句(如 return 处)设置断点
  1. Triggering and Analysis

在小程序上点击触发网络请求,断点命中后,检查参数、调用栈以及密钥的生成逻辑

Intercepting and Analyzing Network Requests

抓取最新发出的网络请求列表,并找出特定的加密请求(如带有 mina_edata 参数的请求),
随后获取该请求的发起者调用栈 (Initiator) 定位加密入口。

Practical Cases

The examples/ directory in the project contains some practical scripts derived from reverse engineering using this tool (e.g., vipshop_decrypt_demo.py), demonstrating how to analyze complex multi-layer encryption algorithms of MiniApps via MCP and perfectly restore them in Python.

Security Notice

This tool exposes the underlying runtime context of the MiniApp to the MCP client, allowing for the inspection, debugging, and modification of any data in the application's memory. Do not use this tool for illegal purposes; it is intended solely for personal learning, security research, and legally authorized reverse engineering analysis.

Acknowledgments

This project is built on cdp-use. cdp-use provides a low-level WebSocket interaction layer that is highly optimized and abstracted for Agent scenarios, greatly simplifying the communication complexity of the raw CDP protocol.

License

MIT License

Available Tools

19 tools
break_on_xhrA

Sets a breakpoint that triggers when an XHR/Fetch request URL contains the specified string.

Inputs: url (required). Returns: result

evaluate_scriptC

Evaluates a JavaScript expression in the current context. If execution is paused, it automatically evaluates in the paused call frame context.

Inputs: expression (required), return_by_value, await_promise, context_id, +1 more. Returns: result

get_paused_infoA

Gets information about the current paused state including call stack, current location, and scope variables. Use this after a breakpoint is hit to understand the execution context.

Inputs: include_scopes, max_scope_depth, frame_index. Returns: result

get_request_initiatorB

Gets the JavaScript call stack that initiated a network request. This helps trace which code triggered an API call.

Inputs: request_id (required). Returns: result

get_response_bodyA

Get the response body for a request returned by list_network_requests. If session_id is omitted, it is inferred from the monitored request cache.

Inputs: request_id (required), session_id. Returns: result

get_script_sourceB

Gets a snippet of a JavaScript script source by URL (recommended) or script ID. Supports line range (for normal files) or character offset (for minified single-line files).

Inputs: script_id, url, start_line, end_line, +2 more. Returns: result

get_websocket_messagesB

Lists WebSocket connections or gets messages for a specific connection. Without wsid, lists all connections. With wsid, gets messages.

Inputs: wsid, direction, show_content, page_size, +1 more. Returns: result

list_breakpointsB

Lists all active XHR and code breakpoints.

Inputs: no named parameters. Returns: result

list_network_requestsA

List network requests for the currently selected miniapp target/session since MCP started monitoring it. Results are sorted newest-first. By default returns the 20 most recent requests; use page_size/page_idx to paginate. Pass reqid to get a single request's full details. On first call it automatically connects to the endpoint, infers the target, attaches only that target, enables Network on that target session, and starts collecting XHR/Fetch requests.

Inputs: endpoint, reqid, page_size, page_idx, +5 more. Returns: result

list_scriptsA

Lists all JavaScript scripts loaded in the current page. Returns script ID, URL, and source map information. Use this to find scripts before setting breakpoints or searching.

Inputs: url_filter. Returns: result

list_targetsB

Lists all available targets (WebView threads, AppService threads, etc.) in the connected debugger.

Inputs: no named parameters. Returns: result

pause_or_resumeB

Toggles JavaScript execution. If paused, resumes execution. If running, pauses execution.

Inputs: no named parameters. Returns: result

remove_breakpointB

Removes a breakpoint by its ID.

Inputs: breakpoint_id (required). Returns: result

remove_xhr_breakpointC

Removes an XHR/Fetch breakpoint.

Inputs: url (required). Returns: result

save_script_sourceC

Saves the full source code of a JavaScript script to a local file.

Inputs: file_path (required), script_id, url. Returns: result

search_in_sourcesB

Searches for a string or regex pattern in all loaded JavaScript sources. Returns matching lines with script ID, URL, and line number.

Inputs: query (required), case_sensitive, is_regex, max_results, +3 more. Returns: result

set_breakpoint_on_textA

Finds a text string in all loaded scripts and sets a breakpoint at that location. CRITICAL AI WORKFLOW WARNING: Do NOT set breakpoints on function names or assignment statements (e.g., 'funcName = function'). In minified code, this will break on the one-time assignment rather than the execution. Instead, ALWAYS use get_script_source to read the function body first, then set the breakpoint on a specific statement INSIDE the function body (e.g., 'var x=', 'return').

Inputs: text (required), case_sensitive, condition. Returns: result

stepB

Controls execution when paused. action must be one of: 'over', 'into', 'out'.

Inputs: action (required). Returns: result

switch_targetB

Switches the CDP connection to a different target thread (e.g. from WebView to AppService) to debug different parts of the miniapp.

Inputs: target_id (required). Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 19 tools

    Disambiguation4/5

    Most tools have distinct purposes with clear boundaries, such as break_on_xhr for XHR breakpoints versus set_breakpoint_on_text for code breakpoints. However, some overlap exists between list_breakpoints and remove_breakpoint/remove_xhr_breakpoint, as they all manage breakpoints but with different granularities, which could cause minor confusion in selection.

    Naming Consistency5/5

    Tool names follow a highly consistent verb_noun or verb_noun_noun pattern throughout, such as list_network_requests, get_paused_info, and remove_xhr_breakpoint. There are no deviations in style or convention, making the set predictable and easy to navigate.

    Tool Count4/5

    With 19 tools, the count is slightly high but reasonable for a comprehensive debugging and monitoring server for miniapps. It covers various aspects like breakpoints, network requests, and script analysis without feeling excessively bloated, though it might be borderline for some use cases.

    Completeness5/5

    The toolset provides complete coverage for debugging miniapps, including breakpoint management, network monitoring, script inspection, and execution control. There are no obvious gaps; tools like step, pause_or_resume, and switch_target ensure full lifecycle support for debugging workflows.

    Maintenance

    ActivityInactive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to debug JavaScript and TypeScript applications by connecting to Chrome DevTools Protocol-compatible debuggers, allowing them to set breakpoints, step through code, inspect variables, and evaluate expressions with full source map support.
      18
      10 npm
      2
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI coding assistants to debug and analyze JavaScript code in web pages through breakpoint debugging, function hooking, network analysis, and runtime inspection of scripts including minified code.
      24
      1,064 npm
      3,072
      Apache 2.0
    • A
      license
      B
      quality
      D
      maintenance
      Connects to WMPFDebugger's CDP WebSocket to enable AI-assisted debugging of Windows WeChat Mini Programs, providing tools for JavaScript evaluation, script inspection, breakpoints, debugger control, and network inspection.
      21
      1
      MIT
    • 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.
      31 npm
      1
      MIT