Skip to main content
Glama

Run JavaScript inside an extension own page

browser_run_in_extension

Evaluates 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.

Input Schema

NameRequiredDescriptionDefault
idYesExtension id
pageNoRelative page to run in (default: the options page)
expressionYesJavaScript expression; may return a Promise

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With only readOnlyHint=false in annotations, the description carries most of the burden and does well: it discloses that a background tab is opened, the expression is evaluated, and the tab is closed afterwards. It also states the return expectation (JSON value or string), though it doesn't explicitly warn that arbitrary evaluated code can mutate extension state.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Four sentences, front-loaded with the core purpose, followed by the tab lifecycle, the relationship to a sibling, and the return constraint. Every sentence adds information and there is no filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, and the description compensates by explaining the return-value expectation and the tab lifecycle side effect. For a tool that executes arbitrary code in an extension context, an explicit note about the privilege level of the evaluated code would make it complete, but the essentials are present.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds meaning the schema does not: it constrains what the expression should return ('a JSON value or a string') beyond the schema's note that a Promise is allowed. The 'page' default is already in the schema, so no further credit is needed there.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and scope: 'Evaluate an expression inside the context of one of the extension own pages' with browser.* APIs and extension DOM available. It explicitly positions itself against browser_extension_storage as 'the general escape hatch behind' it, letting an agent distinguish it from siblings without opening schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Clear context for when to use it: when an extension exposes no command line of its own but still needs to be inspected and driven, and as a fallback beyond browser_extension_storage. It lacks explicit when-not-to-use guidance (e.g., prefer browser_evaluate for normal page contexts) but the usage context is strong.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools