mcp_py_sse_browser_control

mcp_py_sse_browser_control

3.3

This project provides a way to execute JavaScript code in a browser from Python using MCP (Model Control Protocol).

The Browser JavaScript Evaluator is a project designed to execute JavaScript code in a browser environment from a Python-based MCP server. It consists of two main components: a web server and an MCP server. The web server handles browser connections via Server-Sent Events (SSE) and provides a REST API for executing JavaScript, returning results synchronously. The MCP server manages the lifecycle of the web server, provides MCP tools for executing JavaScript, and communicates with the web server through REST API calls. The process involves the MCP server starting the web server, a browser connecting via SSE, and the execution of JavaScript code through REST API calls, with results being returned to the caller.

Features

  • Execute JavaScript code in a browser from Python using MCP.
  • Web server handles browser connections via Server-Sent Events (SSE).
  • REST API endpoint for executing JavaScript and returning results synchronously.
  • MCP server manages the lifecycle of the web server and provides MCP tools.
  • Communication between MCP server and web server via REST API calls.

MCP Tools

  • {'execute_javascript': 'Execute arbitrary JavaScript code in the browser.'}
  • {'add_numbers': 'Add two numbers together using JavaScript in the browser.'}

Usage with Different Platforms

Add the MCP server to your Claude config


  ...
  "browser-js-evaluator": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/this/repo/mcp_py_sse_browser_control",
        "run",
        "browser_server.py"
      ]
    }
  ...

Run the web server independently

bash
python web_server.py