Content
# wmpf-reverse-mcp
[](https://www.python.org/)
[](LICENSE)
**WeChat Mini Program CDP Debugging MCP Server**
Through MCP (Model Context Protocol) to provide WeChat Mini Program's CDP debugging capabilities for AI assistants. Supports automatic detection of mini program connections, capturing loaded scripts, executing JavaScript expressions, and more.
## Features
| Feature | Description |
|------|------|
| **Auto Connection** | Automatically detect mini program connection events, no manual operation required |
| **Script Capture** | Automatically capture all scripts loaded by the mini program |
| **Local Storage** | Script source code saved to local file, does not occupy AI context |
| **JS Execution** | Execute arbitrary JavaScript in the mini program context |
| **Auto Start** | Can automatically start WMPFDebugger subprocess |
| **Pre-check** | Automatically check port occupancy and WeChat process status before startup |
## Quick Start
### Prerequisites
- **Python** ≥ 3.10
- **Node.js** (WMPFDebugger dependency)
- **WMPFDebugger** project ([GitHub](https://github.com/evi0s/WMPFDebugger))
- **WeChat Desktop Client** (WeChatAppEx.exe)
### Installation
```bash
# Clone the project
git clone <your-repo>
cd wmpf-reverse-mcp
# Install dependencies
pip install -e .
```
### Startup
```bash
# Automatically start WMPFDebugger (recommended)
wmpf-reverse --wmpf-dir /path/to/WMPFDebugger
# Or specify the Python interpreter in the conda environment
python -m wmpf_reverse --wmpf-dir /path/to/WMPFDebugger
```
After installation, you can add the following configuration to the MCP configuration of your AI assistant:
```json
{
"mcpServers": {
"wmpf-reverse": {
"command": "wmpf-reverse",
"args": ["--wmpf-dir", "/path/to/WMPFDebugger"]
}
}
}
```
### Example Usage
```
1. Start the MCP server
2. Cold start the WeChat mini program
3. AI assistant automatically detects the connection and starts capturing scripts
4. Use get_captured_scripts() to view captured scripts
5. Use get_script_source() to get script source code
```
## Main Parameters
```
--wmpf-dir, -d <path> WMPFDebugger directory (auto-start mode)
--log-file, -l <path> Log file path (classic mode)
--port, -p <port> CDP port, default 62000
--debug-port <port> WMPFDebugger debug port, default 9421
--no-auto-start Disable auto-start
```
## Project Structure
```
src/wmpf_reverse/
├── mcp_server.py # MCP server entry
├── cli.py # CLI parameter parsing
├── adapters.py # Line source adapters
├── wmpf_debugger.py # WMPFDebugger subprocess management
└── core/
├── config.py # Configuration management
├── cdp_client.py # CDP WebSocket client
├── log_monitor.py # Log event monitoring
├── logger.py # Logging
├── mcp_tools.py # MCP tools (7)
└── wmpf_service.py # Core service layer
```
## Documentation
For detailed usage guidelines, see [USAGE.md](USAGE.md).
## License
[MIT](LICENSE)