Skip to main content
Glama
WhiteNightShadow

camoufox-reverse-mcp

hook_function

Intercept or trace JavaScript function calls by path, logging arguments, returns, or injecting custom code for reverse engineering in anti-detection browsers.

Instructions

Hook or trace a function (v0.9.0 unified).

Replaces hook_function + trace_function.

Args: function_path: Full path like "window.encrypt", "XMLHttpRequest.prototype.open", "JSON.stringify". mode: "intercept" — inject custom JS before/after/replace the function. Requires hook_code. (was: hook_function) "trace" — log synchronous returns/throws and optionally args and call stacks. (was: trace_function) hook_code: JS code for "intercept" mode. Context vars: - arguments: original args - __this: the 'this' context - __result: return value (only in position="after") position: For "intercept": "before", "after", or "replace". non_overridable: For "intercept": use Object.defineProperty to lock. persistent: If True, survives page navigation. log_args: For "trace": record arguments (default True). log_return: For "trace": record return values (default True). log_stack: For "trace": record call stacks (default False). max_captures: For "trace": max calls to record (default 50). world: "isolated" (compatible default) or Firefox page "main" world. wait_timeout_ms: How long to wait for a late-bound target. Defaults to 5000 for persistent hooks and 0 for non-persistent hooks. poll_interval_ms: Late-binding polling interval (10..1000ms). watch_assignments: Install a temporary setter on the first missing path segment so assignment-and-immediate-call in one JS task is captured. Defaults to True for persistent hooks and False otherwise. 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. serialization: For "trace": "json" (default) retains JSON text fields, but executes getters/toJSON and may fall back to String conversion; this can have side effects. "preview" reads no properties of argument, return, or thrown objects and never coerces them: objects/functions are placeholders, symbols omit their description, and undefined, BigInt, NaN, infinities and -0 have string tags. Only the wrapper's own argument array is traversed. Text is truncated at 2000 characters in both modes and is not necessarily complete/parseable JSON.

Trace semantics: Ordinary synchronous calls keep the original receiver, argument values, return/throw identity and one original invocation. Entries retain traceId, callIndex, timestamp, world, frame, args/returnValue and optional stack; outcome is "return" or "throw", with thrownValue for synchronous throws. completion="sync" always: a returned Promise/thenable is only a synchronous return, never an observed settlement (no await or attached handlers). Logging failures do not replace the original result/exception. Calls made by logging/JSON serialization are not recursively traced; real nested calls are. Clearing logs does not reset max_captures or callIndex. Intrinsics are saved at the first trace installation in each realm, so later hooks cannot redirect the logger. Already modified third-party intrinsics cannot be recovered. Preview limits value inspection, not timing/stack/identity visibility of wrappers or page-controlled sinks; optional stack capture may run custom stack formatting. Constructor/new semantics are outside this ordinary-call trace contract.

Returns: dict with status, target, mode.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeNointercept
worldNoisolated
log_argsNo
positionNobefore
frame_urlNo
hook_codeNo
log_stackNo
frame_nameNo
log_returnNo
persistentNo
frame_indexNo
max_capturesNo
function_pathYes
serializationNojson
non_overridableNo
wait_timeout_msNo
poll_interval_msNo
watch_assignmentsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.8.0
    • addedInput schema / properties / serialization
      Added value: +{
      +  "default": "json",
      +  "title": "Serialization",
      +  "type": "string"
      +}
  2. Changed7 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 / poll_interval_ms
      Added value: +{
      +  "default": 50,
      +  "title": "Poll Interval Ms",
      +  "type": "integer"
      +}
    • addedInput schema / properties / wait_timeout_ms
      Added value: +{
      +  "title": "Wait Timeout Ms",
      +  "type": "integer"
      +}
    • addedInput schema / properties / watch_assignments
      Added value: +{
      +  "title": "Watch Assignments",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / world
      Added value: +{
      +  "default": "isolated",
      +  "title": "World",
      +  "type": "string"
      +}
  3. Changed8 schema fields changedv1.0.0
    • addedInput schema / properties / hook_code / default
      Added value: +""
    • addedInput schema / properties / log_args
      Added value: +{
      +  "default": true,
      +  "title": "Log Args",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / log_return
      Added value: +{
      +  "default": true,
      +  "title": "Log Return",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / log_stack
      Added value: +{
      +  "default": false,
      +  "title": "Log Stack",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / max_captures
      Added value: +{
      +  "default": 50,
      +  "title": "Max Captures",
      +  "type": "integer"
      +}
    • addedInput schema / properties / mode
      Added value: +{
      +  "default": "intercept",
      +  "title": "Mode",
      +  "type": "string"
      +}
    • addedInput schema / properties / persistent
      Added value: +{
      +  "default": false,
      +  "title": "Persistent",
      +  "type": "boolean"
      +}
    • changedInput schema / required
      Previous value: -[
      -  "function_path",
      -  "hook_code"
      -]New value: +[
      +  "function_path"
      +]
  4. First observedv0.3.0

TDQS

A4.3/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and delivers exceptionally. It discloses side effects (json serialization executes getters/toJSON and may coerce via String; preview reads no properties), async semantics (a returned Promise is never awaited or settled-observed; completion is always 'sync'), failure isolation (logging failures don't replace original results), non-reset of counters (clearing logs doesn't reset max_captures or callIndex), intrinsic snapshotting at first install, and limitations (2000-char truncation, third-party modified intrinsics unrecoverable, constructor/new semantics out of contract). The watch_assignments temporary setter installation is explicitly called out.

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?

Densely informative with a clean structure: purpose line, bulleted parameter list, a 'Trace semantics' section, then Returns. Nearly every sentence carries semantic weight. Minor redundancy exists (position='after' and serialization caveats appear in both the parameter list and the trace-semantics section), and the 'Replaces hook_function + trace_function' line is stale filler. Justified length given 18 parameters and the late-binding/serialization complexity, but a few duplicated details could be trimmed.

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?

Parameter and behavioral coverage is superb, but the output contract is thin: with no output schema, the description offers only 'Returns: dict with status, target, mode' — status values, what 'target' contains, and error/timeout outcomes (e.g., when the late-bound target never appears within wait_timeout_ms) are unspecified. For a tool this complex, an agent cannot fully predict success or failure shapes from the description alone.

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%, and the description compensates completely: all 18 schema properties are addressed with real semantics beyond names and defaults — examples for function_path, context vars (arguments, __this, __result, and its position='after' restriction) for hook_code, value sets for mode/position/world/serialization, persistence-dependent defaults for wait_timeout_ms and watch_assignments, the polling range for poll_interval_ms, and exact frame targeting semantics for frame_url/frame_name/frame_index. Nothing in the schema is left unexplained.

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 opening line — 'Hook or trace a function (v0.9.0 unified)' — gives a specific verb and resource, and the mode parameter (intercept vs trace) crisply splits the two behaviors. The function_path examples ('window.encrypt', 'XMLHttpRequest.prototype.open', 'JSON.stringify') make the target concrete. Though the 'Replaces hook_function + trace_function' note references tools absent from the sibling list, the core purpose is unmistakable.

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?

In-tool guidance is strong: mode selection, the difference between intercept and trace, frame targeting, and world choice are all explained, and defaults are given by persistence flavor. However, the description never contrasts with current siblings like inject_hook_preset, trace_property_access, or hook_jsvmp_interpreter — an agent has no explicit signal for when to pick this tool over those. The 'Replaces' note targets tools that no longer exist, so that guidance is inert.

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