Skip to content

Stealth browser automation for AI agents over MCP and the Chrome DevTools Protocol: navigation, network hooks, DOM extraction, and pixel-accurate UI cloning.

feat(browser): add Microsoft Edge support with automatic browser detection

Hamza Abbadc1b5189c8cd5
diff --git a/README.md b/README.md
index e60c399..f4df1a6 100644
--- a/README.md
+++ b/README.md
@@ -220,8 +220,8 @@ Restart your MCP client and ask your agent:
- **Check paths**: Make sure the Claude CLI command uses the correct venv path
**❌ Chrome/Browser issues**
-- **Solution**: The server will automatically download Chrome when first run
-- **No manual Chrome installation needed**
+- **Solution**: The server will automatically detect Chrome, Chromium, or Microsoft Edge when first run
+- **No manual browser installation needed** - supports Chrome, Chromium, and Edge
**❌ "Failed to connect to browser" / Root user issues**
- **Solution**: ✅ **FIXED in v0.2.4!** Auto-detects root/administrator and adds `--no-sandbox` automatically
@@ -259,6 +259,8 @@ Restart your MCP client and ask your agent:
- 90 focused tools organized into 11 logical sections
> Built on [nodriver](https://github.com/ultrafunkamsterdam/nodriver) + Chrome DevTools Protocol + FastMCP
+>
+> **🌐 Browser Support**: Chrome • Chromium • Microsoft Edge (automatic detection)
## 🎯 **NEW: Advanced Text Input**
@@ -305,7 +307,7 @@ validate_browser_environment_tool() # Diagnose your environment
- **Root/Administrator Detection**: Auto-adds `--no-sandbox` when running as root
- **Container Detection**: Detects Docker/Kubernetes and adds container-specific args
- **Platform-Aware**: Handles Windows, Linux, macOS differences automatically
-- **Chrome Discovery**: Automatically finds Chrome/Chromium installation
+- **Browser Discovery**: Automatically finds Chrome, Chromium, or Microsoft Edge installation
### 🔧 **Flexible Args Handling**
```json
diff --git a/src/browser_manager.py b/src/browser_manager.py
index 7593559..bd442b2 100644
--- a/src/browser_manager.py
+++ b/src/browser_manager.py
@@ -12,7 +12,7 @@ from debug_logger import debug_logger
from models import BrowserInstance, BrowserState, BrowserOptions, PageState
from persistent_storage import persistent_storage
from dynamic_hook_system import dynamic_hook_system
-from platform_utils import get_platform_info
+from platform_utils import get_platform_info, check_browser_executable
from process_cleanup import process_cleanup
@@ -44,16 +44,32 @@ class BrowserManager:
try:
platform_info = get_platform_info()
+
+ # Detect the best available browser executable (Chrome, Chromium, or Edge)
+ browser_executable = check_browser_executable()
+ if not browser_executable:
+ raise Exception("No compatible browser found (Chrome, Chromium, or Microsoft Edge)")
+
+ # Identify browser type for logging
+ browser_type = "Unknown"
+ if 'edge' in browser_executable.lower() or 'msedge' in browser_executable.lower():
+ browser_type = "Microsoft Edge"
+ elif 'chromium' in browser_executable.lower():
+ browser_type = "Chromium"
+ elif 'chrome' in browser_executable.lower():
+ browser_type = "Google Chrome"
+
debug_logger.log_info(
- "browser_manager",
- "spawn_browser",
- f"Platform info: {platform_info['system']} | Root: {platform_info['is_root']} | Container: {platform_info['is_container']} | Sandbox: {options.sandbox}"
+ "browser_manager",
+ "spawn_browser",
+ f"Platform: {platform_info['system']} | Root: {platform_info['is_root']} | Container: {platform_info['is_container']} | Sandbox: {options.sandbox} | Browser: {browser_type} ({browser_executable})"
)
config = uc.Config(
headless=options.headless,
user_data_dir=options.user_data_dir,
- sandbox=options.sandbox
+ sandbox=options.sandbox,
+ browser_executable_path=browser_executable
)
browser = await uc.start(config=config)
diff --git a/src/platform_utils.py b/src/platform_utils.py
index 4f834cb..3e6730a 100644
--- a/src/platform_utils.py
+++ b/src/platform_utils.py
@@ -134,48 +134,80 @@ def get_platform_info() -> dict:
}
-def check_chrome_executable() -> Optional[str]:
+def check_browser_executable() -> Optional[str]:
"""
- Find the Chrome/Chromium executable on the system.
+ Find a compatible browser executable on the system.
+ Searches for Chrome, Chromium, and Microsoft Edge in order of preference.
Returns:
- Optional[str]: Path to Chrome executable or None if not found
+ Optional[str]: Path to browser executable or None if not found
"""
system = platform.system().lower()
if system == 'windows':
possible_paths = [
+ # Chrome paths
r'C:\Program Files\Google\Chrome\Application\chrome.exe',
r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe',
r'C:\Users\{}\AppData\Local\Google\Chrome\Application\chrome.exe'.format(os.environ.get('USERNAME', '')),
+ # Chromium paths
r'C:\Program Files\Chromium\Application\chromium.exe',
+ # Microsoft Edge paths
+ r'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe',
+ r'C:\Program Files\Microsoft\Edge\Application\msedge.exe',
+ r'C:\Users\{}\AppData\Local\Microsoft\Edge\Application\msedge.exe'.format(os.environ.get('USERNAME', '')),
]
elif system == 'darwin':
possible_paths = [
+ # Chrome paths
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
+ # Chromium paths
'/Applications/Chromium.app/Contents/MacOS/Chromium',
+ # Microsoft Edge paths
+ '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',
]
else:
possible_paths = [
+ # Chrome paths
'/usr/bin/google-chrome',
'/usr/bin/google-chrome-stable',
+ # Chromium paths
'/usr/bin/chromium',
'/usr/bin/chromium-browser',
'/snap/bin/chromium',
'/usr/local/bin/chrome',
+ # Microsoft Edge paths
+ '/usr/bin/microsoft-edge-stable',
+ '/usr/bin/microsoft-edge',
+ '/usr/bin/microsoft-edge-beta',
+ '/usr/bin/microsoft-edge-dev',
+ '/snap/bin/microsoft-edge',
+ '/opt/microsoft/msedge/msedge',
]
+ # First check static paths
for path in possible_paths:
- if os.path.isfile(path) and os.access(path, os.X_OK):
- return path
+ try:
+ if os.path.isfile(path) and os.access(path, os.X_OK):
+ return path
+ except (OSError, PermissionError):
+ # Handle potential permission issues on certain systems
+ continue
- chrome_names = ['google-chrome', 'google-chrome-stable', 'chromium', 'chromium-browser', 'chrome']
- for name in chrome_names:
+ # Fallback: search using 'which' command
+ browser_names = [
+ 'google-chrome', 'google-chrome-stable', 'chromium', 'chromium-browser', 'chrome',
+ 'microsoft-edge-stable', 'microsoft-edge', 'msedge'
+ ]
+ for name in browser_names:
try:
- result = subprocess.run(['which', name], capture_output=True, text=True)
+ result = subprocess.run(['which', name], capture_output=True, text=True, timeout=5)
if result.returncode == 0 and result.stdout.strip():
- return result.stdout.strip()
- except (subprocess.SubprocessError, FileNotFoundError):
+ found_path = result.stdout.strip()
+ # Verify the found executable is actually executable
+ if os.path.isfile(found_path) and os.access(found_path, os.X_OK):
+ return found_path
+ except (subprocess.SubprocessError, FileNotFoundError, subprocess.TimeoutExpired):
continue
return None
@@ -184,18 +216,34 @@ def check_chrome_executable() -> Optional[str]:
def validate_browser_environment() -> dict:
"""
Validate the browser environment and return status information.
+ Checks for Chrome, Chromium, and Microsoft Edge availability.
Returns:
dict: Environment validation results
"""
- chrome_path = check_chrome_executable()
+ browser_path = check_browser_executable()
platform_info = get_platform_info()
issues = []
warnings = []
+ recommendations = []
- if not chrome_path:
- issues.append("Chrome/Chromium executable not found")
+ if not browser_path:
+ issues.append("Compatible browser executable not found (Chrome, Chromium, or Microsoft Edge)")
+ recommendations.append("Install a compatible browser (Chrome, Chromium, or Microsoft Edge)")
+ else:
+ # Identify which browser was found
+ browser_type = "Unknown"
+ if 'chrome' in browser_path.lower():
+ browser_type = "Google Chrome"
+ elif 'chromium' in browser_path.lower():
+ browser_type = "Chromium"
+ elif 'edge' in browser_path.lower() or 'msedge' in browser_path.lower():
+ browser_type = "Microsoft Edge"
+
+ # Add Edge-specific warnings if applicable
+ if browser_type == "Microsoft Edge" and platform_info['system'] == 'Linux':
+ warnings.append("Microsoft Edge on Linux detected - ensure all dependencies are installed")
if platform_info['is_root']:
warnings.append("Running as root/administrator - sandbox will be disabled")
@@ -207,10 +255,12 @@ def validate_browser_environment() -> dict:
warnings.append(f"Untested platform: {platform_info['system']}")
return {
- 'chrome_executable': chrome_path,
+ 'browser_executable': browser_path,
+ 'browser_type': browser_type if browser_path else None,
'platform_info': platform_info,
'issues': issues,
'warnings': warnings,
+ 'recommendations': recommendations,
'is_ready': len(issues) == 0,
'recommended_args': get_required_sandbox_args(),
}
\ No newline at end of file