Skip to main content
Glama

javascript_tool

Execute JavaScript in a browser tab to debug and inspect page state, returning the expression result or last statement value.

Instructions

Execute JavaScript in the page for DEBUGGING and INSPECTION only. Returns the result of the expression or last statement.

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": {
      "code": "<code>"
    },
    "name": "javascript_tool"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesJavaScript expression or statements to run.
tabIdNoTab ID to target. Omit to act on the current tab.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.2/5.0
Behavior2/5

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

No annotations exist, so the description carries the full disclosure burden for arbitrary in-page code execution. It states the return semantics ('result of the expression or last statement'), which is useful, but says nothing about side effects on page state, execution context/frame, async support, timeouts, or serialization limits of returned values — all material for this class of 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?

Two short sentences, front-loaded with the action and its scope, with the return behavior immediately after. Nothing is wasted; the only cost is that brevity here leaves important behavior unstated.

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 tool that runs arbitrary code in a live page with no annotations and no output schema, the definition covers what it does, where it acts, and what it returns. It is still thin on the execution environment and side-effect profile, which an agent needs to call this safely.

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?

Schema description coverage is 100%, and both parameters (code, tabId) are documented in the schema, including the omit-to-target-current-tab behavior. The description adds no meaning beyond that, so the baseline of 3 for a fully documented schema is appropriate.

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?

The description gives a specific verb and resource: execute JavaScript in the page, and it scopes the tool to 'DEBUGGING and INSPECTION only.' That narrows it against siblings like read_page and get_page_text, though it never names an alternative outright, so an agent must infer the boundary rather than read it.

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

Usage Guidelines3/5

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

There is an implied when-to-use clause ('for DEBUGGING and INSPECTION only'), which is a real constraint, but no explicit when-not or named alternatives. The agent is told the spirit of the tool without being told when to reach for read_page or get_page_text instead.

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