Skip to main content
Glama

javascript

Execute page-level scripts in Firefox tabs and return the final expression as JSON; wrap asynchronous logic in an IIFE.

Instructions

Run JavaScript in the page and return the last expression value (JSON). For async code use (async () => { ... })().

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"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYes
tabIdNoTab to act on. Omit for the active tab.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.5/5.0
Behavior3/5

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

With no annotations, the description must carry behavioral burden; it discloses the return semantics (last expression value, JSON-serialized) and the required async wrapper, which are genuinely useful. It says nothing about execution context (page main world vs isolated), whether side effects persist, error/exception behavior, or the risk profile of arbitrary code execution.

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?

Two short sentences, front-loaded with the action and return contract, with the async caveat appended immediately. 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?

For a two-parameter tool with no output schema, the essentials are present: what runs, what comes back, and how to handle async. Gaps remain around error behavior and execution environment, which matter for a tool that executes arbitrary code against a live page.

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 50% — only tabId is documented in the schema, while code is bare. The description compensates well: it makes clear that code is an expression whose final value is returned, and that async work needs an IIFE wrapper. It does not clarify the tabId default beyond the schema's own note, but the added meaning for code is substantial.

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 ('Run JavaScript in the page') plus the return contract (last expression value, JSON). It is clearly distinguishable from action-specific siblings like click or type, though it never explicitly frames itself as the general-purpose escape hatch.

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?

The only guidance is syntactic ('For async code use (async () => { ... })()'), which is a pattern hint rather than selection guidance. There is no statement of when to prefer this over the dedicated siblings (click, type, find, get_page_text) or when not to use it.

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