MCP 浏览器使用
使用此 MCP 可以实现什么
该项目旨在使 AI 代理能够使用模型上下文协议 (MCP) 和 Selenium 执行网络使用、浏览器自动化、抓取和自动化。
我们的使命是让人工智能代理在最少的人工监督下完成任何网络任务——所有这些都基于自然语言指令。
如何使用此 MCP
请参阅modelcontextprotocol.io 上的 MCP 文档。
请注意,您需要在 MCP 配置文件指向的 Python 环境中安装所有依赖项。例如,如果您指向python
或python3
可执行文件,则指向全局 Python 环境。通常,最好指向虚拟环境,例如:
/Users/yourname/code/mcp_browser_use/.venv/bin/python
如果您已将此存储库克隆到本地code
文件夹,则您的 MCP 配置文件应如下所示:
{
"mcpServers": {
"mcp_browser_use": {
"command": "/Users/janspoerer/code/mcp_browser_use/.venv/bin/python",
"args": [
"/Users/janspoerer/code/mcp_browser_use/mcp_browser_use"
]
}
}
}
它将在这里(在 macOS 中): /Users/janspoerer/Library/Application Support/Claude/claude_desktop_config.json
。
请参阅requirements.txt
来了解您需要安装哪些依赖项。
重启 Claude 来检查 JSON 配置是否有效。如果出现问题,Claude 会将 MCP 的错误日志发送给你。
如果设置成功,您将在 Claude 的“新聊天”窗口右下角看到一个小锤子图标。锤子旁边显示的是 MCP 提供的功能数量。
点击锤子可以看到类似这样的内容:
Available MCP Tools
Claude can use tools provided by specialized servers using Model Context Protocol. Learn more about MCP.
click_element
Click an element on the page. Args: session_id: Session ID of the browser selector: CSS selector, XPath, or ID of the element to click selector_type: Type of selector (css, xpath, id)
From server: mcp_browser_use
close_browser
Close a browser session. Args: session_id: Session ID of the browser to close
From server: mcp_browser_use
fill_text
Input text into an element. Args: session_id: Session ID of the browser selector: CSS selector, XPath, or ID of the input field text: Text to enter into the field selector_type: Type of selector (css, xpath, id) clear_first: Whether to clear the field before entering text
From server: mcp_browser_use
navigate
Navigate to a URL. Args: session_id: Session ID of the browser url: URL to navigate to
From server: mcp_browser_use
scroll
Scroll the page. Args: session_id: Session ID of the browser x: Horizontal scroll amount in pixels y: Vertical scroll amount in pixels
From server: mcp_browser_use
send_keys
Send keyboard keys to the browser. Args: session_id: Session ID of the browser key: Key to send (e.g., ENTER, TAB, etc.) selector: CSS selector, XPath, or ID of the element to send keys to (optional) selector_type: Type of selector (css, xpath, id)
From server: mcp_browser_use
start_browser
Start a new browser session. Args: headless: Whether to run the browser in headless mode
From server: mcp_browser_use
take_screenshot
Take a screenshot of the current page. Args: session_id: Session ID of the browser
From server: mcp_browser_use
演示视频(YouTube)