Skip to main content

Browser automation MCP server with triple engine (static + selenium + playwright)

Project description

BrowserMCP — Browser Automation MCP Server

CI PyPI Python License

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_text Tool — 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_script Tool — Execute arbitrary JavaScript in the browser and return the result. Useful for debugging, inspecting page state, and complex interactions.
  • Improved Label Detectionget_forms() now also finds labels in <div for="..."> elements (not just <label for="...">), with JS-based fallback for React SPAs.
  • Multiple Submit Fixclick_by_text avoids 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 SettingsCHROME_WINDOW_SIZE, CHROME_LANG, BROWSER_TEXT_MAX, BROWSER_JS_FILL_THRESHOLD env vars
  • Playwright Scroll Fix — "bottom" now scrolls to scrollHeight instead of fixed 10000px
  • Playwright Async Fix_sync_run uses new_event_loop() (no more nested event loop deadlocks)
  • Scroll Case-InsensitiveDOWN/down/Down all work
  • Double Truncation Removed — Server no longer applies a second text truncation after the engine
  • Client Uses sys.executable — No more hardcoded .venv/bin/python path
  • Selenium in CLI--engine selenium now available in the test client
  • Dead Dependencies Removedhttpx and websocket-client cleaned 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

browser_mcp_automation-1.0.0.tar.gz (78.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

browser_mcp_automation-1.0.0-py3-none-any.whl (99.9 kB view details)

Uploaded Python 3

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

Hashes for browser_mcp_automation-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a71d5c72e27bbe535f8ce3d8f024debbbbd74b870ebb3f988974c83f67825737
MD5 3cc0e76ca9ecfd358220d041e6e2ea05
BLAKE2b-256 11b362424a6b4eb34fffd9914a6d54aca56910f8edda584e3d2bc915eb93a6db

See more details on using hashes here.

File details

Details for the file browser_mcp_automation-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for browser_mcp_automation-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4c2dce01daae0d9195c2717f979acbe021db0ee761d564a62d2ece691730408
MD5 de3a5b0e7ba55d0a9328ff1ec85c70a1
BLAKE2b-256 a84571b74d461d2b206df90b367de597c66fde2ba8b09a5f73eedde734b0e1ac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page