Stealth browser automation for AI agents over MCP and the Chrome DevTools Protocol: navigation, network hooks, DOM extraction, and pixel-accurate UI cloning.
Python ai-agent-toolsai-toolsanthropicanti-bot-bypassautomation-toolsbrowser-automationchrome-devtoolsclaude-mcpcloudflare-bypassdeveloper-toolsfastmcpmcp-servermodel-context-protocolnetwork-interceptionnodriverpythonstealth-browserundetectable-browserweb-automationweb-scraping
Remove broken network hook functions and update docs
Vibhek Soni9d7932b195a1
diff --git a/.gitignore b/.gitignoreindex 1b970f2..71da924 100644--- a/.gitignore+++ b/.gitignore@@ -238,4 +238,5 @@ $RECYCLE.BIN/oldstuff/old_network_hook_system/element_clones/-.claude\ No newline at end of file+.claude+youtube_signin_button_clone.htmldiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 763f099..1cc8e06 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.The format is based on Keep a Changelog and adheres to Semantic Versioning where practical.-## [0.2.0] - 2025-08-09+## [0.2.1] - 2025-08-09### Added- **π Dynamic Network Hook System** - AI-powered request/response interception- **π§ AI Hook Learning System** - 10 comprehensive hook examples and documentation@@ -16,11 +16,25 @@ The format is based on Keep a Changelog and adheres to Semantic Versioning where- RequestId type conversion issues in CDP calls- Missing imports in hook learning system- Syntax errors in browser manager integration+- **Smithery.ai deployment Docker build failure** - Added `git` to Dockerfile system dependencies for py2js installation+- **Smithery.ai PORT environment variable support** - Server now reads PORT env var as required by Smithery deployments+- **Docker health check endpoint** - Updated health check to use correct /mcp endpoint with dynamic PORT### Changed- Replaced old network hook system with dynamic architecture- Updated documentation to reflect new capabilities-- Enhanced MCP tool count to 96+ functions+- **Removed 13 broken/incomplete network hook functions** - Moved to `oldstuff/old_funcs.py` for reference+- **Corrected MCP tool count to 88 functions** - Updated all documentation consistently++### Removed+- `create_request_hook`, `create_response_hook`, `create_redirect_hook`, `create_block_hook`, `create_custom_response_hook` - These functions were calling non-existent methods+- `list_network_hooks`, `get_network_hook_details`, `remove_network_hook`, `update_network_hook_status` - Management functions for the broken hook system+- `list_pending_requests`, `get_pending_request_details`, `modify_pending_request`, `execute_pending_request` - Pending request management (replaced by real-time dynamic hooks)++## [0.2.0] - 2025-08-08+### Added+- Initial dynamic network hook system implementation+- Real-time request/response processing architecture## [0.1.0] - 2025-08-07### Addeddiff --git a/COMPARISON.md b/COMPARISON.mdindex 3420351..b651703 100644--- a/COMPARISON.md+++ b/COMPARISON.md@@ -12,7 +12,7 @@| **Element Cloning Accuracy** | β CDP-Perfect | β οΈ Limited | β οΈ Basic | β οΈ Basic || **Network Interception** | β Full CDP Access | β οΈ Basic | β None | β οΈ Limited || **AI Integration** | β Native MCP | β Custom Setup | β Custom Setup | β Custom Setup |-| **Function Count** | β 93 Tools | β οΈ ~20 | β οΈ ~15 | β οΈ ~15 |+| **Function Count** | β 88 Tools | β οΈ ~20 | β οΈ ~15 | β οΈ ~15 || **Python in Browser** | β py2js Integration | β Not Supported | β Not Supported | β Not Supported |## π **Real-World Test Results**@@ -40,7 +40,7 @@### 2. **CDP-Level Access**- Direct Chrome DevTools Protocol integration-- 93 specialized tools vs competitors' ~20+- 88 specialized tools vs competitors' ~20- Pixel-perfect element extraction### 3. **AI-First Design**diff --git a/Checklist.md b/Checklist.mdindex 9a850ad..c7ddb78 100644--- a/Checklist.md+++ b/Checklist.md@@ -151,13 +151,14 @@15. **Debug Functions Hanging** β Added pagination and timeout protection (get_debug_view β , clear_debug_view β , export_debug_logs β )16. **Execute Python in Browser Hanging & Translation Errors** β Fixed with proper py2js transpiler from am230/py2js - now handles functions, loops, variables correctly with only minor class edge cases17. **Export Debug Logs Lock Deadlock** β Fixed with lock-free fallback and ownership tracking - now works perfectly β+18. **Broken Network Hook Functions** β Removed 13 incomplete/broken functions (create_request_hook, create_response_hook, etc.) that called non-existent methods - moved to oldstuff/old_funcs.py for reference## π **TESTING SUMMARY**-- **Total Functions**: 105+ functions-- **Tested & Working**: 90+ functions β+- **Total Functions**: 88 functions+- **Tested & Working**: 88 functions β- **Functions with Issues**: 0 functions β-- **Major Issues Fixed**: 18 critical issues resolved+- **Major Issues Fixed**: 19 critical issues resolved- **Success Rate**: 100% π― π**LATEST ACHIEVEMENT:**diff --git a/Dockerfile b/Dockerfileindex 9f82417..01c35ee 100644--- a/Dockerfile+++ b/Dockerfile@@ -1,13 +1,14 @@# Use Python 3.11 slim image for smaller sizeFROM python:3.11-slim-# Install system dependencies for Chrome and browser automation+# Install system dependencies for Chrome, browser automation, and git (needed for py2js)RUN apt-get update && apt-get install -y \wget \gnupg \unzip \curl \xvfb \+ git \&& apt-get clean \&& rm -rf /var/lib/apt/lists/*@@ -35,12 +36,13 @@ COPY . .RUN useradd -m -u 1000 mcpuser && chown -R mcpuser:mcpuser /appUSER mcpuser-# Expose port (Smithery expects HTTP server)+# Expose port (Smithery will set PORT env var)EXPOSE 8000+ENV PORT=8000-# Health check for FastMCP HTTP server (406 response is expected/healthy)+# Health check for FastMCP HTTP server (uses PORT env var)HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \- CMD curl -s http://localhost:8000/mcp/ -o /dev/null || exit 1+ CMD curl -s http://localhost:$PORT/mcp -o /dev/null || exit 1-# Start the MCP server with HTTP transport-CMD ["python", "src/server.py", "--transport", "http", "--port", "8000"]\ No newline at end of file+# Start the MCP server with HTTP transport (reads PORT env var automatically)+CMD ["python", "src/server.py", "--transport", "http", "--host", "0.0.0.0"]\ No newline at end of filediff --git a/README.md b/README.mdindex 701a342..9bec979 100644--- a/README.md+++ b/README.md@@ -18,13 +18,24 @@ Supercharge any MCP-compatible AI agent with undetectable, real-browser automati[](https://github.com/vibheksoni/stealth-browser-mcp/issues)[](CONTRIBUTING.md)[](https://discord.gg/7ETmqgTY6H)-[](#-toolbox)+[](#-toolbox)[](#-stealth-vs-playwright-mcp)[](#-why-developers-star-this)[](LICENSE)> Give your AI agent real browser superpowers: access Cloudflare sites, extract any UI, and intercept network traffic β from inside your chat.+## π₯ **See It In Action**++<div align="center">+<video width="800" height="450" controls preload="metadata" style="max-width: 100%; height: auto; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);">+ <source src="media/Showcase Stealth Browser Mcp.mp4" type="video/mp4">+ <p>Your browser doesn't support HTML5 video. <a href="media/Showcase Stealth Browser Mcp.mp4">Download the video</a> to see Stealth Browser MCP in action.</p>+</video>+</div>++*π― **Watch**: Stealth Browser MCP bypassing Cloudflare, cloning UI elements, and intercepting network traffic β all through simple AI chat commands*+---## π Quick Links@@ -33,7 +44,7 @@ Supercharge any MCP-compatible AI agent with undetectable, real-browser automati- π [Hall of Fame](HALL_OF_FAME.md) - Impossible automations made possible- π₯ [Stealth vs Others](COMPARISON.md) - Why we dominate the competition- π₯ [Viral Examples](examples/claude_prompts.md) - Copy & paste prompts that blow minds-- π§° [105 Tools](#toolbox) - Complete arsenal of browser automation+- π§° [88 Tools](#toolbox) - Complete arsenal of browser automation- π₯ [Live Demos](demo/) - See it bypass what others can't- π€ [Contributing](#contributing) & π¬ [Discord](https://discord.gg/7ETmqgTY6H)@@ -115,7 +126,7 @@ Restart your MCP client and ask your agent:- **Full network debugging through AI chat β see every request, response, header, and payload**- **Your AI agent becomes a network detective β no more guessing what APIs are being called**- Clean MCP integration β no custom brokers or wrappers needed-- 105 focused tools designed for real-world workflows+- 88 focused tools designed for real-world workflows> Built on [nodriver](https://github.com/ultrafunkamsterdam/nodriver) + Chrome DevTools Protocol + FastMCP@@ -132,7 +143,7 @@ Restart your MCP client and ask your agent:| Network debugging | **AI agent sees all requests/responses** | Basic || API reverse engineering | **Full payload inspection via chat** | Manual tools only || Dynamic Hook System | **AI writes Python functions for real-time request processing** | Not available |-| Tooling | 105 | ~20 |+| Tooling | 88 | ~20 |Sites users care about: LinkedIn β’ Instagram β’ Twitter/X β’ Amazon β’ Banking β’ Government portals β’ Cloudflare APIs β’ Nike SNKRS β’ Ticketmaster β’ Supremediff --git a/demo/README.md b/demo/README.mdindex 1274557..2631bb0 100644--- a/demo/README.md+++ b/demo/README.md@@ -26,7 +26,7 @@- [ ] "Stealth vs Playwright: Cloudflare Challenge"- [ ] "Stealth vs Selenium: Banking Portal Test"-- [ ] "93 Tools in 3 Minutes: Full Feature Demo"+- [ ] "88 Tools in 3 Minutes: Full Feature Demo"- [ ] "AI Agent Clones Airbnb Homepage in Real-Time"## π― **Use Case Demos**diff --git a/media/Showcase Stealth Browser Mcp.mp4 b/media/Showcase Stealth Browser Mcp.mp4new file mode 100644index 0000000..ec0fe65Binary files /dev/null and b/media/Showcase Stealth Browser Mcp.mp4 differdiff --git a/smithery.yaml b/smithery.yamlindex a63e02c..7da25d8 100644--- a/smithery.yaml+++ b/smithery.yaml@@ -33,5 +33,5 @@ startCommand:timeout: 30000env:- NODE_ENV: "production"- PYTHONUNBUFFERED: "1"\ No newline at end of file+ PYTHONUNBUFFERED: "1"+ PYTHONDONTWRITEBYTECODE: "1"\ No newline at end of filediff --git a/src/server.py b/src/server.pyindex 8a374eb..7926989 100644--- a/src/server.py+++ b/src/server.py@@ -2336,291 +2336,6 @@ async def get_function_executor_info(return await cdp_function_executor.get_function_executor_info(instance_id)-# Network Hook Management Functions--async def create_request_hook(- name: str,- url_pattern: str,- action: str,- modifications: Optional[Dict[str, Any]] = None,- instance_ids: Optional[List[str]] = None,- resource_type: Optional[str] = None,- priority: int = 100-) -> Dict[str, Any]:- """- Create a new request hook to intercept and modify outgoing network requests.-- Args:- name (str): Human-readable hook name- url_pattern (str): URL pattern to match (supports wildcards like *.example.com)- action (str): Action to take - 'modify', 'block', 'redirect', 'fulfill', or 'log'- modifications (Optional[Dict[str, Any]]): Modifications to apply (for modify action)- instance_ids (Optional[List[str]]): Browser instances to apply hook to (all if None)- resource_type (Optional[str]): Resource type filter (image, stylesheet, script, etc.)- priority (int): Hook priority (lower = higher priority)-- Returns:- Dict[str, Any]: Hook creation result with hook_id- """- return await network_hook_ai.create_request_hook(- name=name,- url_pattern=url_pattern,- action=action,- modifications=modifications,- instance_ids=instance_ids,- resource_type=resource_type,- priority=priority- )---async def create_response_hook(- name: str,- url_pattern: str,- action: str,- modifications: Optional[Dict[str, Any]] = None,- instance_ids: Optional[List[str]] = None,- resource_type: Optional[str] = None,- priority: int = 100-) -> Dict[str, Any]:- """- Create a new response hook to intercept and modify incoming network responses.-- Args:- name (str): Human-readable hook name- url_pattern (str): URL pattern to match- action (str): Action to take - 'modify', 'block', 'fulfill', or 'log'- modifications (Optional[Dict[str, Any]]): Modifications to apply- instance_ids (Optional[List[str]]): Browser instances to apply hook to- resource_type (Optional[str]): Resource type filter- priority (int): Hook priority-- Returns:- Dict[str, Any]: Hook creation result with hook_id- """- return await network_hook_ai.create_response_hook(- name=name,- url_pattern=url_pattern,- action=action,- modifications=modifications,- instance_ids=instance_ids,- resource_type=resource_type,- priority=priority- )---async def create_redirect_hook(- name: str,- url_pattern: str,- redirect_url: str,- instance_ids: Optional[List[str]] = None,- priority: int = 100-) -> Dict[str, Any]:- """- Create a hook that redirects matching requests to a different URL.-- Args:- name (str): Hook name- url_pattern (str): Pattern to match- redirect_url (str): URL to redirect to- instance_ids (Optional[List[str]]): Browser instances- priority (int): Hook priority-- Returns:- Dict[str, Any]: Hook creation result- """- return await network_hook_ai.create_redirect_hook(- name=name,- url_pattern=url_pattern,- redirect_url=redirect_url,- instance_ids=instance_ids,- priority=priority- )---async def create_block_hook(- name: str,- url_pattern: str,- instance_ids: Optional[List[str]] = None,- resource_type: Optional[str] = None,- priority: int = 100-) -> Dict[str, Any]:- """- Create a hook that blocks matching requests.-- Args:- name (str): Hook name- url_pattern (str): Pattern to match and block- instance_ids (Optional[List[str]]): Browser instances- resource_type (Optional[str]): Resource type filter- priority (int): Hook priority-- Returns:- Dict[str, Any]: Hook creation result- """- return await network_hook_ai.create_block_hook(- name=name,- url_pattern=url_pattern,- instance_ids=instance_ids,- resource_type=resource_type,- priority=priority- )---async def create_custom_response_hook(- name: str,- url_pattern: str,- response_data: Dict[str, Any],- instance_ids: Optional[List[str]] = None,- priority: int = 100-) -> Dict[str, Any]:- """- Create a hook that fulfills requests with custom responses.-- Args:- name (str): Hook name- url_pattern (str): URL pattern to match- response_data (Dict[str, Any]): Response data (status, headers, body)- instance_ids (Optional[List[str]]): Browser instances- priority (int): Hook priority-- Returns:- Dict[str, Any]: Hook creation result- """- return await network_hook_ai.create_custom_response_hook(- name=name,- url_pattern=url_pattern,- response_data=response_data,- instance_ids=instance_ids,- priority=priority- )---async def list_network_hooks(instance_id: Optional[str] = None) -> Dict[str, Any]:- """- List all network hooks with their details.-- Args:- instance_id (Optional[str]): Filter by browser instance (all if None)-- Returns:- Dict[str, Any]: List of hooks with details- """- return await network_hook_ai.list_hooks(instance_id)---async def get_network_hook_details(hook_id: str) -> Dict[str, Any]:- """- Get detailed information about a specific network hook.-- Args:- hook_id (str): Hook identifier-- Returns:- Dict[str, Any]: Detailed hook information- """- return await network_hook_ai.get_hook_details(hook_id)---async def remove_network_hook(hook_id: str) -> Dict[str, Any]:- """- Remove a network hook by ID.-- Args:- hook_id (str): Hook identifier to remove-- Returns:- Dict[str, Any]: Removal result- """- return await network_hook_ai.remove_hook(hook_id)---async def update_network_hook_status(hook_id: str, status: str) -> Dict[str, Any]:- """- Update the status of a network hook.-- Args:- hook_id (str): Hook identifier- status (str): New status - 'active', 'inactive', or 'paused'-- Returns:- Dict[str, Any]: Update result- """- return await network_hook_ai.update_hook_status(hook_id, status)---async def list_pending_requests(instance_id: Optional[str] = None) -> Dict[str, Any]:- """- List pending network requests in the interception queue.- These are requests that have been paused and can be modified.-- Args:- instance_id (Optional[str]): Filter by browser instance-- Returns:- Dict[str, Any]: List of pending requests- """- return await network_hook_ai.list_pending_requests(instance_id)---async def get_pending_request_details(request_id: str) -> Dict[str, Any]:- """- Get detailed information about a pending request.-- Args:- request_id (str): Request identifier-- Returns:- Dict[str, Any]: Request details- """- return await network_hook_ai.get_pending_request_details(request_id)---async def modify_pending_request(- request_id: str,- modifications: Dict[str, Any]-) -> Dict[str, Any]:- """- Modify a pending network request before it's executed.-- Args:- request_id (str): Request identifier- modifications (Dict[str, Any]): Modifications (url, method, headers, post_data, etc.)-- Returns:- Dict[str, Any]: Modification result- """- return await network_hook_ai.modify_pending_request(request_id, modifications)---async def execute_pending_request(instance_id: str, request_id: str) -> Dict[str, Any]:- """- Execute a pending request with its current modifications.-- Args:- instance_id (str): Browser instance ID- request_id (str): Request identifier to execute-- Returns:- Dict[str, Any]: Execution result- """- tab = await browser_manager.get_tab(instance_id)- if not tab:- return {"success": False, "error": f"Instance not found: {instance_id}"}-- return await network_hook_ai.execute_pending_request(tab, request_id)# Dynamic Hook System Functions (New AI-Generated Hook System)@@ -2806,7 +2521,7 @@ if __name__ == "__main__":parser = argparse.ArgumentParser(description="Stealth Browser MCP Server")parser.add_argument("--transport", choices=["stdio", "http"], default="stdio",help="Transport protocol to use")- parser.add_argument("--port", type=int, default=8000,+ parser.add_argument("--port", type=int, default=int(os.getenv("PORT", 8000)),help="Port for HTTP transport")parser.add_argument("--host", default="0.0.0.0",help="Host for HTTP transport")