compare_env
Collect browser environment fingerprint data to compare with Node.js/jsdom. Specify properties to check or use defaults: navigator, screen, canvas, WebGL, audio, timing.
Instructions
Collect browser environment fingerprint data for comparison with Node.js/jsdom.
Args: properties: Optional list of specific properties to check. If omitted, checks navigator, screen, canvas, WebGL, audio, timing.
Returns: dict with categorized environment data and their values.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| properties | No |
Implementation Reference
- The compare_env tool handler — an MCP tool that collects browser environment fingerprint data (navigator, screen, canvas, WebGL, audio, timing) for comparison with Node.js/jsdom. Decorated with @mcp.tool() to register as an MCP tool.
@mcp.tool() async def compare_env(properties: list[str] | None = None) -> dict: """Collect browser environment fingerprint data for comparison with Node.js/jsdom. Args: properties: Optional list of specific properties to check. If omitted, checks navigator, screen, canvas, WebGL, audio, timing. Returns: dict with categorized environment data and their values. """ try: page = await browser_manager.get_active_page() custom_props_js = "" if properties: custom_props_js = f""" const customProps = {json.dumps(properties)}; for (const prop of customProps) {{ try {{ const val = eval(prop); result.custom[prop] = {{ value: typeof val === 'object' ? JSON.stringify(val).substring(0, 500) : String(val), type: typeof val }}; }} catch(e) {{ result.custom[prop] = {{ value: null, error: e.message }}; }} }}""" result = await page.evaluate(f"""() => {{ const result = {{ navigator: {{}}, screen: {{}}, canvas: {{}}, webgl: {{}}, audio: {{}}, timing: {{}}, misc: {{}}, custom: {{}} }}; const navProps = ['userAgent', 'platform', 'language', 'languages', 'hardwareConcurrency', 'deviceMemory', 'maxTouchPoints', 'vendor', 'cookieEnabled', 'webdriver']; for (const p of navProps) {{ try {{ result.navigator[p] = {{ value: String(navigator[p]), type: typeof navigator[p] }}; }} catch(e) {{ result.navigator[p] = {{ value: null, error: e.message }}; }} }} const screenProps = ['width', 'height', 'availWidth', 'availHeight', 'colorDepth']; for (const p of screenProps) {{ try {{ result.screen[p] = {{ value: screen[p], type: typeof screen[p] }}; }} catch(e) {{ result.screen[p] = {{ value: null, error: e.message }}; }} }} result.screen.devicePixelRatio = {{ value: window.devicePixelRatio, type: 'number' }}; result.timing.timezoneOffset = {{ value: new Date().getTimezoneOffset(), type: 'number' }}; result.timing.timezone = {{ value: Intl.DateTimeFormat().resolvedOptions().timeZone, type: 'string' }}; {custom_props_js} return result; }}""") return result except Exception as e: return {"error": str(e)} - src/camoufox_reverse_mcp/server.py:21-21 (registration)Registration import in server.py — imports the jsvmp module (which contains compare_env) so the @mcp.tool() decorator registers it on the FastMCP server.
from .tools import jsvmp # noqa: E402, F401 — hook_jsvmp_interpreter + compare_env - Fallback helper in trace.py — _fallback_compare_env() calls compare_env when engine-level tracing is not available (i.e., using official Camoufox without enable_trace).
async def _fallback_compare_env(reason: str) -> dict: """Fallback to compare_env when custom browser is not available.""" try: from .jsvmp import compare_env result = await compare_env() except Exception as e: result = {"error": f"compare_env also failed: {e}"} return { "mode": "fallback_compare_env", "reason": reason, "install_hint": ( "To use engine-level tracing:\n" "1. Download camoufox-reverse from GitHub Releases\n" - The function signature itself serves as the schema — parameters are `properties: list[str] | None = None` (optional list of property names to check) and return type is `dict`.
async def compare_env(properties: list[str] | None = None) -> dict: """Collect browser environment fingerprint data for comparison with Node.js/jsdom. Args: properties: Optional list of specific properties to check. If omitted, checks navigator, screen, canvas, WebGL, audio, timing. Returns: dict with categorized environment data and their values.