Run JavaScript inside an extension own page
browser_run_in_extensionEvaluates a JavaScript expression in an extension page context with browser.* APIs and DOM access, opening a temporary background tab to inspect or drive extensions without a CLI.
Instructions
Evaluate an expression inside the context of one of the extension own pages, where the WebExtension APIs (browser.*) and the extension DOM are available. It opens the page in a background tab, evaluates, then closes the tab. This is the general escape hatch behind browser_extension_storage: with it an extension that exposes no command line of its own can still be inspected and driven. The expression should return a JSON value or a string.
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": {
"id": "<id>",
"expression": "<expression>"
},
"name": "browser_run_in_extension"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Extension id | |
| page | No | Relative page to run in (default: the options page) | |
| expression | Yes | JavaScript expression; may return a Promise |