Camoufox Unified MCP Server
Camoufox Unified MCP Server
Model Context Protocol (MCP) server for stealth browser automation and anti-detection web interaction, powered by the Camoufox modified Firefox Gecko engine.
1. Project Overview
The Camoufox Unified MCP Server provides AI agents with a standardized, protocol-level interface to execute browser automation under strict anti-bot and Web Application Firewall (WAF) environments.
By integrating the architectural paradigms of community implementations, this project synthesizes:
Enterprise-grade session lifecycle management, including state serialization (Cookies and LocalStorage) and automated cookie consent banner dismissal, pioneered in the Node.js implementation by baixianger.
Comprehensive atomic browser controls and Python-native asynchronous execution pipelines, demonstrated in the Python CLI and MCP implementations by rlgrpe.
This unified server is engineered entirely in Python on top of the Model Context Protocol SDK and the official Camoufox browser library by daijro.
2. Technical Architecture
2.1 Gecko Engine-Level Anti-Fingerprinting
Standard automation frameworks (e.g., standard Playwright or Puppeteer on Chromium) operate via JavaScript prototype shims or CDP flags that remain vulnerable to runtime detection:
Prototype pollution probes (e.g., inspecting Object.getOwnPropertyDescriptor on navigator properties).
Chromium-specific leaks (e.g., window.chrome, Blink rendering memory artifacts, V8 stack trace anomalies).
Automated TLS/JA3/JA4 fingerprinting designed specifically to flag automated Chromium clients.
Camoufox resolves these vulnerabilities at the C++ source level within the Mozilla Firefox (Gecko) engine:
Hardware and platform virtualization: Native spoofing of hardwareConcurrency, deviceMemory, screen dimensions, color depth, and system fonts without JavaScript runtime overhead.
Canvas, WebGL, and AudioContext noise injection: Deterministic or randomized mathematical jitter applied directly within the graphics and audio rendering pipelines.
Native Firefox TLS/HTTP2 stack: Inherits genuine Firefox network signatures, circumventing anti-bot algorithms that target Chromium automation headers.
2.2 Asynchronous Architecture and Concurrency Model
The server uses FastMCP over standard I/O (stdio) transport:
State Synchronization: A singleton CamoufoxManager coordinates browser processes using asyncio.Lock, ensuring thread safety across concurrent tool invocations.
Lazy Initialization: The browser process is not spawned at server startup. Resources are allocated only upon the first invocation requiring browser interaction, conserving memory during inactive periods.
Dual-Mode Session Isolation: Supports independent BrowserContext instances per session identifier. Each session operates with discrete cache directories, cookie stores, and LocalStorage databases.
2.3 State Serialization Pipeline
Session persistence utilizes Playwright Storage State specifications:
Data Schema: Serializes all active session cookies (including secure, httpOnly, and SameSite attributes) alongside origins-level LocalStorage key-value pairs into structured JSON representations.
Portability: Serialized states can be saved to disk, transferred across environments, and injected into newly instantiated BrowserContext instances prior to page navigation, bypassing redundant authentication flows.
2.4 Humanized Behavioral Simulation
To defeat behavioral analysis heuristics (e.g., Cloudflare Turnstile, DataDome mouse tracking):
Cursor Trajectories: Mouse movements follow cubic Bezier curves with randomized control points, velocity variance, and simulated overshoot rather than linear or instantaneous coordinate jumps.
Keystroke Timing: Text input simulates human typing cadence using randomized Gaussian intervals per character, including micro-delays between words.
Smooth Scrolling: Wheel events are segmented into incremental step bursts with decaying velocity.
2.5 Heuristic Consent Banner Dismissal
An automated banner resolution subsystem scans active pages against a priority matrix of known consent management platforms:
Vendor Selectors: OneTrust, Cookiebot, Klaro, TrustArc, and Osano.
Heuristic Selectors: Generalized attribute matching for button elements containing consent-related identifiers across multiple language encodings (English, Simplified Chinese, Traditional Chinese).
3. Tool Reference
The server exposes 19 discrete tools grouped into functional subsystems:
3.1 Session and Authentication Tools
Tool Name | Parameters | Type | Description |
create_session | session_id (str, default: "default")os_target (str, optional)proxy (str, optional)headless (bool, default: False)storage_state_path (str, optional) | String | Instantiates an isolated browser context. Supports OS emulation ("windows", "macos", "linux"), HTTP/SOCKS proxy configuration, and pre-loaded session state injection. |
save_session | output_path (str)session_id (str, optional) | String | Serializes and exports current session cookies and LocalStorage to the designated JSON filepath. |
load_session | input_path (str)session_id (str, optional) | String | Imports a JSON storage state file into an active or newly initialized session context. |
list_sessions | None | JSON | Returns metadata of all active sessions, including tab counts, active tab indices, and current URLs. |
close_session | session_id (str, optional) | String | Terminates the specified session context and closes all affiliated pages. |
3.2 Navigation and Tab Control Tools
Tool Name | Parameters | Type | Description |
navigate | url (str)session_id (str, optional)wait_until (str, default: "load")timeout_ms (int, default: 30000)dismiss_cookies (bool, default: True) | JSON | Navigates the active tab to a URL. Automatically performs heuristic cookie banner dismissal when enabled. |
new_tab | url (str, optional)session_id (str, optional) | JSON | Spawns a new page within the session and sets it as the active tab. |
list_tabs | session_id (str, optional) | JSON | Lists all open tabs in the session with numerical indices, titles, and URLs. |
switch_tab | tab_index (int)session_id (str, optional) | JSON | Sets the specified tab index as active and brings the page to front. |
close_tab | tab_index (int, optional)session_id (str, optional) | String | Closes the target tab or the currently active tab if omitted. |
3.3 Humanized Interaction Tools
Tool Name | Parameters | Type | Description |
click | selector (str)humanize (bool, default: True)session_id (str, optional)timeout_ms (int, default: 10000) | String | Locates the element, calculates a randomized inner boundary target, simulates Bezier mouse approach, and clicks. |
type_text | selector (str)text (str)humanize (bool, default: True)clear_first (bool, default: False)session_id (str, optional) | String | Focuses the element and inputs text character-by-character with randomized latency. |
human_scroll | direction (str, default: "down")distance (int, default: 500)session_id (str, optional) | String | Dispatches segmented wheel events simulating physical mouse scrolling. |
wait_for_selector | selector (str)state (str, default: "visible")timeout_ms (int, default: 15000)session_id (str, optional) | String | Blocks execution until the DOM element matches the expected lifecycle state ("visible", "attached", "detached", "hidden"). |
3.4 Extraction and Execution Tools
Tool Name | Parameters | Type | Description |
take_screenshot | path (str, optional)full_page (bool, default: False)session_id (str, optional) | JSON | Captures page viewport or full-page rendering. Saves to local disk or returns base64 string. |
get_page_content | format_type (str, default: "text")selector (str, optional)session_id (str, optional) | String | Extracts innerText or innerHTML from the entire document or a scoped DOM subtree. |
evaluate_js | script (str)session_id (str, optional) | String | Executes JavaScript expressions within the page execution context and returns JSON-serialized output. |
3.5 Anti-Detection Diagnostics Tools
Tool Name | Parameters | Type | Description |
dismiss_cookie_banners | session_id (str, optional) | String | Actively scans and dismisses known modal consent overlays. |
get_fingerprint_info | session_id (str, optional) | JSON | Audits active browser fingerprint traits, including User-Agent, platform, screen resolution, timezone, and concurrency values. |
4. Installation and Setup
4.1 System Prerequisites
Python 3.10 or later.
uv package manager (recommended) or standard pip.
Supported operating systems: Windows, macOS, Linux.
4.2 Installation via UV (Recommended)
Clone or download the repository:
git clone https://github.com/tom613951/camoufox-unified-mcp.git
cd camoufox-unified-mcpCreate an isolated virtual environment:
uv venv .venvInstall project dependencies:
uv pip install -e .Fetch the pre-compiled Camoufox Firefox browser binary:
uv run camoufox fetch4.3 Installation via Pip
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -e .
camoufox fetch5. Client Configuration
Configure the MCP server within your AI client settings file.
5.1 Claude Desktop Configuration
File path:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Configuration:
{
"mcpServers": {
"camoufox": {
"command": "path/to/camoufox-unified-mcp/.venv/bin/python",
"args": [
"path/to/camoufox-unified-mcp/run_mcp.py"
]
}
}
}Windows example:
{
"mcpServers": {
"camoufox": {
"command": "D:\\skills-mcp\\camoufox-unified-mcp\\.venv\\Scripts\\python.exe",
"args": [
"D:\\skills-mcp\\camoufox-unified-mcp\\run_mcp.py"
]
}
}
}5.2 Antigravity / Gemini CLI Configuration
File path: ~/.gemini/config/mcp_config.json
{
"mcpServers": {
"camoufox": {
"command": "D:\\skills-mcp\\camoufox-unified-mcp\\.venv\\Scripts\\python.exe",
"args": [
"D:\\skills-mcp\\camoufox-unified-mcp\\run_mcp.py"
]
}
}
}5.3 Cursor Configuration
In Cursor Settings -> Features -> MCP -> Add New MCP Server:
Name:
camoufoxType:
commandCommand:
D:\skills-mcp\camoufox-unified-mcp\.venv\Scripts\python.exe D:\skills-mcp\camoufox-unified-mcp\run_mcp.py
6. Acknowledgements
This unified project builds upon and synthesizes the foundational contributions of open-source developers:
daijro (Author of daijro/camoufox): For engineering the customized, anti-detection Firefox Gecko engine, automated binary packaging, and the Python library bindings that serve as the foundational runtime for this project.
baixianger (Author of baixianger/camoufox-mcp): For pioneering the MCP session lifecycle architecture, storage state persistence patterns, heuristic consent banner resolution, and high-level agent integration concepts in Node.js.
rlgrpe (Author of rlgrpe/camoufox-browser-cli): For designing the Python FastMCP implementation paradigms, fine-grained atomic browser tool definitions, and lazy resource allocation patterns.
7. License
This project is licensed under the terms of the MIT License. See the LICENSE file for details.