execute_js
Run JavaScript code in the browser and retrieve the output. Scripts are automatically wrapped to capture results; avoid using 'return' statements directly.
Instructions
Execute JavaScript code on the page and return the result.
IMPORTANT: Do NOT use 'return' statements directly in your script.
The script is automatically wrapped to capture the result.
Examples:
Good: document.title
Good: (function() { const x = 1 + 1; return x; })()
Bad: return document.title // SyntaxError!
For complex scripts, wrap in an IIFE:
(function() {
const data = [];
// ... your code ...
return data;
})()
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": {
"script": "<script>"
},
"name": "execute_js"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |