# Web Analysis MCP
MCP 服务 - 使用 SearXNG 搜索 + Creeper 爬虫,通过 LLM 总结网页内容后返回,避免 token 超限问题。
## 特性
- 🔍 SearXNG 智能搜索 + 域名过滤
- 🧠 LLM 智能过滤 + 主题分类
- 🕷️ Creeper 高效爬虫 + 并发处理
- 🧠 DeepSeek LLM 智能总结
- ⚡ 缓存优化 + 批量处理
## 快速开始
### 1. 安装依赖
```bash
git clone <repository-url>
cd web-analysis-mcp
npm install
```
### 2. 部署外部服务
```bash
# SearXNG 搜索引擎
docker run -d -p 8086:8080 searxng/searxng
# Creeper 爬虫
git clone https://github.com/ihub-tech/Creeper.git /home/lyf/workspaces/creeper
cd /home/lyf/workspaces/creeper && pip install -r requirements.txt
```
### 3. 配置环境变量
```bash
cp .env.example .env
# 编辑 .env 文件,配置以下必需项:
SEARXNG_BASE_URL=http://127.0.0.1:8086
CREEPER_PATH=/home/lyf/workspaces/creeper
SUMMARY_API_KEY=sk-your-deepseek-key-here
# 可选配置
FILTER_MAX_RESULTS=8
DOMAIN_BLACKLIST=pinterest.com,facebook.com,instagram.com
DOMAIN_WHITELIST=github.com,stackoverflow.com
# LLM 智能过滤(可选)
FILTER_LLM_ENABLED=true
FILTER_LLM_API_KEY=sk-your-filter-api-key
FILTER_LLM_BASE_URL=https://api.deepseek.com
FILTER_LLM_MODEL=glm-4.5-air
```
### 4. 获取 API Key
- DeepSeek: https://platform.deepseek.com/
- 智谱 AI: https://open.bigmodel.cn/
- ModelScope (国内): https://dashscope.aliyuncs.com/
### 5. 运行
```bash
# 开发模式
npm run dev
# 生产模式
npm run build && npm start
```
### 6. Claude Desktop 配置
```json
{
"mcpServers": {
"web-analysis": {
"command": "node",
"args": ["/path/to/web-analysis-mcp/dist/index.js"],
"env": {
"SEARXNG_BASE_URL": "http://127.0.0.1:8086",
"CREEPER_PATH": "/home/lyf/workspaces/creeper",
"SUMMARY_API_KEY": "sk-your-key"
}
}
}
}
```
## 可用工具
| 工具 | 描述 | 主要参数 |
|------|------|----------|
| `web_search` | 智能搜索 + 爬取 + 总结 | query, max_results, include_domains, exclude_domains |
## 智能过滤机制
### 规则过滤
- **黑名单过滤**: 排除低质量域名
- **白名单优先**: 白名单结果排在前面
- **数量限制**: 保留指定数量的高质量结果
- **去重机制**: 移除重复链接
### LLM 智能过滤(可选)
启用后使用 LLM 进行主题分类和关联性过滤:
- 识别 10 种主题类型:编程、军事、政治、历史、科学、科技、娱乐、体育、金融、其他
- 单次调用完成主题分类和结果筛选
- 大幅降低后续总结成本
```bash
# 规则过滤配置
FILTER_MAX_RESULTS=8
DOMAIN_BLACKLIST=pinterest.com,facebook.com
DOMAIN_WHITELIST=github.com,stackoverflow.com
# LLM 过滤配置
FILTER_LLM_ENABLED=true
FILTER_LLM_MODEL=glm-4.5-air
```
## 测试
```bash
# 安装测试工具
npm install -g @modelcontextprotocol/inspector
# 开发模式测试(推荐)
npm run test:dev
# 生产模式测试
npm run test:inspector
```
## 故障排除
### 常见问题
**SearXNG 连接失败**:
```bash
curl http://127.0.0.1:8086/search?q=test&format=json
```
**Creeper 错误**:
```bash
cd /path/to/creeper && python creeper.py --help
```
**调试模式**:
```bash
LOG_LEVEL=debug npm run dev
```
## 文档链接
- [SearXNG 文档](https://docs.searxng.org/)
- [Creeper 项目](https://github.com/ihub-tech/Creeper)
## License
MIT