Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MCP Integration

B4n1Web includes a Model Context Protocol (MCP) server with 33 tools for AI agent workflows.

What is MCP?

MCP (Model Context Protocol) lets AI agents (Claude, Cursor, etc.) use tools through a standardized interface. B4n1Web’s MCP server exposes browser automation as callable tools.

Quick Start

# Start MCP server
b4n1web mcp

This runs on stdio. Configure your AI client to use it:

Claude Desktop Config

{
  "mcpServers": {
    "b4n1web": {
      "command": "b4n1web",
      "args": ["mcp"]
    }
  }
}

Cursor Config

{
  "mcp": {
    "servers": {
      "b4n1web": {
        "command": "b4n1web",
        "args": ["mcp"]
      }
    }
  }
}

Available Tools (33)

ToolDescription
gotoNavigate to URL and extract content
clickClick element by CSS selector
type_textType text into element
wait_for_selectorWait for element to appear

Content Extraction

ToolDescription
evaluateExecute JavaScript
screenshotTake screenshot
pdfGenerate PDF
get_cookiesGet all cookies
clear_cookiesClear all cookies

Page Interaction

ToolDescription
hoverHover over element
scrollScroll page/element
select_optionSelect dropdown option
key_pressPress keyboard key
upload_fileUpload file to input
download_fileDownload file from URL

Network

ToolDescription
routeAdd network route handler
unrouteRemove route handler
block_resourcesBlock resource types
wait_for_requestWait for request
wait_for_responseWait for response

Browser State

ToolDescription
set_viewportSet viewport size
set_user_agentOverride user agent
set_geolocationSet geolocation
emulate_deviceEmulate device
framesList iframes
iframe_textGet iframe text
iframe_clickClick in iframe
iframe_type_textType in iframe

Utility

ToolDescription
performance_metricsGet Core Web Vitals
save_stateSave cookies/localStorage
load_stateRestore cookies/localStorage
start_contextStart incognito context
quit_contextQuit incognito context

Usage Example (AI Agent)

User: "Go to github.com and get the markdown of the trending page"

AI Agent calls:
1. goto(url="https://github.com/trending", mode="light")
2. Returns: {url, markdown, links, ...}

Daemon Mode

For persistent connections:

# Start daemon
b4n1web daemon start

# Check status
b4n1web daemon status

# Stop daemon
b4n1web daemon stop

The daemon runs the MCP server in background. Useful for long-running agent sessions.


Configuration

Environment Variables

export B4N1WEB_BINARY=/custom/path/b4n1web
export B4N1WEB_CHROMIUM=/usr/bin/chromium

Custom Chromium

The MCP server auto-downloads Chromium for Render mode tools. To use system Chromium:

export B4N1WEB_CHROMIUM=/usr/bin/chromium
b4n1web mcp

All 33 Tools Reference

Each tool returns structured JSON. Example:

{
  "goto": {
    "url": "https://example.com",
    "mode": "light",
    "wait_for": ".content"
  }
}

See CLI Reference for individual tool parameters.


Security

The MCP server runs with your user permissions. It can:

  • Access any URL
  • Take screenshots
  • Download files
  • Execute JavaScript

Only run with trusted AI agents.