MiniApp CDP MCP logo

MiniApp CDP MCP

Community
zhizhuodemao

微信小程序逆向工程 MCP 服务器,让你的 AI 编码助手(如 Claude、Cursor、Antigravity)能够直接通过 Chrome DevTools Protocol (CDP) 调试和分析微信小程序(包括微信开发者工具或 PC 端微信小程序)中的 JavaScript 代码。

Publisherzhizhuodemao
Repositoryminiapp-cdp-mcp
LanguagePython
Forks
40
Stars
213
Available tools
0
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    MiniApp CDP MCP exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    213 stars and 40 forks from the linked repository.

MiniApp CDP MCP

English | 中文

微信小程序逆向工程 MCP 服务器,让你的 AI 编码助手(如 Claude、Cursor、Antigravity)能够直接通过 Chrome DevTools Protocol (CDP) 调试和分析微信小程序(包括微信开发者工具或 PC 端微信小程序)中的 JavaScript 代码。

功能特点

  • 多目标调试: 支持在 AppService(逻辑层)和 WebView(渲染层)目标之间无缝切换
  • 网络拦截: 捕获、监控和过滤由小程序发起的 XHR/Fetch 请求
  • 断点调试: 设置/移除代码断点和 XHR 断点,支持在压缩混淆代码中精确定位
  • 执行控制: 暂停/恢复执行,单步调试(over/into/out)并返回源码上下文
  • 脚本分析: 列出所有加载的 JS 脚本,搜索代码,获取/保存源码
  • 运行时检查: 在断点处求值表达式,检查调用栈和作用域变量
  • WebSocket 分析: 监控 WebSocket 连接和消息模式

系统要求

  • Python 3.11 或更新版本
  • uv (必需,超快的 Python 包和环境管理器)
  • 运行中的微信开发者工具(需开启调试端口)或 PC 版微信小程序(开启远程调试机制)

前置准备 1:开启小程序调试端口

在使用本 MCP 之前,你需要先通过注入工具将微信小程序的 CDP 调试端口暴露出来。你可以根据你的操作系统和微信版本,选择以下开源工具之一来完成 Hook 和端口暴露(通常暴露于 62000 端口):

前置准备 2:安装 uv

本项目通过 uvx 实现零配置的“开箱即用”。如果你还没安装 uv,请先根据你的系统执行以下命令安装:

macOS / Linux:

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

Windows:

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

快速开始(uvx 零安装)

无需把代码克隆到本地,你可以直接利用 uv 的能力,在 AI 助手的 MCP 配置文件中添加:

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

Claude Desktop

修改 ~/Library/Application Support/Claude/claude_desktop_config.json,加入上述配置。

Cursor

进入 Cursor Settings -> Features -> MCP -> Add new MCP server:

  • Type: command
  • Name: miniapp-cdp
  • Command: uvx --from miniapp-cdp miniapp-cdp-mcp

本地安装(可选)

如果你想在本地修改或开发:

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

然后在 MCP 配置中使用本地运行方式:

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

工具列表

目标与上下文管理

工具描述
list_targets列出调试器中所有可用的目标(AppService 线程、WebView 线程等)
switch_target切换 CDP 连接到不同的目标线程进行调试上下文切换

网络与 WebSocket

工具描述
list_network_requests列出小程序网络请求(支持分页),或获取单条详情
get_request_initiator获取发起网络请求的 JavaScript 调用栈
get_response_body获取网络请求的完整响应体
get_websocket_messages列出 WebSocket 连接或获取特定连接的消息详情

脚本分析

工具描述
list_scripts列出当前页面加载的所有 JavaScript 脚本
get_script_source获取脚本源码片段,支持行范围或字符偏移
save_script_source保存完整脚本源码到本地文件(适用于提取整包或核心风控代码)
search_in_sources在所有脚本中搜索字符串或正则表达式

断点与执行控制

工具描述
set_breakpoint_on_text通过搜索代码文本自动设置断点(切勿直接对匿名函数声明下断点)
break_on_xhr按 URL 模式设置 XHR/Fetch 断点
remove_breakpoints移除指定的断点,或通过 clear_all=True 瞬间清空所有断点环境
list_breakpoints列出所有活动断点
get_paused_info获取暂停状态、调用栈和作用域变量
resume_execution释放断点,恢复代码执行
step单步调试(over/into/out),返回位置和源码上下文

检查工具

工具描述
evaluate_script在当前上下文中执行 JavaScript 表达式(支持在断点暂停时执行)

使用示例

小程序逆向工程基本流程

  1. 连接与目标切换
列出所有小程序目标,并切换到 AppService (逻辑层) 线程
  1. 查找目标函数与代码
在所有脚本中搜索包含 "encrypt" 的代码,并获取相关脚本的上下文源码
  1. 设置断点
在加密函数的具体执行语句(如 return 处)设置断点
  1. 触发并分析
在小程序上点击触发网络请求,断点命中后,检查参数、调用栈以及密钥的生成逻辑

拦截并分析网络请求

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

实战案例

在项目的 examples/ 目录下,包含了一些利用本工具逆向得出的实战脚本(例如 vipshop_decrypt_demo.py),展示了如何通过 MCP 分析出小程序的复杂多层加密算法并在 Python 中完美还原。

安全提示

此工具会将小程序的底层运行上下文暴露给 MCP 客户端,允许检查、调试和修改应用内存中的任何数据。请勿将此工具用于非法用途,仅限于个人学习、安全研究与合法授权的逆向分析。

致谢

本项目构建在 cdp-use 之上。cdp-use 提供了一个面向 Agent 场景进行高度优化和抽象的底层 WebSocket 交互层,极大地简化了原始 CDP 协议的通信复杂性。

许可证

MIT License

Installation

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

Use MiniApp CDP MCP MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once MiniApp CDP MCP is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add MiniApp CDP MCP as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the MiniApp CDP MCP MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "miniapp-cdp-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the MiniApp CDP MCP MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the MiniApp CDP MCP MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use MiniApp CDP MCP to help me with this task?
MiniApp CDP MCP
Sure. I read it.
Here is what I found using MiniApp CDP MCP.

Frequently asked questions

What is the MiniApp CDP MCP MCP server used for?

MiniApp CDP MCP is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use MiniApp CDP MCP MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use MiniApp CDP MCP with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use MiniApp CDP MCP MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With MiniApp CDP MCP connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect MiniApp CDP MCP MCP to TypingMind?

MiniApp CDP MCP runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does MiniApp CDP MCP MCP provide in TypingMind?

MiniApp CDP MCP exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use MiniApp CDP MCP MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If MiniApp CDP MCP requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇