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.1.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.1.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: browserless_mcp-0.1.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.1.0.tar.gz
Algorithm Hash digest
SHA256 eac9db55b10e28c739827f002be1a24258e9753dd4026e0e2605bf99531e676d
MD5 f22536bb0cbf73a585f89b2e507b3494
BLAKE2b-256 42f5985c31c59baf64936b1659d5f85475d653cf1c5bb42882bbb228a22c2d65

See more details on using hashes here.

File details

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

File metadata

  • Download URL: browserless_mcp-0.1.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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a5f2f53593ee25db1b64f14b8d7e1e05786116998fc836bb115facbfcbf9eb6
MD5 1d2da2b23b0281c5d78a87a11a770907
BLAKE2b-256 b481fafaad4399deb74cbbb3cf1f236d06b7d8c7e787734031ac7380ee9ec3e7

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