m

mcp自然语言浏览器交互工具

@JovaniPink/mcp-browser-use
1 Stars 507 次浏览 JovaniPink 更新于 2026-08-23

启用AI代理通过自然语言与网络浏览器交互,功能包括自动浏览、表单填写、基于视觉的元素检测以及用于系统浏览器控制的结构化JSON响应。

该服务暂未提供标准配置,请参考 README 手动接入

可用工具 (1 个)

该服务在 MCP 协议中暴露的工具,AI 可按需调用

run_browser_agent 2 个参数 需填 1 项

Handle run-browser-agent tool calls.

必填参数:task

服务介绍

MCP 服务器与浏览器使用

smithery 徽章

用于 browser-use 的 MCP 服务器。

概述

此仓库包含了 browser-use 库的服务器,该库提供了一个强大的浏览器自动化系统,使 AI 代理能够通过自然语言与网页浏览器交互。服务器基于 Anthropic 的 Model Context Protocol (MCP) 构建,并与 browser-use 库无缝集成。

功能

  1. 浏览器控制
  • 通过自然语言进行自动化的浏览器交互
  • 导航、表单填写、点击和滚动功能
  • 标签页管理和截图功能
  • Cookie 和状态管理
  1. 代理系统
  • 在 custom_agent.py 中实现自定义代理
  • 基于视觉的元素检测
  • 结构化的 JSON 响应动作
  • 消息历史管理和摘要
  1. 配置
  • 基于环境的 API 密钥和设置配置
  • Chrome 浏览器设置(调试端口、持久性)
  • 模型提供商选择及参数

依赖项

本项目依赖于以下 Python 包:

Package Version Description
Pillow >=10.1.0 Python Imaging Library (PIL) fork that adds image processing capabilities to your Python interpreter.
browser-use ==0.1.19 A powerful browser automation system that enables AI agents to interact with web browsers through natural language. The core library that powers this project's browser automation capabilities.
fastapi >=0.115.6 Modern, fast (high-performance) web framework for building APIs with Python 3.7+ based on standard Python type hints. Used to create the server that exposes the agent's functionality.
fastmcp >=0.4.1 A framework that wraps FastAPI for building MCP (Model Context Protocol) servers.
instructor >=1.7.2 Library for structured output prompting and validation with OpenAI models. Enables extracting structured data from model responses.
langchain >=0.3.14 Framework for developing applications with large language models (LLMs). Provides tools for chaining together different language model components and interacting with various APIs and data sources.
langchain-google-genai >=2.1.1 LangChain integration for Google GenAI models, enabling the use of Google's generative AI capabilities within the LangChain framework.
langchain-openai >=0.2.14 LangChain integrations with OpenAI's models. Enables using OpenAI models (like GPT-4) within the LangChain framework. Used in this project for interacting with OpenAI's language and vision models.
langchain-ollama >=0.2.2 Langchain integration for Ollama, enabling local execution of LLMs.
openai >=1.59.5 Official Python client library for the OpenAI API. Used to interact directly with OpenAI's models (if needed, in addition to LangChain).
python-dotenv >=1.0.1 Reads key-value pairs from a .env file and sets them as environment variables. Simplifies local development and configuration management.
pydantic >=2.10.5 Data validation and settings management using Python type annotations. Provides runtime enforcement of types and automatic model creation. Essential for defining structured data models in the agent.
pyperclip >=1.9.0 Cross-platform Python module for copy and paste clipboard functions.
uvicorn >=0.22.0 ASGI web server implementation for Python. Used to serve the FastAPI application.

组件

资源

服务器实现了一个浏览器自动化系统,包括:

  • 与浏览器使用库集成以进行高级浏览器控制
  • 自定义浏览器自动化功能
  • 基于代理的交互系统,具备视觉能力
  • 持久状态管理
  • 可自定义的模型设置

需求

  • 操作系统(Linux, macOS, Windows;我们尚未在Docker或Microsoft WSL上测试)
  • Python 3.11 或更高版本
  • uv(快速Python包安装器)
  • Chrome/Chromium 浏览器
  • Claude Desktop

快速开始

Claude Desktop

在MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
在Windows: %APPDATA%/Claude/claude_desktop_config.json

通过Smithery安装

要通过Smithery自动为Claude Desktop安装Browser Use:

npx -y @smithery/cli install @JovaniPink/mcp-browser-use --client claude
"mcpServers": {
  "mcp_server_browser_use": {
    "command": "uvx",
    "args": [
      "mcp-server-browser-use",
    ],
    "env": {
      "OPENAI_ENDPOINT": "https://api.openai.com/v1",
      "OPENAI_API_KEY": "",
      "ANTHROPIC_API_KEY": "",
      "GOOGLE_API_KEY": "",
      "AZURE_OPENAI_ENDPOINT": "",
      "AZURE_OPENAI_API_KEY": "",
      // "DEEPSEEK_ENDPOINT": "https://api.deepseek.com",
      // "DEEPSEEK_API_KEY": "",
      // Set to false to disable anonymized telemetry
      "ANONYMIZED_TELEMETRY": "false",
      // Chrome settings
      "CHROME_PATH": "",
      "CHROME_USER_DATA": "",
      "CHROME_DEBUGGING_PORT": "9222",
      "CHROME_DEBUGGING_HOST": "localhost",
      // Set to true to keep browser open between AI tasks
      "CHROME_PERSISTENT_SESSION": "false",
      // Model settings
      "MCP_MODEL_PROVIDER": "anthropic",
      "MCP_MODEL_NAME": "claude-3-5-sonnet-20241022",
      "MCP_TEMPERATURE": "0.3",
      "MCP_MAX_STEPS": "30",
      "MCP_USE_VISION": "true",
      "MCP_MAX_ACTIONS_PER_STEP": "5",
      "MCP_TOOL_CALL_IN_CONTENT": "true"
    }
  }
}

环境变量

关键环境变量:

# API Keys
ANTHROPIC_API_KEY=anthropic_key

# Chrome Configuration
# Optional: Path to Chrome executable
CHROME_PATH=/path/to/chrome
# Optional: Chrome user data directory
CHROME_USER_DATA=/path/to/user/data
# Default: 9222
CHROME_DEBUGGING_PORT=9222
# Default: localhost
CHROME_DEBUGGING_HOST=localhost
# Keep browser open between tasks
CHROME_PERSISTENT_SESSION=false

# Model Settings
# Options: anthropic, openai, azure, deepseek
MCP_MODEL_PROVIDER=anthropic
# Model name
MCP_MODEL_NAME=claude-3-5-sonnet-20241022
MCP_TEMPERATURE=0.3
MCP_MAX_STEPS=30
MCP_USE_VISION=true
MCP_MAX_ACTIONS_PER_STEP=5

开发

设置

  1. 克隆仓库:
git clone https://github.com/JovaniPink/mcp-browser-use.git
cd mcp-browser-use
  1. 创建并激活虚拟环境:
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. 安装依赖项:
uv sync
  1. 启动服务器
uv run mcp-browser-use

调试

对于调试,请使用MCP Inspector:

npx @modelcontextprotocol/inspector uv --directory /path/to/project run mcp-server-browser-use

Inspector将显示一个用于调试界面的URL。

浏览器操作

服务器支持通过自然语言执行各种浏览器操作:

  • 导航:访问URL、前进/后退、刷新
  • 交互:点击、输入、滚动、悬停
  • 表单:填写表单、提交、选择选项
  • 状态:获取页面内容、截屏
  • 标签页:创建、关闭、切换标签页
  • 视觉:根据视觉外观查找元素
  • Cookies & 存储:管理浏览器状态

安全性

需要注意的是,有一些Chrome设置被设定为允许服务器控制浏览器。这是一个安全风险,应谨慎使用。该服务器不打算用于生产环境。

安全详情:SECURITY.MD

贡献

我们欢迎对该项目的贡献。请遵循以下步骤:

  1. 分叉此仓库。
  2. 创建你的特性分支:git checkout -b my-new-feature
  3. 提交更改:git commit -m 'Add some feature'
  4. 推送到分支:git push origin my-new-feature
  5. 提交拉取请求。

对于重大变更,请先打开一个问题来讨论你想要更改的内容。请适当更新测试以反映所做的任何更改。

相关 MCP 服务