Skip to main content

A Model Context Protocol (MCP) server for Browserless.io browser automation

Project description

Browserless MCP Server (Python)

A FastMCP server that exposes Browserless.io browser-automation capabilities as MCP tools. Built in Python with uv, fastmcp, and httpx.


Features

Tool Description
browserless_generate_pdf Convert a URL or HTML to PDF
browserless_take_screenshot Capture full-page or clipped screenshots
browserless_get_content Extract fully-rendered HTML after JS execution
browserless_execute_function Run arbitrary JS inside a real browser
browserless_scrape Extract structured data via CSS selectors
browserless_run_performance_audit Lighthouse performance/accessibility audit
browserless_unblock Bypass bot detection / anti-scraping measures
browserless_execute_browserql Run BrowserQL GraphQL automation queries
browserless_get_websocket_url Build WebSocket URL for Puppeteer/Playwright
browserless_get_health Check Browserless instance health
browserless_get_sessions List active browser sessions
browserless_get_metrics Get instance performance metrics
browserless_configure_connection Update connection settings at runtime

Prerequisites

  • Python ≥ 3.11
  • uv package manager
  • A running Browserless instance

Start Browserless (Docker)

# Quick start (no auth)
docker run -p 3000:3000 ghcr.io/browserless/chromium

# With token
docker run -p 3000:3000 \
  -e TOKEN=my-secret-token \
  -e CONCURRENT=10 \
  ghcr.io/browserless/chromium

Installation

# Clone
git clone https://github.com/your-org/browserless-mcp-python.git
cd browserless-mcp-python

# Install dependencies with uv
uv sync

# Copy and edit config
cp .env.example .env

Edit .env:

BROWSERLESS_HOST=localhost
BROWSERLESS_PORT=3000
BROWSERLESS_TOKEN=my-secret-token
BROWSERLESS_PROTOCOL=http
BROWSERLESS_TIMEOUT=30000
BROWSERLESS_CONCURRENT=5

Running

# Via uv
uv run browserless-mcp

# Or directly
uv run python src/browserless_mcp/server.py

# Or after installing
pip install -e .
browserless-mcp

Claude Desktop Configuration

Add to ~/.config/claude/claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "browserless": {
      "command": "uvx",
      "args": ["browserless-mcp"],
      "env": {
        "BROWSERLESS_HOST": "localhost",
        "BROWSERLESS_PORT": "3000",
        "BROWSERLESS_TOKEN": "your-token"
      }
    }
  }
}

Tool Examples

Generate PDF

{
  "name": "browserless_generate_pdf",
  "arguments": {
    "url": "https://example.com",
    "options": {
      "format": "A4",
      "printBackground": true,
      "margin": { "top": "20mm", "bottom": "10mm", "left": "10mm", "right": "10mm" }
    }
  }
}

Take Screenshot

{
  "name": "browserless_take_screenshot",
  "arguments": {
    "url": "https://example.com",
    "options": { "type": "png", "fullPage": true }
  }
}

Extract Content

{
  "name": "browserless_get_content",
  "arguments": {
    "url": "https://example.com",
    "waitForSelector": { "selector": "#main-content", "timeout": 5000 }
  }
}

Scrape Structured Data

{
  "name": "browserless_scrape",
  "arguments": {
    "url": "https://news.ycombinator.com",
    "elements": [
      { "selector": ".titleline > a" },
      { "selector": ".score" }
    ]
  }
}

Execute Custom JS

{
  "name": "browserless_execute_function",
  "arguments": {
    "code": "export default async function ({ page }) { await page.goto('https://example.com'); const title = await page.title(); return { data: { title }, type: 'application/json' }; }"
  }
}

Performance Audit

{
  "name": "browserless_run_performance_audit",
  "arguments": {
    "url": "https://example.com",
    "config": {
      "extends": "lighthouse:default",
      "settings": { "onlyCategories": ["performance", "accessibility"] }
    }
  }
}

Bypass Bot Detection

{
  "name": "browserless_unblock",
  "arguments": {
    "url": "https://protected-site.com",
    "content": true,
    "screenshot": true,
    "stealth": true,
    "blockAds": true
  }
}

BrowserQL Query

{
  "name": "browserless_execute_browserql",
  "arguments": {
    "query": "mutation { goto(url: \"https://example.com\") { status } screenshot { base64 } }"
  }
}

Project Structure

browserless-mcp-python/
├── src/
│   └── browserless_mcp/
│       ├── __init__.py       # Package metadata
│       ├── config.py         # Env-based configuration
│       ├── client.py         # Shared httpx HTTP helpers
│       └── server.py         # FastMCP server + all tools
├── .env.example              # Example environment config
├── pyproject.toml            # uv/hatch build config
└── README.md

Environment Variables

Variable Default Description
BROWSERLESS_HOST localhost Browserless host
BROWSERLESS_PORT 3000 Browserless port
BROWSERLESS_TOKEN (empty) Auth token (required for secured instances)
BROWSERLESS_PROTOCOL http http, https, ws, or wss
BROWSERLESS_TIMEOUT 30000 Request timeout in milliseconds
BROWSERLESS_CONCURRENT 5 Max concurrent sessions (informational)

License

MIT

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

browserless_mcp-0.0.0.tar.gz (80.4 kB view details)

Uploaded Source

Built Distribution

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

browserless_mcp-0.0.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file browserless_mcp-0.0.0.tar.gz.

File metadata

  • Download URL: browserless_mcp-0.0.0.tar.gz
  • Upload date:
  • Size: 80.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for browserless_mcp-0.0.0.tar.gz
Algorithm Hash digest
SHA256 b3f68a67dd192f7c8c08c2d639efecbc8b48e05190ad58d7f4b3236a488bd304
MD5 7be8c35270272af7e719fc9aeea93915
BLAKE2b-256 f7ed6662fb54eb4fca7476f0fd8ffebbff7e93f218674f103f4d36a417dd3560

See more details on using hashes here.

File details

Details for the file browserless_mcp-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: browserless_mcp-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for browserless_mcp-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3e360705c4219a16624de9b1a4a320a76e338d5802d9f0a14aa2512d427f112e
MD5 5b1392febdc3868121d7b40a15d679d8
BLAKE2b-256 595869aba6a3f976ac04d337abe6c55366354424721398aefe1db095b2d5e056

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