Skip to main content
Glama

javascript_tool

Run JavaScript in the active browser tab to manipulate the DOM, access page variables, or fetch data. Returns the evaluated result or any errors.

Instructions

Execute JavaScript code in the context of the current page. The code runs in the page's context and can interact with the DOM, window object, and page variables. Returns the result of the last expression or any thrown errors. If you don't have a valid tab ID, use tabs_context first to get available tabs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe JavaScript code to execute. Evaluated in the page context with REPL semantics: top-level `await` works, and the result of the last expression is returned automatically -- write the expression you want (e.g. `window.myData.value`, or `await fetch(url).then(r=>r.json())`) rather than `return ...`. You can access and modify the DOM, call page functions, and interact with page variables.
tabIdYesTab ID to execute the code in. Must be a tab in the current group. Use tabs_context first if you don't have a valid tab ID.
actionYesMust be set to 'javascript_exec'

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
provenanceNo
Behavior5/5

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

With no annotations, the description fully discloses execution context ('runs in the page's context'), interaction capabilities ('interact with the DOM, window object, and page variables'), and return behavior ('Returns the result of the last expression or any thrown errors'). The schema further adds REPL semantics and top-level await support, providing comprehensive behavioral transparency.

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?

The description is three sentences, front-loaded with the core purpose, followed by behavioral details and a practical prerequisite. Every sentence earns its place with no redundancy or fluff.

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

Completeness5/5

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

Given the tool's complexity and the presence of a detailed schema and output schema, the description covers purpose, execution context, interactions, return values, and prerequisites. It is complete for an agent to select and invoke the tool correctly.

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

Parameters3/5

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

The input schema already provides extensive descriptions for all three parameters (100% coverage), including REPL semantics, tabId prerequisites, and the fixed action value. The description itself adds no information beyond the schema, so a baseline score of 3 is appropriate.

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 opens with a precise verb+resource: 'Execute JavaScript code in the context of the current page.' It further specifies interaction with DOM, window object, and page variables, clearly distinguishing this from navigation or read-only tools. The return behavior is also stated, leaving no ambiguity about the tool's function.

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?

The description provides a clear prerequisite: 'If you don't have a valid tab ID, use tabs_context first to get available tabs.' This implies when the tool is appropriate (having a tab context) and directs the agent to a supporting tool. However, it doesn't explicitly contrast with alternatives like 'script' or state when not to use this tool, so it stops short of a 5.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sylin-org/ghostlight'

If you have feedback or need assistance with the MCP directory API, please join our Discord server