Skip to main content

MCP server for browser-use

Project description

browser-mcp

A MCP (Model Control Protocol) server for browser-use library. This package allows AI agents to perform web browsing tasks through a standardized interface.

Installation

You can install the package using pip:

pip install browser-mcp

Or with uv (recommended):

uv pip install browser-mcp

After installation, you'll need to install Playwright's browser dependencies:

playwright install

Alternatively, you can use the browser-mcp-run command which will automatically install these dependencies if they're missing.

Setup

For development, clone the repository and install in development mode:

# Clone the repository
git clone https://github.com/pranav7/browser-mcp.git
cd browser-mcp

# Install dependencies with uv
uv pip install -e .

# Or with pip
pip install -e .

Environment Variables

Create a .env file with your OpenAI API key:

OPENAI_API_KEY=your_api_key_here

Usage

Running the MCP Server

In Development Mode

When working with the package in development mode, you can run it directly with Python:

mcp dev browser_mcp/server.py

In Production

After installing the package from PyPI, you can run it with uvx:

uvx browser-mcp

The package is specifically designed to work with uvx, which allows for more efficient package loading and execution.

With Automatic Dependency Check

You can also use the browser-mcp-run command, which checks for and installs Playwright dependencies automatically before starting the server:

browser-mcp-run

This ensures that all required Playwright browsers are installed on your system.

Using as a Client

from mcp.client import Client

async def main():
    client = await Client.connect()

    # Perform a task with the browser
    result = await client.rpc("perform_task_with_browser",
                             task="Search for the latest news about AI and summarize the top 3 results")
    print(result)

    await client.close()

Programmatic Usage

You can also use the package programmatically:

# In development mode
from src import run

# In production (after installing the package)
# from browser_mcp import run

# Run the MCP server with stdio transport
run(transport="stdio")

# Or with SSE transport
# run(transport="sse")

Available RPC Methods

  • search_web(task: str, model: str = "gpt-4o-mini") - Performs basic web searches using browser-use Agent. The model parameter is optional and defaults to "gpt-4o-mini".
  • search_web_with_planning(task: str, base_model: str = "gpt-4o-mini", planning_model: str = "o3-mini") - Performs complex web searches that require planning. Uses a planner LLM for better task decomposition. Both base_model and planning_model parameters are optional with their respective defaults.

Development

Testing

Tests can be run with:

python -m unittest discover

You can also test the package functionality with:

python test_uvx.py

This script will:

  1. Test importing the package directly (development mode)
  2. Attempt to run it with uvx (production mode)

Note: The uvx test may fail in development mode unless the package is published to PyPI. This is expected behavior.

Publishing to PyPI

This project uses GitHub Actions to automatically publish to PyPI when a new release is created. The workflow:

  1. Builds the package using uv
  2. Publishes it to PyPI using trusted publishing

To create a new release:

  1. Update the version in pyproject.toml
  2. Create a new release on GitHub
  3. The GitHub Action will automatically build and publish the package

License

MIT License

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-0.1.2.tar.gz (7.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-0.1.2-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file browser_mcp-0.1.2.tar.gz.

File metadata

  • Download URL: browser_mcp-0.1.2.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for browser_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2e07d574579973c2388bf4cc57f74e7d491cecfaed727f75dce2a81699cbeaa9
MD5 6213a9687e5da8c8e8e49ca55b1e1b55
BLAKE2b-256 012476f33155f41c1beab4aeb86b42a68a85a12f658489fca0c3041051ba7cdd

See more details on using hashes here.

Provenance

The following attestation bundles were made for browser_mcp-0.1.2.tar.gz:

Publisher: python-publish.yml on pranav7/browser-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file browser_mcp-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: browser_mcp-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for browser_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 733704e5a9fb89bf3e2aa116e00dd6d467ab0fdd92a7dda9920740645dbe8d3b
MD5 17330f9d58480ca25b867b1b35a1f224
BLAKE2b-256 8e3ab563c84fa46f5a8ca8213e646ad1c0cc99a15f56e4d7d4e20881b2854815

See more details on using hashes here.

Provenance

The following attestation bundles were made for browser_mcp-0.1.2-py3-none-any.whl:

Publisher: python-publish.yml on pranav7/browser-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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