内容
+ 大模型 + LibreChat + Playwright MCP
本项目演示了如何使用 **LibreChat**大模型**、**Playwright MCP** 运行一个完全本地的 AI 驱动的浏览器自动化助手。
AI 代理可以理解自然语言指令,启动浏览器,使用 Playwright 执行操作,并总结结果。
---
# 架构
```
用户
│
▼
LibreChat
│
▼
大模型 (Ollama)
│
▼
Playwright MCP 服务器
│
▼
Chrome 浏览器
```
---
# 前置条件
## 硬件
* 16 GB RAM 或更高
* SSD 硬盘,20 GB 空闲空间
* GPU 推荐(可选)
## 软件
* Docker Desktop
* Git
* Node.js 20+
* Ollama
---
# 技术栈
* Docker
* LibreChat Ollama
* 大模型
* Playwright MCP
* Chrome 浏览器
---
# 步骤 1 – 安装 Ollama
从以下地址安装 Ollama:
https://ollama.com
或使用 brewbash
brew install ollama
```
验证安装:
```bash --version
```
---
# 步骤 2 – 下载模型
拉取大模型
```bash
ollama pull qwen3:8b
```
验证:
```bash
ollama list
```
---
步骤 3 – 启动 Ollama
```bash
ollama serve
```
默认端点:
```
http://localhost:11434
```
步骤 4 – 克隆 LibreChat
```bash
git clone https://github.com/danny-avila/LibreChat.git
cd LibreChat
```
---
# 步骤 5 – 配置 LibreChat
创建或编辑:
```
librechat.yaml
```
示例 MCP 配置:
```yaml
mcpServers:
playwright:
type: sse
url: http://host.docker.internal:8931/sse
timeout: 120000
mcpSettings:
allowedDomains:
- 'host.docker.internal:8931'
- 'localhost:8931'
```
示例 Ollama 配置:
```yaml
- name: "Ollama"
apiKey: "ollama"
baseURL: "http://host.docker.internal:11434/v1"
models:
default:
- "qwen3:8b"
fetch: true
titleConvo: true
titleModel: "current_model"
summarize: false
summaryModel: "current_model"
modelDisplayLabel: "Ollama"
```
要验证 Ollama 配置的连接,请在终端中运行以下命令:
`docker exec -it LibreChat curl http://host.docker.internal:11434/api/tags`
查看我的账户中更新的项目 [mfaisalkhatri/LibreChat](https://github.com/mfaisalkhatri/LibreChat)
---
# 步骤 6 – 在 LibreChat 中配置 Ollama
示例端点
```
http://host.docker.internal:11434
```
提供商:Ollama
* 模型:qwen3:8b
---
# 步骤 7 – 启动 Playwright MCP
打开另一个终端。
```bash
npx @playwright/mcp@latest \
--host 0.0.0.0 \
--allowed-hosts "*" \
--port 8931 \
```
服务器启动于
```
http://localhost:8931
```
---
# 步骤 8 – 安装 Chrome
```bash
playwright install chrome
```
---
# 步骤 9 – 启动
```bash
docker compose up -d
```
打开
localhost:3080
```
创建您的账户。
---
#Chat 创建 AI 代理
- 将大模型添加到代理
# 推荐的代理设置
| 设置 | 推荐值 |
| ----------------- | ----------------- |
| 温度 | 0. |
| Top P | 0.9 |
| 频率惩罚 | 0 |
| 存在惩罚 | 0 |
| 推理努力 | 中等 |
| 推理总结 | 自动 |
- 将 Playwright MCP 服务器添加到代理
- 从 `AI-Instructions.txt` 添加指令
---
# 示例提示
打开 https://playwright.dev 并点击 **Get Started**。
---
导航到 GitHub 并搜索 Playwright。
---
打开 Google 并搜索 "Playwright MCP"。
---
导航到 https://parabank.parasoft.com/parabank/index.htm
定位 "用户名" 字段使用 "name=username"
在 "用户名" 字段中输入 "john"。
定位 "密码" 字段使用 "name=password"
在 "密码" 字段中输入 "demo"。
定位 "登录" 按钮使用 "input[type="submit"]
点击 "登录按钮
验证是否显示 "账户概览" 页面
---
# 执行流程
```
用户提示
│
▼
Libre │
▼
大模型 │
▼wright MCP
│
▼
Chrome
│
▼
浏览器操作
│
▼
执行结果
│
▼
AI 总结
```
---
# 故障排除
## MCP 连接关闭
验证 MCP 服务器是否正在运行。
```bash
npx @playwright/mcp@latest \
--host 0.0.0.0 \
--allowed-hosts "*" \
--port 8931 \
```
---
## Chrome 未找到
安装 Chrome
```bash
npx playwright install chrome
```
---
## Ollama 未检测到
确保 Ollama 正在运行。
```bash
ollama serve
```
验证:
```
http://localhost:11434
```
---
## LibreChat 无法访问 MCP
如果 LibreChat 在 Docker 中运行,请使用:
```
host.docker.internal
```
代替
```
localhost
```
---
## 模型出现幻觉
将温度降低至:
```
0.2
```
为 AI 代理使用更严格的指令。
---
# 有用的命令
启动 Ollama
```bash
ollama serve
```
列出模型
```bash
ollama list
```
下载模型
```bash
ollama pull qwen3:8b
```
运行模型
```bash
ollama run qwen3:8b
```
wright MCP
```bash
npx @playwright/mlatest \
--host 0.0.0.0 \
--allowed-hosts "*" \
--port 8931 \
```
安装 Chrome
```bash
npx playwright install chrome
```
启动 LibreChat
```bash
docker compose up -d
```
查看 Docker 中的 LibreChat 日志
```bash
docker logs Librechat -```
停止 LibreChat
```bash
docker compose down
```