MCP Browser Automation Server logo

MCP Browser Automation Server

by weir1

A simple yet powerful browser automation server that allows you to control browsers, take screenshots, and monitor console logs through a REST API. It provides a convenient way to automate browser tasks.

View on GitHub

Last updated: N/A

What is MCP Browser Automation Server?

MCP Browser Automation Server is a tool that exposes browser automation functionalities through a REST API and WebSocket. It allows users to programmatically control browsers, capture screenshots, and monitor console logs.

How to use MCP Browser Automation Server?

To use the server, first install it following the provided instructions, which include cloning the repository, creating a virtual environment, installing dependencies, and installing Playwright browsers. Then, start the server using python server.py. Interact with the server using HTTP requests to the API endpoints or establish a WebSocket connection to monitor console logs. Example Python code is provided for demonstration.

Key features of MCP Browser Automation Server

  • Create browser sessions

  • Navigate to URLs

  • Take screenshots (full page or specific elements)

  • Click elements

  • Fill form inputs

  • Monitor console logs in real-time through WebSocket

  • Close sessions

Use cases of MCP Browser Automation Server

  • Automated testing

  • Web scraping

  • Monitoring website content

  • Generating website screenshots for documentation

FAQ from MCP Browser Automation Server

How do I create a new session?

Send a POST request to /session/create. The response will contain the session_id.

How do I navigate to a URL?

Send a POST request to /session/{session_id}/navigate?url=https://example.com, replacing {session_id} with the actual session ID.

How do I take a screenshot of a specific element?

Send a POST request to /session/{session_id}/screenshot?name=screenshot1&selector=.my-element, replacing {session_id} with the actual session ID and specifying the CSS selector of the element.

How do I monitor console logs?

Establish a WebSocket connection to /session/{session_id}/console, replacing {session_id} with the actual session ID. Messages will be sent over the WebSocket connection as they appear in the browser console.

How do I close a session?

Send a POST request to /session/{session_id}/close, replacing {session_id} with the actual session ID.