Skip to main content
Glama

browser_js

Execute JavaScript in the current or specified browser tab to read or modify page content. Set full mode to return large results completely.

Instructions

Execute JavaScript in the current page context.

Args: code: JavaScript code to run (e.g. "document.title" or "document.querySelectorAll('a').length") tab_id: Optional tab to target. Defaults to active tab. full: Results are capped at 8 MB (50 KB on extensions older than 2.1.0). full=True runs the code once and reads the result back in slices, so any size comes back complete.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
fullNo
tab_idNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.3/5.0
Behavior3/5

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

With no annotations, the description carries the full burden. It usefully discloses the result size cap (8 MB, 50 KB on extensions older than 2.1.0) and the slicing behavior of full=True. But it omits whether arbitrary JS executes on trusted/protected pages, error propagation, and whether the return value must be serializable – relevant behavioral facts for an arbitrary-code-execution tool.

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

Conciseness4/5

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

Front-loaded with the purpose sentence, then a compact Args block. The full-parameter explanation is slightly long but every clause (cap size, legacy cap, slicing) is decision-relevant. No filler.

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

Completeness3/5

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

For a 3-param tool with no annotations and no output schema, the description covers the important output-size concern but leaves return-value shape (how a value comes back to the caller) and error behavior unstated. Adequate but with clear gaps.

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 description coverage is 0%, so the description must compensate. It does: code is explained with two concrete examples, tab_id documents its default-to-active-tab behavior, and full gets a thorough explanation of the capping threshold and sliced read-back. This covers all three parameters well beyond the bare schema titles.

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

Purpose4/5

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

States a specific verb and resource: 'Execute JavaScript in the current page context'. This is unambiguous and would let an agent identify the tool. However, it does not differentiate from siblings that also read page content (browser_dom, browser_html, browser_query, browser_page_text), so no credit for sibling distinction.

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

Usage Guidelines2/5

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

No when-to-use, when-not-to-use, or alternative is named. The agent must infer that this is for arbitrary JS execution rather than the many structured page-reading siblings. The 'tab_id Optional tab to target. Defaults to active tab' line is parameter help, not usage guidance.

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