返回市场
浏览器使用mcp服务器

浏览器使用mcp服务器

作者:kontext-dev774 星标更新:2025-07-10

项目介绍

browser-use-mcp-server

<div align="center">

Twitter URL Discord PyPI version

一个使用browser-use控制网络浏览器的MCP服务器。

🌐 想要浏览网页? 开源的人工智能驱动的网络浏览器 - Vibe 浏览器

🔗 管理多个MCP服务器? 使用 agent-browser 简化你的开发流程。

</div>

预备条件

  • uv - 快速的Python包管理器
  • Playwright - 浏览器自动化
  • mcp-proxy - 标准输入输出模式所需
# 安装预备条件
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  # 如果需要等待任务完成再返回API调用结果,请设置为true

安装

# 安装依赖
uv sync
uv pip install playwright
uv run playwright install --with-deps --no-shell chromium

使用方法

SSE模式

# 直接从源运行
uv run server --port 8000

标准输入输出模式

# 1. 构建并全局安装
uv build
uv tool uninstall browser-use-mcp-server 2>/dev/null || true
uv tool install dist/browser_use_mcp_server-*.whl

# 2. 使用标准输入输出传输运行
browser-use-mcp-server run server --port 8000 --stdio --proxy-port 9000

客户端配置

SSE模式客户端配置

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

标准输入输出模式客户端配置

{
  "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./.cursor/mcp.json
Windsurf~/.codeium/windsurf/mcp_config.json
Claude (Mac)~/Library/Application Support/Claude/claude_desktop_config.json
Claude (Windows)%APPDATA%\Claude\claude_desktop_config.json

功能

  • 浏览器自动化:通过AI代理控制浏览器
  • 双传输:支持SSE和标准输入输出协议
  • VNC流媒体:实时观看浏览器自动化操作
  • 异步任务:异步执行浏览器操作

本地开发

为了在本地开发和测试该包:

  1. 构建可分发的wheel文件:

    # 在项目根目录下
    uv build
    
  2. 作为全局工具安装它:

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

    # 设置当前会话的OpenAI API密钥
    export OPENAI_API_KEY=your-api-key-here
    
    # 或者提供一次性的密钥
    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

使用Docker可以提供一致且隔离的环境来运行服务器。

# 构建Docker镜像
docker build -t browser-use-mcp-server .

# 运行容器,默认VNC密码为"browser-use"
# --rm 确保容器停止时自动删除
# -p 8000:8000 映射服务器端口
# -p 5900:5900 映射VNC端口
docker run --rm -p8000:8000 -p5900:5900 browser-use-mcp-server

# 使用自定义VNC密码运行
# 创建一个文件(例如,vnc_password.txt)仅包含你的密码
echo "your-secure-password" > vnc_password.txt
# 将密码文件挂载为容器内的秘密
docker run --rm -p8000:8000 -p5900:5900 \
  -v $(pwd)/vnc_password.txt:/run/secrets/vnc_password:ro \
  browser-use-mcp-server

注意:卷挂载中的:ro标志使容器内密码文件为只读,以增加安全性。

VNC查看器

# 基于浏览器的查看器
git clone https://github.com/novnc/noVNC
cd noVNC
./utils/novnc_proxy --vnc localhost:5900

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

<div align="center"> <img width="428" alt="VNC截图" src="https://gips2.baidu.com/it/u=1770249911,1625192852&fm=3081&app=3081&f=PNG?w=2154&h=1376" /> <br><br> <img width="428" alt="VNC截图" src="https://gips1.baidu.com/it/u=308206876,1226232755&fm=3081&app=3081&f=PNG?w=2872&h=2306" /> </div>

示例

尝试询问你的AI:

打开 https://news.ycombinator.com 并返回排名最高的文章

支持

对于问题或咨询:cobrowser.xyz

Star历史

<div align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=co-browser/browser-use-mcp-server&type=Date&theme=dark" /> <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=co-browser/browser-use-mcp-server&type=Date" /> <img alt="Star历史图表" src="https://api.star-history.com/svg?repos=co-browser/browser-use-mcp-server&type=Date" /> </picture> </div>