intercept_request
Intercept matching network requests to log, block, modify, or mock responses, or stop interception for JavaScript reverse engineering and dynamic debugging.
Instructions
Intercept network requests matching a pattern.
Args:
url_pattern: URL glob pattern (e.g. "**/api/login*").
action: "log", "block", "modify", "mock", or "stop" (unroute).
modify_headers: Headers to add/override (action="modify").
modify_body: Request body replacement (action="modify").
mock_response: Dict for action="mock": "status", "headers", and at most
one body source —
"body" (inline text) or "body_file" (regular UTF-8 file up to 10 MiB;
relative paths resolve against the server working directory). Passing
both is an error. The file is re-read on every request in a worker
thread, so editing a patched script and reloading the page picks up
changes immediately; a missing or unreadable file returns a readable
error from the tool call (and aborts that request during serving).
When "headers" is omitted, body_file infers the content type from its
suffix (.js/.json/.html/.css/...).
Security note: fulfilled responses are readable by scripts in the
matching page/origin — only point body_file at intended mock or
instrumented assets, never at credentials or private local files.
Returns: dict with the interception status; for action="mock" with body_file it also reports the resolved absolute path and its current byte size.
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": {
"url_pattern": "<url_pattern>"
},
"name": "intercept_request"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | No | log | |
| modify_body | No | ||
| url_pattern | Yes | ||
| mock_response | No | ||
| modify_headers | No |