Content
# JS Reverse MCP
JavaScript Reverse Engineering MCP Server, allowing your AI coding assistants (such as Claude, Cursor, Copilot) to debug and analyze JavaScript code in web pages.
## Features
- **Script Analysis**: List all loaded JS scripts, search code, get source code
- **Breakpoint Debugging**: Set/remove breakpoints, support conditional breakpoints, support precise positioning in compressed code
- **Function Tracing**: Hook any function (including module internal functions), monitor calls and return values
- **Execution Control**: Pause/resume execution, step debugging (step over/into/out)
- **Runtime Inspection**: Evaluate expressions at breakpoints, inspect scope variables
- **Network Analysis**: View the call stack that initiated the request, set XHR breakpoints
- **Event Monitoring**: Monitor DOM events, check storage data
## System Requirements
- [Node.js](https://nodejs.org/) v20.19 or newer
- [Chrome](https://www.google.com/chrome/) Stable version
- Git
## Local Installation
```bash
# Clone the repository
git clone https://github.com/zhizhuodemao/js-reverse-mcp.git
cd js-reverse-mcp
# Install dependencies
npm install
# Build the project
npm run build
```
## MCP Client Configuration
Add the following to your MCP client configuration file:
```json
{
"mcpServers": {
"js-reverse": {
"command": "node",
"args": ["/your/path/js-reverse-mcp/build/src/index.js"]
}
}
}
```
### Claude Code
```bash
claude mcp add js-reverse node /your/path/js-reverse-mcp/build/src/index.js
```
### Cursor
Go to `Cursor Settings` -> `MCP` -> `New MCP Server`, and use the above configuration.
### VS Code Copilot
```bash
code --add-mcp '{"name":"js-reverse","command":"node","args":["/your/path/js-reverse-mcp/build/src/index.js"]}'
```
## Tool List
### Script Analysis
| Tool | Description |
| ------------------- | -------------------------------------------------------------- |
| `list_scripts` | List all loaded JavaScript scripts in the page |
| `get_script_source` | Get script source code, supports line range or character offset (suitable for compressed files) |
| `find_in_script` | Find text in the script, return precise line and column numbers |
| `search_in_sources` | Search for strings or regular expressions in all scripts |
### Breakpoint Management
| Tool | Description |
| ------------------------ | ---------------------------------------------------------- |
| `set_breakpoint` | Set a breakpoint at the specified URL and line number |
| `set_breakpoint_on_text` | Automatically set breakpoints by searching for code text (suitable for compressed code) |
| `remove_breakpoint` | Remove a breakpoint |
| `list_breakpoints` | List all active breakpoints |
### Debug Control
| Tool | Description |
| ----------------------- | -------------------------------------------- |
| `get_paused_info` | Get pause status, call stack, and scope variables |
| `resume` | Resume execution |
| `pause` | Pause execution |
| `step_over` | Step over |
| `step_into` | Step into |
| `step_out` | Step out |
| `evaluate_on_callframe` | Evaluate expressions in the context of a paused call frame |
### Function Hook
| Tool | Description |
| ----------------- | ---------------------------------------------------------------- |
| `hook_function` | Hook global functions or object methods, record calls and return values |
| `unhook_function` | Remove function hook |
| `list_hooks` | List all active hooks |
| `trace_function` | Trace any function call (including module internal functions), implemented using conditional breakpoints |
### Network Debugging
| Tool | Description |
| ----------------------- | -------------------------------------------- |
| `get_request_initiator` | Get the JavaScript call stack for network requests |
| `break_on_xhr` | Set XHR/Fetch breakpoints |
| `remove_xhr_breakpoint` | Remove XHR breakpoints |
### Inspection Tools
| Tool | Description |
| ---------------- | ------------------------------------------------------ |
| `inspect_object` | Deeply inspect JavaScript object structure |
| `get_storage` | Get cookies, localStorage, sessionStorage |
| `monitor_events` | Monitor DOM events on elements or the window |
| `stop_monitor` | Stop event monitoring |
### Page Navigation
| Tool | Description |
| --------------- | ---------------------------------- |
| `list_pages` | List open pages in the browser |
| `select_page` | Select a page as the debugging context |
| `new_page` | Create a new page and navigate to a URL |
| `navigate_page` | Navigate the current page |
### Other Tools
| Tool | Description |
| ----------------------- | ------------------------------ |
| `take_screenshot` | Take a screenshot of the page |
| `take_snapshot` | Get a DOM snapshot of the page |
| `evaluate_script` | Execute JavaScript in the page |
| `list_console_messages` | Get console messages |
| `list_network_requests` | List network requests |
| `get_network_request` | Get request details and response content |
## Usage Examples
### Basic Flow
1. **Select Page**
```
List all pages and select the page to debug
```
2. **Find Target Function**
```
Search for code containing "encrypt"
```
3. **Set Breakpoint**
```
Set a breakpoint on the encryption function
```
4. **Trigger and Analyze**
```
Trigger the operation and inspect parameters and call stack at the breakpoint
```
### Hook Encryption Function
```
Hook the fetch function to record parameters and return values of all API calls
```
### Trace Module Internal Function
```
Use trace_function to trace the webpack-bundled internal function "encryptData"
```
## Configuration Options
| Option | Description |
| ---------------------- | ---------------------------------------------- |
| `--browserUrl, -u` | Connect to a running Chrome instance |
| `--wsEndpoint, -w` | WebSocket endpoint connection |
| `--headless` | Run in headless mode (default: false) |
| `--executablePath, -e` | Custom Chrome path |
| `--isolated` | Use a temporary user data directory |
| `--channel` | Chrome channel: stable, canary, beta, dev |
| `--viewport` | Initial viewport size, e.g., `1280x720` |
### Example Configuration
```json
{
"mcpServers": {
"js-reverse": {
"command": "node",
"args": [
"/your/path/js-reverse-mcp/build/src/index.js",
"--headless=false",
"--isolated=true"
]
}
}
}
```
### Connect to a Running Chrome
1. Launch Chrome (requires restarting after closing all Chrome windows):
**macOS**
```bash
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug
```
**Windows**
```bash
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="%TEMP%\chrome-debug"
```
2. Configure MCP connection:
```json
{
"mcpServers": {
"js-reverse": {
"command": "node",
"args": [
"/your/path/js-reverse-mcp/build/src/index.js",
"--browser-url=http://127.0.0.1:9222"
]
}
}
}
```
## Security Tips
This tool exposes browser content to the MCP client, allowing inspection, debugging, and modification of any data in the browser. Do not use it on pages containing sensitive information.
## License
Apache-2.0
Connection Info
You Might Also Like
markitdown
MarkItDown-MCP is a lightweight server for converting URIs to Markdown.
servers
Model Context Protocol Servers
Time
A Model Context Protocol server for time and timezone conversions.
Filesystem
Node.js MCP Server for filesystem operations with dynamic access control.
Sequential Thinking
A structured MCP server for dynamic problem-solving and reflective thinking.
git
A Model Context Protocol server for Git automation and interaction.