javascript_tool
Execute JavaScript in a live Firefox tab and return the last expression's value. Runs in the page's context, supports top-level await, and reports thrown errors with details.
Instructions
Evaluate JavaScript inside a page and hand back what its final expression produced. All three fields are required: action pinned to javascript_exec, text carrying the source, and tabId naming the page. The snippet runs in the page's own world, so the document, window, and whatever globals the site defined are all within reach, and anything it changes is really changed. It behaves like a console rather than a function body: top-level await is allowed, and the value of the last expression comes back by itself, so finish with the expression instead of a return statement. Results are stringified (objects as indented JSON) and cut off at 10000 characters, with a line saying how long the full text was. A throw from the page fails the call with its message and the frame that raised it. Two things script cannot do here: fill a file input, which needs file_upload or upload_image, and get past its own alert or confirm - that parks the page until firefox_dialog answers it, which in Firefox is recoverable rather than the end of the session.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | The source to evaluate. Console semantics: top-level await works, and the last expression is the result, so write `document.title` or `await fetch('/api/status').then(r => r.json())` and skip the return; statements ahead of it run normally. It executes in the page context, with the DOM, window and page globals available and its writes sticking to the live document. Anything past 10000 characters of output is trimmed. | |
| tabId | Yes | The page to run in; required, never guessed. Use an id tabs_context_mcp listed for this session - a tab outside the group, or one already closed, is refused. | |
| action | Yes | Fixed string: send javascript_exec, spelled exactly that way. Any other value is turned away before the page is touched. |