🌐 通过简单的MCP接口,使AI助手能够浏览和从网页中提取内容。
Web Browser MCP Server通过消息控制协议(MCP)为AI模型提供了浏览网站、提取内容以及理解网页的能力。它支持使用CSS选择器进行智能内容提取,并具备强大的错误处理功能。
要通过Smithery自动为Claude Desktop安装Web Browser Server:
npx -y @smithery/cli install web-browser-mcp-server --client claude
使用uv安装:
uv tool install web-browser-mcp-server
开发环境:
# Clone and set up development environment
git clone https://github.com/blazickjp/web-browser-mcp-server.git
cd web-browser-mcp-server
# Create and activate virtual environment
uv venv
source .venv/bin/activate
# Install with test dependencies
uv pip install -e ".[test]"

将此配置添加到您的MCP客户端配置文件中:
{
"mcpServers": {
"web-browser-mcp-server": {
"command": "uv",
"args": [
"tool",
"run",
"web-browser-mcp-server"
],
"env": {
"REQUEST_TIMEOUT": "30"
}
}
}
}

开发环境:
{
"mcpServers": {
"web-browser-mcp-server": {
"command": "uv",
"args": [
"--directory",
"path/to/cloned/web-browser-mcp-server",
"run",
"web-browser-mcp-server"
],
"env": {
"REQUEST_TIMEOUT": "30"
}
}
}
}

服务器提供了一个强大的网页浏览工具:
使用可选的CSS选择器浏览并从网页中提取内容:
# Basic webpage fetch
result = await call_tool("browse_webpage", {
"url": "https://example.com"
})
# Target specific content with CSS selectors
result = await call_tool("browse_webpage", {
"url": "https://example.com",
"selectors": {
"headlines": "h1, h2",
"main_content": "article.content",
"navigation": "nav a"
}
})

通过环境变量进行配置:
变量 | 目的 | 默认值 |
---|---|---|
REQUEST_TIMEOUT |
网页请求超时时间(秒) | 30 |
运行测试套件:
python -m pytest
本项目依据MIT许可证发布。详情请参见LICENSE文件。