基于MCP(模型-控制器-提示)的浏览器自动化Chrome服务器。
npx -y @smithery/cli install @dlwjdtn535/mcp-chrome-server --client claude
根据您的环境选择以下配置方法之一:
Windows 设置:
{
"mcpServers": {
"mcp-chrome-server": {
"command": "uv",
"args": [
"run",
"--directory",
"%LOCALAPPDATA%\\Programs\\mcp-chrome-server\\src",
"mcp-chrome-server"
],
"env": {
"CHROME_PROFILE_PATH": "%LOCALAPPDATA%\\Google\\Chrome\\User Data"
}
}
}
}
macOS 设置:
{
"mcpServers": {
"mcp-chrome-server": {
"command": "uv",
"args": [
"run",
"--directory",
"/usr/local/bin/mcp-chrome-server/src",
"mcp-chrome-server"
],
"env": {
"CHROME_PROFILE_PATH": "$HOME/Library/Application Support/Google/Chrome"
}
}
}
}
Linux 设置:
{
"mcpServers": {
"mcp-chrome-server": {
"command": "uv",
"args": [
"run",
"--directory",
"/usr/local/bin/mcp-chrome-server/src",
"mcp-chrome-server"
],
"env": {
"CHROME_PROFILE_PATH": "$HOME/.config/google-chrome"
}
}
}
}
每个操作系统的默认Chrome配置文件路径:
| 操作系统 | 路径 |
|---|---|
| Windows | %LOCALAPPDATA%\Google\Chrome\User Data |
| macOS | ~/Library/Application Support/Google/Chrome |
| Linux | ~/.config/google-chrome |
使用系统密钥链安全地存储和管理登录信息:
# 保存凭证
result = tool_save_credentials(
site="example.com",
username="your_username",
password="your_password"
)
# 获取已保存的凭证
result = tool_get_credentials(
site="example.com",
username="your_username"
)
# 打开浏览器
result = tool_open_browser()
# 导航到URL
result = tool_navigate(url="https://example.com")
# 关闭浏览器
result = tool_close_browser()
result = tool_web_login(
url="https://example.com/login",
credentials={
"username": "your_username",
"password": "your_password"
},
selectors={
"username": "#id",
"password": "#pw",
"submit": ".login-button"
}
)
特殊处理:
# 点击元素
result = tool_click(selector=".button")
# 输入文本
result = tool_type(
selector="#input-field",
text="Hello, World!"
)
# 获取文本
result = tool_get_text(selector=".content")
# 获取多个元素
result = tool_get_elements(selector=".items")
Chrome 配置文件使用
防止自动化检测
安全性