浏览器操作器
STDIO浏览器自动化MCP服务器
浏览器自动化MCP服务器
A Model Control Protocol (MCP) server for browser automation that enables LLMs to control a web browser, interact with web pages, and analyze web content through a standardized JSON-RPC interface.
Clone this repository:
git clone https://github.com/yourusername/operator-mcp.git
cd operator-mcp
Install dependencies:
pip install -e .
Install Playwright browsers:
playwright install chromium
Set your OpenAI API key:
export OPENAI_API_KEY=your-api-key
Start the MCP server:
./run-server
The server listens for JSON-RPC requests on stdin and responds on stdout, following the MCP protocol.
run-server - Runs the MCP server (main entry point)
# Run the MCP server ./run-server # Run with specific log directory ./run-server --log-dir /path/to/logs # Run in debug mode ./run-server --debug
run-tests - Runs all tests (with options for unit or integration only)
# Run all tests ./run-tests # Run only unit tests (faster) ./run-tests --unit-only # Run only integration tests ./run-tests --integration-only # Run with verbose output ./run-tests --verbose # Run a specific test ./run-tests --test TestBrowserOperatorMethods
run-test-harness - Runs the server with MCP Inspector for interactive testing
# Run with the MCP Inspector for interactive testing ./run-test-harness
Create Browser: Initialize a new browser instance
{ "jsonrpc": "2.0", "id": 1, "method": "mcp__browser-operator__create-browser", "params": { "project_name": "my-project" } }
Navigate Browser: Direct the browser to a specified URL
{ "jsonrpc": "2.0", "id": 2, "method": "mcp__browser-operator__navigate-browser", "params": { "project_name": "my-project", "url": "https://example.com" } }
Operate Browser: Execute natural language instructions for browser interaction
{ "jsonrpc": "2.0", "id": 3, "method": "mcp__browser-operator__operate-browser", "params": { "project_name": "my-project", "instruction": "Find the heading on this page and tell me what it says." } }
Close Browser: Terminate a browser instance
{ "jsonrpc": "2.0", "id": 4, "method": "mcp__browser-operator__close-browser", "params": { "project_name": "my-project" } }
Get Job Status: Retrieve the status and result of an operation by job ID
{ "jsonrpc": "2.0", "id": 5, "method": "mcp__browser-operator__get-job-status", "params": { "job_id": "job-12345" } }
List Jobs: View recent browser operation jobs
{ "jsonrpc": "2.0", "id": 6, "method": "mcp__browser-operator__list-jobs", "params": { "limit": 10 } }
{ "jsonrpc": "2.0", "id": 7, "method": "mcp__browser-operator__add-note", "params": { "name": "My Note", "content": "Important information about this browser session" } }
mcp__browser-tools__getConsoleLogsmcp__browser-tools__getConsoleErrorsmcp__browser-tools__getNetworkLogsmcp__browser-tools__getNetworkErrorsmcp__browser-tools__takeScreenshotmcp__browser-tools__getSelectedElementmcp__browser-tools__wipeLogsmcp__browser-tools__runAccessibilityAuditmcp__browser-tools__runPerformanceAuditmcp__browser-tools__runSEOAuditmcp__browser-tools__runNextJSAuditmcp__browser-tools__runBestPracticesAuditmcp__browser-tools__runDebuggerModemcp__browser-tools__runAuditModeBrowser operations are asynchronous and use a job-based approach:
This approach prevents client timeouts while allowing complex browser operations to complete.
The MCP Operator maintains persistent state when browsers are created with a project name:
src/mcp_operator/: Main package
__init__.py: Package initialization__main__.py: Entry point for packageserver.py: MCP server implementationbrowser.py: Browser operator implementationcua/: Computer Use API components
agent.py: Agent implementationcomputer.py: Computer interfaceutils.py: Utility functionsrun-server: Script to run the MCP serverrun-tests: Script to run unit and integration testsrun-test-harness: Script to run with MCP InspectorFor debugging, use the MCP Inspector:
# Use the included run-test-harness script ./run-test-harness # Or directly: npx @modelcontextprotocol/inspector ./run-server
This provides a web interface to test your MCP server.