浏览器自动化MCP服务器

一个通过AI代理控制网页浏览器的MCP服务器,支持SSE和stdio协议,适用于浏览器自动化任务。

  • by kontext-security
  • Python
  • 本地部署
  • 849 星标
  • 更新于
在 GitHub 查看 co-browser/browser-use-mcp-server

使用说明

浏览器使用mcp服务器

一个MCP服务器,使AI代理能够使用 浏览器使用.

🌐 想用Vibe浏览网页吗? 开源人工智能网络浏览器- VIBE浏览器.

🔗 管理多个MCP服务器? 通过以下方式简化您的开发工作流程 代理浏览器

先决条件

# Install prerequisites
curl -LsSf https://astral.sh/uv/install.sh | sh
uv tool install mcp-proxy
uv tool update-shell

环境

创建一个 .env 文件:

OPENAI_API_KEY=your-api-key
CHROME_PATH=optional/path/to/chrome
PATIENT=false  # Set to true if API calls should wait for task completion

安装

# Install dependencies
uv sync
uv pip install playwright
uv run playwright install --with-deps --no-shell chromium

用法

SSE模式

# Run directly from source
uv run server --port 8000

stdio模式

# 1. Build and install globally
uv build
uv tool uninstall browser-use-mcp-server 2>/dev/null || true
uv tool install dist/browser_use_mcp_server-*.whl

# 2. Run with stdio transport
browser-use-mcp-server run server --port 8000 --stdio --proxy-port 9000

客户端配置

SSE模式客户端配置

{
  "mcpServers": {
    "browser-use-mcp-server": {
      "url": "http://localhost:8000/sse"
    }
  }
}

stdio模式客户端配置

{
  "mcpServers": {
    "browser-server": {
      "command": "browser-use-mcp-server",
      "args": [
        "run",
        "server",
        "--port",
        "8000",
        "--stdio",
        "--proxy-port",
        "9000"
      ],
      "env": {
        "OPENAI_API_KEY": "your-api-key"
      }
    }
  }
}

配置位置

客户端 配置路径
光标 ./.cursor/mcp.json
风帆冲浪 ~/.codeium/windsurf/mcp_config.json
克劳德(Mac) ~/Library/Application Support/Claude/claude_desktop_config.json
克劳德(Windows) %APPDATA%\Claude\claude_desktop_config.json

特性

  • [x] 浏览器自动化:通过AI代理控制浏览器
  • [x] 双重运输:支持SSE和stdio协议
  • [x] VNC流媒体:实时观察浏览器自动化
  • [x] 异步任务:异步执行浏览器操作

地方发展

要在本地开发和测试软件包:

  1. 构建一个可分配的轮子:

    # From the project root directory
    uv build
    
  2. 将其安装为全局工具:

    uv tool uninstall browser-use-mcp-server 2>/dev/null || true
    uv tool install dist/browser_use_mcp_server-*.whl
    
  3. 从任何目录运行:

    # Set your OpenAI API key for the current session
    export OPENAI_API_KEY=your-api-key-here
    
    # Or provide it inline for a one-time run
    OPENAI_API_KEY=your-api-key-here browser-use-mcp-server run server --port 8000 --stdio --proxy-port 9000
    
  4. 更改后,重新生成并重新安装:

    uv build
    uv tool uninstall browser-use-mcp-server
    uv tool install dist/browser_use_mcp_server-*.whl
    

码头工人

使用Docker为运行服务器提供了一个一致和隔离的环境。

# Build the Docker image
docker build -t browser-use-mcp-server .

# Run the container with the default VNC password ("browser-use")
# --rm ensures the container is automatically removed when it stops
# -p 8000:8000 maps the server port
# -p 5900:5900 maps the VNC port
docker run --rm -p8000:8000 -p5900:5900 browser-use-mcp-server

# Run with a custom VNC password read from a file
# Create a file (e.g., vnc_password.txt) containing only your desired password
echo "your-secure-password" > vnc_password.txt
# Mount the password file as a secret inside the container
docker run --rm -p8000:8000 -p5900:5900 \
  -v $(pwd)/vnc_password.txt:/run/secrets/vnc_password:ro \
  browser-use-mcp-server

注: :ro 卷装载中的标志(-v)使密码文件在容器内为只读,以增加安全性。

客户端

# Browser-based viewer
git clone https://github.com/novnc/noVNC
cd noVNC
./utils/novnc_proxy --vnc localhost:5900

默认密码: browser-use (除非使用自定义密码方法覆盖)



示例

试着问你的AI:

open https://news.ycombinator.com and return the top ranked article

支持

对于问题或询问: Cobrow.xyz

明星历史