run_js
Execute custom JavaScript in a selected Safari tab and receive the JSON-encoded output, solving cases where dedicated tools do not cover the needed action.
Instructions
Run arbitrary JavaScript in a tab. The escape hatch; prefer the others.
Your code runs as a function body, so return the value you want back. The
result is JSON-encoded, so return plain data rather than DOM nodes.
Args:
tab: Tab index within window 1, or a substring of its URL or title.
code: JavaScript to execute. Use return to produce a result.
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": {
"tab": "<tab>",
"code": "<code>"
},
"name": "run_js"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tab | Yes | ||
| code | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |