inject_hook_preset
Injects pre-built JavaScript hooks into the page's main world to log XHR, fetch, crypto, WebSocket, cookie, and runtime activity, with optional persistence across new documents.
Instructions
Inject a pre-built hook into the page main world.
Presets run where page scripts run (v1.10.0; before, they ran in the isolated world and recorded none of the page's own calls). Page code can detect the replaced functions; remove_hooks() restores them in the current document.
Available presets (log location in brackets, read it with
evaluate_js("window. || []", world="main")):
- "xhr": XMLHttpRequest requests [__mcp_xhr_log].
- "fetch": fetch requests [__mcp_fetch_log]; get_request_initiator
also reads its stacks.
- "crypto": btoa/atob/JSON.stringify inputs and outputs [__mcp_crypto_log].
- "websocket": WebSocket connections and messages [__mcp_ws_log].
- "debugger_bypass": strip debugger from Function(...) and timers.
- "cookie" (alias "cookie_hook"): document.cookie reads/writes [__mcp_cookie_log].
- "runtime_probe": XHR/fetch/canvas/WebGL/navigator/listener calls [__mcp_runtime_log].
Args: preset: One of the above preset names. persistent: True (default) also installs it in every new document, including same-origin iframes; False installs it in the current document only.
Returns: dict with status, preset, world, execution_backend and read_with.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"preset": "<preset>"
},
"name": "inject_hook_preset"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| preset | Yes | ||
| persistent | No |