jsreverser-mcp
repository·main·Indexed 21 days ago
https://github.com/noone-hub/jsreverser-mcpAn MCP server for JavaScript reverse engineering and debugging that provides a standardized workflow engine to move from browser observation to Node.js-based local reproduction. It includes capabilities for page observation, runtime sampling via hooks, breakpoint debugging, network analysis, WebSocket observation, and environment patching. The tool implements a six-step methodology (Observe-first, Hook-preferred, Breakpoint-last, Rebuild-oriented, Evidence-first, and Pure-extraction-after-pass) to ensure systematic analysis and evidence preservation.
What's inside jsreverser-mcp
- JS Reverse MCP is an MCP (Model Context Protocol) service designed to standardize the frontend JavaScript reverse engineering process. Instead of focusing solely on page debugging, it provides a reusable workflow that integrates page observation, runtime sampling, local reproduction, environment patching (补环境), and evidence preservation.
Capabilities of JS Reverse MCP
mainJS Reverse MCP provides a comprehensive suite of tools for JavaScript reverse engineering, categorized by the reverse engineering lifecycle:
1. Page Observation & Script Locating
Establish the scope of scripts and find target code.
list_scripts: List all loaded scripts on the current page.get_script_source: View the source code of a specific script.find_in_script: Locate strings, variable names, or patterns within a single script.search_in_scripts: Batch search across cached scripts to narrow down candidates.
2. Hooking & Runtime Sampling
Perform non-intrusive observation of runtime behavior.
create_hook: Define reusable hooks for later injection.inject_hook: Inject existing hooks into the current page.get_hook_data: Retrieve hook call records and summaries.hook_function: Directly hook global functions or object methods to record arguments and return values.trace_function: Trace function calls by source name to follow call chains.
3. Breakpoints & Debugging Control
Use pause-based debugging when hooks are insufficient.
set_breakpoint: Set a breakpoint by script URL and line number.set_breakpoint_on_text: Automatically locate and set a breakpoint based on code text.resume: Continue execution to the next breakpoint or end.pause: Manually pause JavaScript execution.step_over/step_into/step_out: Single-step execution control.
4. Network Analysis
Identify requests and their origins.
list_network_requests: List all current network requests.get_network_request: View detailed request info (headers, response, payload).get_request_initiator: Trace which entity triggered a specific request.break_on_xhr: Interrupt execution when a target XHR request is sent.
5. Page State & Environment Checks
Verify browser health and local dependencies.
check_browser_health: Verify browser connection and page controllability.diagnose_environment: Output Node, browser, path, and dependency status.recommend_next_step: Get suggested actions based on current evidence.explain_reverse_stage: Explain the current stage, requirements, and exit conditions.list_console_messages: View console output (useful for hook/trace logs).get_storage: Read cookies,localStorage, andsessionStorage.evaluate_script: Execute code within the selected frame for runtime validation.search_in_sources: Search all loaded source code for keywords.
6. WebSocket Observation
Handle long connections and binary frames.
list_websocket_connections: List active WebSocket connections (returnswsid).analyze_websocket_messages: Group messages by frame characteristics.get_websocket_messages: View message summaries or content for a connection/group.
7. Local Rebuild & Environment Patching
Bring page evidence to a local environment.
export_rebuild_bundle: Export entry points, environment patches, and evidence for local reproduction.diff_env_requirements: Compare current environment capabilities against missing requirements based on errors.record_reverse_evidence: Save key observations to a task artifact.
8. Page Automation
Automate interactions to reproduce conditions.
navigate_page: Navigate, go back, or refresh.query_dom: Query elements via selectors.click_element: Trigger clicks.hover_element/select_option: Handle menus and dropdowns.type_text: Input text into fields.press_key/upload_file: Handle keyboard and file uploads.scroll_page/wait_for_network_idle: Handle lazy loading and request completion.set_viewport/emulate_device: Emulate mobile or specific viewports.get_all_links: List all links on the page.take_screenshot: Capture the current page state.
9. Deep Analysis
Understand code structure and deobfuscate.
collect_code: Collect page code with controlled sampling.understand_code: Use static analysis and AI to understand business logic and structure.deobfuscate_code: Clean and restore obfuscated code.risk_panel: Aggregate code analysis, crypto detection, and hook signals.
10. Session Management
save_session_state: Snapshot cookies and storage to memory.restore_session_state: Restore a session snapshot to the current page.dump_session_state: Export session snapshot to JSON.load_session_state: Load session from JSON or string.
11. Task Orchestration & Agent Consumption
start_reverse_task/create_reverse_task_from_request: Create task artifacts.manage_reverse_task: Entry point forget,summarize,archive,restore,search,tag,prune, andcompare.orchestrate_reverse_task: Advance through stages (observation, sampling, reconstruction, etc.).run_reverse_agent: One-stop entry point for agent-driven tasks.query_reverse_task: Read task summaries, suggestions, and artifacts.get_rebuild_health_report: Summarize local rebuild health.
Best practices for handling first-screen initialization
mainWhen reverse engineering targets that rely on first-screen initialization, parameter generation before the first network request, or logic executed during the very first page load cycle, follow these rules:
- Priority: Prioritize
inject_preload_scriptfor sampling. - Timing: Do not wait for the page scripts to finish executing before attempting to apply hooks. If you miss the initial execution window, the context required for the reverse engineering task may be lost.
- Fallback: Only enter the breakpoint/debugging path if Hooks are unable to explain the critical context.
- Priority: Prioritize
Follow the Case Reuse Priority
mainWhen looking for information or implementation logic, follow this order of operations:
- Full Chain: Check
artifacts/tasks/<task-id>/for the complete reproduction chain. - Abstract Case: If no specific task exists, check
scripts/cases/*for the abstract case definition. - New Task: If no reference is found, create a new task following the methodology template and store it in
artifacts/tasks/.
Important: To show what parameters or chains have been established, update
scripts/cases/README.md. Do not use real task directories as a public index.- Full Chain: Check
How to use executionOverrides for testing and prototyping
mainThe
executionOverridesflag has higher priority than real executors. It is intended for:- Testing: Reliably reproducing success or failure states.
- Prototyping: Using a placeholder for an unimplemented adapter to test the overall orchestration flow.
- Demos: Skipping expensive steps or steps that require a real browser context.
Warning: Do not use overrides as long-term replacements for real executors.
# Example: Mocking a successful hook injection node build/src/index.js --orchestrateReverseTask task-001 --execute --executionOverrides '{"inject_hook":{"status":"ok","result":"done"}}'Understand the JS Reverse Workflow stages
mainThe JS Reverse Workflow is a structured model execution protocol designed to transform frontend reverse engineering tasks into stable, repeatable stages. This prevents skipping steps or attempting algorithm extraction before environment replication is stable.
The six stages are:
Observe: Identify target requests, scripts, and trigger conditions.Capture: Use hooks to collect runtime samples, parameters, and call sequences.Rebuild: Export page evidence into a local Node.js reproduction project.Patch: Drive environment patching using proxy logs andfirst divergenceanalysis until the local link matches browser truth.PureExtraction: Separate 'environment noise' from 'algorithm input' to create a pure Node.js implementation.Port: Migrate the pure implementation to Python or other target hosts.
Core Principles:
Observe-first,Hook-preferred,Breakpoint-last.Rebuild-oriented,Evidence-first,Browser-truth-first.Pure-extraction-after-pass(only extract algorithms after the environment rebuild passes).
Understand reverse agent schema versioning
mainThe
reverse-agent-response.schema.jsonand its sub-schemas use a dual-versioning system to manage compatibility between the agent and its clients:schemaVersion: A runtime field present in the response body. This is intended to be read directly by the client or agent during execution.x-schemaVersion: A metadata field within the schema file itself. This is intended for documentation and toolchain consumption.
Currently, the stable baseline is version
1.0.How to interpret JSReverser MCP tool responses
mainWhen calling tools like
manage_reverse_task,orchestrate_reverse_task,run_reverse_agent, orget_rebuild_health_report, parse the response in this specific order to determine the next action:responseSummary: Get the high-level overview.outcome/status: Check the current state of the task.errorType/retryable/blockedBy: Identify if the task failed, if it can be retried, or what is blocking progress.routeGuard: Check for routing constraints.continuation.invoke: Ifcontinuation.ready=true, this is your primary next step.
Decision Logic:
- If blocked: Resolve the issue identified in
blockedBybefore proceeding. - If partial and
retryable=true: You can attempt to resume/run again. - If
shouldSwitchStrategy=true: Prioritize switching the execution strategy. - If
compactDeliveryis ready: Prompt the user to export or use the portable product.
Structure of a Parameter Site Mapping document
mainA complete site mapping document must include the following seven sections to ensure site-specific nuances are captured:
- Site Information: Identifies the site name, parameter name, entry functions/classes, script URL patterns, and entry URLs or API hosts (using Base64 encoding for URLs).
- Request Mapping: Defines the target interface pattern (method, URL pattern, optional functionId/operation) and where parameters reside (
query,body, orheader). - Field Mapping: Lists required and optional fields, and identifies dependency seed types such as specific cookie keys, storage keys, or fingerprinting capabilities (e.g.,
canvas,webgl). - Site-Specific Risk Points: Notes regarding initialization timing (first screen vs. async vs. lazy loading), high-change points (version fields, dynamic algorithms, token issuance), and common misjudgments.
- Verification Criteria (Site Version): Defines structural criteria (segment count, charset, length), behavioral criteria (status + business code), and tolerance for differences.
- Regression Checklist: A list of checks to perform after script version changes, including output contract compliance,
requiredInputschanges, proxyenv logexception paths, andfirst divergenceshifts. - Related Documentation: Links to the methodology template, safety policy, and tool I/O contracts.
Follow parameter accumulation and safety rules
mainWhen documenting or accumulating parameter chains, follow this hierarchy:
- Read local task artifacts:
artifacts/tasks/<task-id>/ - Read abstract cases:
scripts/cases/* - Create new templates if needed:
docs/reference/parameter-methodology-template.mdordocs/reference/parameter-site-mapping-template.md
Safety Boundaries:
- Cases must only contain abstract methods and processes.
- Real task directories should remain local by default.
- Sensitive values must be desensitized before sharing.
- Git should only commit
_TEMPLATEfiles by default.
- Read local task artifacts:
Use record_reverse_evidence to persist observations
mainTherecord_reverse_evidencetool is used to write current observations (e.g., key hits in hooks, network traffic, or scripts) back to the task artifact. This ensures critical information is not lost in the conversation history and provides stable input for subsequentmanage_reverse_task:summarizeorprogresscalls. It allowsorchestrate_reverse_taskto reuse evidence when planning future steps.Understand the Case Safety Policy and Repository Layering
mainThe
jsreverser-mcprepository follows a strict layering strategy to separate public documentation from private, executable task data. This prevents legal and compliance risks by ensuring that sensitive data and executable signing logic are not exposed in the public repository layers.Repository Layers
docs/reference/: Contains rules, contracts, templates, and indices.docs/guides/: Contains operational guides for human users.scripts/cases/: Contains public parameter and workflow indices (abstract only).artifacts/tasks/<task-id>/: Contains private, local task outputs and executable code. This is not a public documentation entry point.
Note: When adding new formal documentation, do not place it directly in the
docs/root directory.