Browser automation MCP server with triple engine (static + selenium + playwright)
Project description
BrowserMCP — Browser Automation MCP Server
Servidor MCP para automatización de navegador web. Navega, extrae contenido, hace clic, rellena formularios, toma capturas de pantalla y más. Arquitectura de triple motor: Selenium (Chromium), Playwright (Chromium) y motor estático (BeautifulSoup) como fallback.
Features / Funcionalidades
| Tool / Herramienta | Description / Descripción |
|---|---|
navigate |
Navega a una URL y devuelve título, URL y texto |
extract |
Extrae texto de elementos CSS selector |
click |
Hace clic en un elemento por selector CSS |
click_by_text |
Hace clic en un botón/enlace por su texto visible (soporta múltiples textos con |) |
fill |
Rellena un campo de formulario con un valor |
run_script |
Ejecuta JavaScript en el navegador y devuelve el resultado |
screenshot |
Toma captura de pantalla (base64 PNG) |
forms |
Lista formularios con campos, labels y tipos |
links |
Lista todos los enlaces (internos/externos) |
scroll |
Desplaza la página (down/up/bottom/top) |
wait |
Espera una cantidad de milisegundos |
engine_info |
Muestra el motor activo (selenium/playwright/static) |
Tech Stack
- Python —
>=3.11 - Framework:
mcp(FastMCP) via stdio JSON-RPC - Selenium Engine:
selenium+ Chromium (headless) - Playwright Engine:
playwright+ Chromium (experimental) - Static Engine:
requests+beautifulsoup4+lxml(fallback)
Selenium Setup / Configuración
El servidor usa Chromium via Selenium en modo headless. Auto-detecta el binario de Chromium.
# Instalar dependencias
pip install mcp selenium beautifulsoup4 lxml requests httpx
# Ejecutar servidor
python server.py
# Forzar motor específico
export BROWSER_ENGINE=selenium # Usar Selenium
export BROWSER_ENGINE=playwright # Usar Playwright (experimental)
export BROWSER_ENGINE=static # Usar motor estático (sin navegador)
export BROWSER_ENGINE=auto # Intentar Selenium, fallback a static (por defecto)
Chromium en Ubuntu
El servidor busca chromium-browser, chromium y la ruta de snap. Si no encuentra Chromium, usar --headless=new.
Triple Engine Architecture
- Selenium (preferred): navegador real — soporta click, fill, screenshot, scroll, JS execution
- Playwright (experimental): navegador real alternativo — soporta mismas capacidades que Selenium
- Static (fallback): solo extracción HTML — no soporta interacciones dinámicas
- Auto (default): intenta Selenium, fallback automático a estático
🔧 Recent Improvements
click_by_textTool — Click buttons, links, or interactive elements by visible text content. Supports multiple texts separated by|(e.g.Postularme|Apply|Aplicar). Uses JavaScript execution to find elements by text, not CSS selectors.run_scriptTool — Execute arbitrary JavaScript in the browser and return the result. Useful for debugging, inspecting page state, and complex interactions.- Improved Label Detection —
get_forms()now also finds labels in<div for="...">elements (not just<label for="...">), with JS-based fallback for React SPAs. - Multiple Submit Fix —
click_by_textavoids clicking the wrong submit button by matching text content ("Responder", "Enviar", etc.) instead of CSS selector. - Headless Mode — Chrome now runs with
--headless=new(no visible windows) - Random Debug Port —
--remote-debugging-port=0+--remote-debugging-address=127.0.0.1(security: no more fixed port 9222 exposed) - Temp Dir Cleanup — Chrome temp directories are cleaned on server shutdown (no disk leaks)
- XPath Injection Fix — Label lookup escapes special characters in form IDs
- Configurable Settings —
CHROME_WINDOW_SIZE,CHROME_LANG,BROWSER_TEXT_MAX,BROWSER_JS_FILL_THRESHOLDenv vars - Playwright Scroll Fix — "bottom" now scrolls to
scrollHeightinstead of fixed 10000px - Playwright Async Fix —
_sync_runusesnew_event_loop()(no more nested event loop deadlocks) - Scroll Case-Insensitive —
DOWN/down/Downall work - Double Truncation Removed — Server no longer applies a second text truncation after the engine
- Client Uses
sys.executable— No more hardcoded.venv/bin/pythonpath - Selenium in CLI —
--engine seleniumnow available in the test client - Dead Dependencies Removed —
httpxandwebsocket-clientcleaned from pyproject.toml
Project Structure
browser-mcp/
├── server.py # MCP server entry point (tools)
├── engines/
│ ├── __init__.py
│ ├── base.py # BaseEngine, PageResult, LinkInfo, FormInfo
│ ├── selenium_engine.py # Selenium/Chromium engine
│ ├── static.py # Static HTML engine (requests + BS4)
│ └── playwright_engine.py # Playwright engine (experimental)
├── client.py # Test client CLI
└── pyproject.toml
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file browser_mcp_automation-1.0.0.tar.gz.
File metadata
- Download URL: browser_mcp_automation-1.0.0.tar.gz
- Upload date:
- Size: 78.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a71d5c72e27bbe535f8ce3d8f024debbbbd74b870ebb3f988974c83f67825737
|
|
| MD5 |
3cc0e76ca9ecfd358220d041e6e2ea05
|
|
| BLAKE2b-256 |
11b362424a6b4eb34fffd9914a6d54aca56910f8edda584e3d2bc915eb93a6db
|
File details
Details for the file browser_mcp_automation-1.0.0-py3-none-any.whl.
File metadata
- Download URL: browser_mcp_automation-1.0.0-py3-none-any.whl
- Upload date:
- Size: 99.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4c2dce01daae0d9195c2717f979acbe021db0ee761d564a62d2ece691730408
|
|
| MD5 |
de3a5b0e7ba55d0a9328ff1ec85c70a1
|
|
| BLAKE2b-256 |
a84571b74d461d2b206df90b367de597c66fde2ba8b09a5f73eedde734b0e1ac
|