Skip to main content
Glama
camoufox-reverse-mcp

camoufox-reverse-mcp

evaluate_js

Executes arbitrary JavaScript expressions in the page or selected frame and returns the result, supporting promise awaiting and file output for large values.

Instructions

Execute an arbitrary JavaScript expression in the page context and return the result.

v1.0.1 fix: correctly handles undefined/null/void/Symbol return values without triggering JSON.parse crashes.

Default auto mode preserves legacy cleaning and smart JSON parsing; it may strip BOM/whitespace and replace lone surrogates. value_raw is not a code-unit-preserving transport. json_ascii returns explicit JSON text before transport/cleaning, preserving JSON string code units. Evaluation is never replayed after a failure.

Args: expression: JavaScript expression. Must be a single expression, not top-level var/let/const/function declarations (Playwright limitation). Wrap in IIFE if needed: (() => { var x = 1; return x; })() await_promise: If True, awaits Promise results (default True). world: "isolated" preserves the existing Playwright execution context. "main" prefers Camoufox's native mw: channel so page globals created by site scripts are visible, with an explicit Firefox window.wrappedJSObject.eval fallback for older/attached servers. frame_url: Optional exact frame URL or shell-style wildcard. frame_name: Optional exact frame name or shell-style wildcard. frame_index: Optional zero-based index from get_page_info().frames. output_file: Write the string result to this path instead of returning it. Use it for page blobs (bytecode, device state, rendered documents): multi-kilobyte values otherwise truncate or flood the conversation. The response carries path/bytes/sha256 and a short preview. output_encoding: "utf8" writes the string as UTF-8; "base64" decodes the string first, for binary payloads. overwrite: Allow replacing an existing output_file. result_format: "auto" (legacy cleanup) or "json_ascii" (ASCII JSON text in value, not parsed/trimmed). json_ascii follows JSON.stringify: tag non-finite numbers/-0/undefined explicitly if their distinction matters; it is not a lossless arbitrary-object graph serializer.

Returns: dict with keys: value - cleaned value (parsed JSON if applicable; None when output_file is used) value_raw - raw string before cleaning (only when cleaning applied) type - "primitive" | "json" | "json_ascii" | "file" | "handle_fallback" | "error" output - (file only) {path, bytes, sha256, encoding} preview - (file only) bounded single-line preview of the string result world - selected execution world frame - selected frame's current snapshot metadata execution_backend - isolated, Camoufox native, or wrappedJSObject warnings - list of applied cleanups, if any hint - (error only) friendly fix suggestion or None

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": {
      "expression": "<expression>"
    },
    "name": "evaluate_js"
  }
}

Input Schema

NameRequiredDescriptionDefault
worldNoisolated
frame_urlNo
overwriteNo
expressionYes
frame_nameNo
frame_indexNo
output_fileNo
await_promiseNo
result_formatNoauto
output_encodingNoutf8

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv1.13.1
    • addedInput schema / properties / output_encoding
      Added value: +{
      +  "default": "utf8",
      +  "title": "Output Encoding",
      +  "type": "string"
      +}
    • addedInput schema / properties / output_file
      Added value: +{
      +  "title": "Output File",
      +  "type": "string"
      +}
    • addedInput schema / properties / overwrite
      Added value: +{
      +  "default": false,
      +  "title": "Overwrite",
      +  "type": "boolean"
      +}
  2. Changed1 schema field changedv1.8.0
    • addedInput schema / properties / result_format
      Added value: +{
      +  "default": "auto",
      +  "title": "Result Format",
      +  "type": "string"
      +}
  3. Changed4 schema fields changedv1.6.0
    • addedInput schema / properties / frame_index
      Added value: +{
      +  "title": "Frame Index",
      +  "type": "integer"
      +}
    • addedInput schema / properties / frame_name
      Added value: +{
      +  "title": "Frame Name",
      +  "type": "string"
      +}
    • addedInput schema / properties / frame_url
      Added value: +{
      +  "title": "Frame Url",
      +  "type": "string"
      +}
    • addedInput schema / properties / world
      Added value: +{
      +  "default": "isolated",
      +  "title": "World",
      +  "type": "string"
      +}
  4. First observedv0.3.0

TDQS

A4.7/5.0
Behavior5/5

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

No annotations exist, and the description carries the full burden well: it discloses that evaluation is never replayed after a failure, that auto mode strips BOM/whitespace and replaces lone surrogates, that value_raw is not a code-unit-preserving path, and that json_ascii is not a lossless object-graph serializer. The Returns block enumerates the distinguishing result types (primitive/json/json_ascii/file/handle_fallback/error) and the execution backend, which is behavior an agent could not infer from the schema.

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?

It is front-loaded with purpose and then organized into behavioral notes, Args, and Returns, which is easy to scan. The v1.0.1 changelog paragraph is a small amount of history that an agent does not need in order to call the tool, which keeps it from a 5.

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?

There is no output schema, but the description supplies a full Returns contract with all keys and their meanings, including the file-only output/preview fields and the error-only hint. Given a ten-parameter tool with no annotations, nothing an agent needs to call it correctly appears to be missing.

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

Parameters5/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 carry all ten parameters, and it does: it explains the constraint on expression, the await_promise default, the isolated-versus-main world semantics including the mw: channel and wrappedJSObject fallback, the three frame selectors, output_file/output_encoding/overwrite behavior, and the auto versus json_ascii result_format tradeoff. This is meaning well beyond parameter names.

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 first sentence states a specific verb (Execute), a specific resource (an arbitrary JavaScript expression), and the scope (in the page context), ending with what it returns. That is enough for an agent to separate it from siblings such as scripts, extract_script, or hook_function without opening any schema.

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 gives concrete conditions for using several options - for example output_file is recommended for multi-kilobyte page blobs that would otherwise truncate or flood the conversation - and it specifies IIFE wrapping when declarations are needed. It does not name an alternative tool or an explicit "do not use this when..." case, so routing guidance 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.