Skip to main content
Glama
camoufox-reverse-mcp

camoufox-reverse-mcp

instrumentation

Injects source-level taps into JavaScript VMP scripts to log property access, calls, and dispatcher stages, and rewrite sources for debugging obfuscated code.

Instructions

JSVMP source-level instrumentation (v0.9.0 unified).

Replaces instrument_jsvmp_source / get_instrumentation_log /
stop_instrumentation / reload_with_hooks.

Args:
    action:
      "install" — register route + AST/regex rewrite on matched scripts.
                  Requires url_pattern. (was: instrument_jsvmp_source)
      "log"     — fetch accumulated tap events from instrumented code.
                  (was: get_instrumentation_log)
      "stop"    — unregister instrumentation route.
                  (was: stop_instrumentation)
      "reload"  — reload page so persistent hooks fire before page JS.
                  (was: reload_with_hooks)
      "status"  — show active instrumentations, their options and the
                  files passed through unchanged, with reasons.
                  (was: get_instrumentation_status)
      "rewrite_source" — apply the same rewrite to local JS without a
                  browser: give `source` (text) or `source_path`, and
                  `output_path` for anything larger than ~100KB. The
                  output runs in Node/vm/jsdom too; events collect in
                  globalThis.__mcp_vmp_log. No size limit applies.
    url_pattern: For "install"/"stop" — glob pattern matching VMP script URLs.
    mode: For "install"/"rewrite_source" — "ast" (esprima then local
        bundled Acorn) or "regex" (conservative whole-program subset;
        unsupported input skipped).
    tag: For "install"/"rewrite_source"/"log" — group identifier.
    rewrite_member_access: tap obj[key] reads (default True). Start here.
    rewrite_calls: tap fn(args) and obj.m(args) calls (default False since
        v1.10.0). Turn it on only when call events are needed: call taps
        add helper frames, so callee.caller reads null and the maximum
        recursion depth drops, which fingerprinting code can notice.
    tap_stage_calls: rewrite the flattened-VMP dispatcher shape
        `return fn.apply(this, [<int>].concat(Array.prototype.slice
        .call(arguments)))` into per-state `tap_stage` events (state id `p`,
        argc, first args previews, return preview), pushed when the state
        returns. Events recorded while a state runs carry it as `stage`.
        This is a literal match, so it also works when the rest of the
        file is not parseable (status then shows "(stage taps only)"), and
        it is independent of `mode`/`filter_*`.
    inject: source-level regex insertion, independent of `mode` and usable
        together with `tap_stage_calls`/`filter_*`. A list of
        `{"find": <regex>, "before": <js>, "after": <js>, "group": <name>}`:
        every match of `find` (re.MULTILINE) gets `before` inserted at the
        match start and/or `after` at the match end. `$1..$99`/`$0` in the
        snippets expand to capture groups, `$$` is a literal `$`.
        Four safety layers keep injected code from breaking syntax:
        (1) each snippet is wrapped into a complete statement (`;` guard on
        both ends, or `;

... ;when it contains newlines or//); (2) insertions landing inside string, template, comment or regex literals are skipped individually (skipped_insertions/ literal_skips); (3) a beforeinsert on aswitch case :/default: label is automatically shifted past that label's colon (label_shift), so it executes when jumping to that state and never lands before the first case; (4) when the original source parses (esprima or local bundled Acorn for modern ES2025/module syntax), the injected output is re-parsed and any group that would break syntax is rolled back individually (inject.skipped_groups, reason "would break syntax"). Note: single-line inserts add zero newlines (lines_added == 0), though mode="ast"prepends the instrumentation runtime header at the top of the file (onlymode="regex"with zero member rewrites keeps exact 1-based line numbers). Per-group inserted counts come back ininject.groups[].insertions (raw regex matches in.matches) and accumulate across newly rewritten scripts in status/logasinject_hits. The injected code runs in the page main world; read the globals it fills with evaluate_js(expression, world="main"). inject_validate: default True — run the parse validation and per-group fallback described above. False skips the AST re-parse check while keeping the ;statement wrapper, literal-region skip guard, and case/defaultlabel shift active. include_source_site: attach a stable site_id to tap events, plus an original-source range map in the log response. Default False. max_rewrites: hard cap on rewrites per file; status lists capped files. fallback_on_error: try conservative regex on AST failure only without property/object filters; otherwise pass through unchanged. ignore_csp: For "install" — skip CSP pre-flight check. clear_log: For "reload" — clear JSVMP logs before reload. wait_until: For "reload" — "load" / "domcontentloaded" / "networkidle". tag_filter: For "log" — filter by tag. type_filter: For "log" — "tap_get", "tap_call", "tap_method", "tap_call_err", "tap_stage", "tap_stage_break". key_filter: For "log" — substring match on property/method name. after_seq: For "log" — only events with seq > after_seq, oldest first; page with the returned next_after_seq. seq_window: For "log" — [start, end], events with start <= seq <= end. stage: For "log" — events recorded while dispatcher statestageran, plus that state's own tap_stage events. limit: For "log" — max entries: the most recent ones, or the first ones when after_seq/seq_window is set. clear: For "log" — clear log after retrieval in the selected main world. frame_url: For log; select a target frame by URL pattern. frame_name: For log; select a target frame by name. frame_index: For log; current frame snapshot index, not a persistent identity. Source scripts run in the main world; logs are always read there. Same-origin child frames log into the top frame's log with frame_url/frame_depth, so a removed iframe keeps its events. filter_property_names: For AST — only rewrite reads/methods of these property names (e.g. ['userAgent', 'platform', 'webdriver']). filter_object_names: For AST — only rewrite when the static base object path matches (e.g. ['navigator', 'this.bytecode']). Dynamic object identity is not inferred. Regex mode rejects nonempty filters. max_file_size: For "install" — files larger than this (bytes) trigger on_oversized behavior. Default 2,000,000. on_oversized: For "install" — "selective" (require filters), "skip", or "force" (full rewrite anyway). Default "selective". source: For "rewrite_source" — JS text to rewrite. source_path: For "rewrite_source" — local JS file to rewrite. output_path: For "rewrite_source" — where to write the rewritten JS (must differ from source_path); with include_source_site the site map goes to<output_path>.sites.json`.

Returns:
    dict with action-specific results. "log" also returns seq, dropped
    (events lost to the 20000-entry cap) and the options each install used.

IMPORTANT — timing for sync-loaded scripts (e.g. webmssdk):
    Route interception only catches requests made AFTER the route is
    registered. For scripts loaded via <script src> during page load,
    you MUST call instrumentation(action='install') BEFORE navigate().
    Pattern:
      1. launch_browser()
      2. instrumentation(action='install', url_pattern='**/webmssdk*')
      3. navigate("https://www.douyin.com/...")
    If called after navigate, use instrumentation(action='reload') to
    re-trigger page load with routes active.

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": {
      "action": "<action>"
    },
    "name": "instrumentation"
  }
}

Input Schema

NameRequiredDescriptionDefault
tagNovmp
modeNoast
clearNo
limitNo
stageNo
actionYes
injectNo
sourceNo
after_seqNo
clear_logNo
frame_urlNo
frame_nameNo
ignore_cspNo
key_filterNo
seq_windowNo
tag_filterNo
wait_untilNoload
frame_indexNo
output_pathNo
source_pathNo
type_filterNo
url_patternNo
max_rewritesNo
on_oversizedNoselective
max_file_sizeNo
rewrite_callsNo
inject_validateNo
tap_stage_callsNo
fallback_on_errorNo
filter_object_namesNo
include_source_siteNo
filter_property_namesNo
rewrite_member_accessNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.12.0
    • addedInput schema / properties / inject
      Added value: +{
      +  "items": {
      +    "additionalProperties": true,
      +    "type": "object"
      +  },
      +  "title": "Inject",
      +  "type": "array"
      +}
    • addedInput schema / properties / inject_validate
      Added value: +{
      +  "default": true,
      +  "title": "Inject Validate",
      +  "type": "boolean"
      +}
  2. Changed8 schema fields changedv1.10.0
    • addedInput schema / properties / after_seq
      Added value: +{
      +  "title": "After Seq",
      +  "type": "integer"
      +}
    • changedInput schema / properties / max_file_size / default
      Previous value: -200000New value: +2000000
    • addedInput schema / properties / output_path
      Added value: +{
      +  "title": "Output Path",
      +  "type": "string"
      +}
    • changedInput schema / properties / rewrite_calls / default
      Previous value: -trueNew value: +false
    • addedInput schema / properties / seq_window
      Added value: +{
      +  "items": {
      +    "type": "integer"
      +  },
      +  "title": "Seq Window",
      +  "type": "array"
      +}
    • addedInput schema / properties / source
      Added value: +{
      +  "title": "Source",
      +  "type": "string"
      +}
    • addedInput schema / properties / source_path
      Added value: +{
      +  "title": "Source Path",
      +  "type": "string"
      +}
    • addedInput schema / properties / stage
      Added value: +{
      +  "title": "Stage",
      +  "type": "integer"
      +}
  3. Changed1 schema field changedv1.9.4
    • addedInput schema / properties / tap_stage_calls
      Added value: +{
      +  "default": false,
      +  "title": "Tap Stage Calls",
      +  "type": "boolean"
      +}
  4. Changed3 schema fields changedv1.8.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"
      +}
  5. Changed1 schema field changedv1.6.0
    • addedInput schema / properties / include_source_site
      Added value: +{
      +  "default": false,
      +  "title": "Include Source Site",
      +  "type": "boolean"
      +}
  6. Changed17 schema fields changedv1.1.1
    • removedInput schema / properties / filter_object_names / anyOf
      Removed value: -[
      -  {
      -    "items": {
      -      "type": "string"
      -    },
      -    "type": "array"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • removedInput schema / properties / filter_object_names / default
      Removed value: -null
    • addedInput schema / properties / filter_object_names / items
      Added value: +{
      +  "type": "string"
      +}
    • addedInput schema / properties / filter_object_names / type
      Added value: +"array"
    • removedInput schema / properties / filter_property_names / anyOf
      Removed value: -[
      -  {
      -    "items": {
      -      "type": "string"
      -    },
      -    "type": "array"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • removedInput schema / properties / filter_property_names / default
      Removed value: -null
    • addedInput schema / properties / filter_property_names / items
      Added value: +{
      +  "type": "string"
      +}
    • addedInput schema / properties / filter_property_names / type
      Added value: +"array"
    • removedInput schema / properties / key_filter / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • removedInput schema / properties / key_filter / default
      Removed value: -null
    • addedInput schema / properties / key_filter / type
      Added value: +"string"
    • removedInput schema / properties / tag_filter / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • removedInput schema / properties / tag_filter / default
      Removed value: -null
    • addedInput schema / properties / tag_filter / type
      Added value: +"string"
    • removedInput schema / properties / type_filter / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • removedInput schema / properties / type_filter / default
      Removed value: -null
    • addedInput schema / properties / type_filter / type
      Added value: +"string"
  7. Addedv1.0.0

TDQS

A4.8/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 behavioral burden and does so richly: it discloses route-registration timing, CSP pre-flight behavior, per-group syntax rollback, literal-region skips, case-label shifting, the 20,000-entry event cap with dropped events, and where injected globals live. These are exactly the non-obvious traits an agent needs before invoking it.

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?

The description is long, but the 33-parameter surface and six actions justify most of the length, and it is front-loaded with the action list before parameter details. Some passages are verbose, and one inject safety-layer example has an awkward truncated snippet, but overall the structure is usable.

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 complex 33-parameter tool with no annotations or output schema, the description is complete enough to call correctly: action semantics, timing, constraints, defaults, and event handling are all covered. Its Returns section is vague ("dict with action-specific results"), leaving install/status response shapes underspecified, but log-specific return details are included.

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% across 33 parameters, so the description must compensate, and it documents nearly every parameter with defaults, valid values, interactions, and constraints. Examples include mode-dependent behavior, filter restrictions in regex mode, after_seq paging with next_after_seq, and output_path rules for rewrite_source.

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 specific verb and resource, "JSVMP source-level instrumentation," and enumerates six actions with what each does and which legacy tool it replaces. An agent can distinguish install, log, stop, reload, status, and rewrite_source without opening the schema.

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

Usage Guidelines5/5

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

It gives explicit when-to-use guidance per action, including the critical timing rule that install must be called before navigate for sync-loaded scripts, with a concrete pattern. It also advises starting with rewrite_member_access and only enabling rewrite_calls when call events are needed because of caller and recursion-depth side effects.

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