Files
agent/mcp/web_search/README.md
T
kicer b97b13095f 部署初始化收敛:init.sh 不再生成配置,只做 .env + 公网地址 + 初始 admin
- scripts/init.sh 重写:不再生成模型/MCP/用户配置;只维护 .env(幂等复用密钥、保留手改变量)、
  探测 PUBLIC_BASE_URL、config.yml 缺失时写入初始管理员(admin/admin)。已存在绝不改写;
  Docker 误建的空目录自动删除重建,非空目录报错退出;去掉 --env-only 参数
- config.js:config.yml 缺失/为空/被误建成目录都能正常启动(不再 EISDIR 崩);PATCH 在文件
  缺失时以空文档继续并自动创建;public_link 改为 config.yml 优先、PUBLIC_BASE_URL 兜底
- compose:ASR_URL 固定为 http://mcp_asr:3000;agent-core 注入 PUBLIC_BASE_URL;
  token 缺失提示改指 scripts/init.sh
- 删除 .env.example(与 init.sh/compose 重复),引用改指 README
- 移除仓库内所有 VIRTUAL_HOST/VIRTUAL_PORT/CERT_NAME 关联(特定部署的反代约定,不进仓库)
- 同步 README / AGENTS.md / config.example.yml / init_host.sh / wxbot / mcp 文档
2026-10-25 08:42:26 +08:00

51 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# web_search
免费网页搜索 MCP server 的本地重构版(上游开源实现:[@sheep233_/dsh-web-search-free](https://github.com/sheep-programmer/dsh-web-search-free),MIT)。
零运行时依赖,只用 Node 内置 `fetch`(Node ≥ 18),**无需 npm install,直接 `node server.js` 启动**。
## 结构
| 文件 | 职责 |
| --- | --- |
| `core.js` | 搜索后端:Parallel(默认)/ Exa(备用)免费 MCP 端点封装 + 响应解析 |
| `mcp.js` | MCP 协议层:`web_search` 工具定义 + JSON-RPC 分发 |
| `server.js` | 入口:CLI 参数 + stdio / HTTP/SSE 双传输 |
## 本地启动
```bash
# HTTP/SSE 模式(默认 127.0.0.1:3100)
node server.js --http --port 3100
# stdio 模式(Claude Code / Codex 直接拉起时用)
node server.js
```
MCP 端点:
- `POST /` — Streamable HTTP(也接受 `Accept: text/event-stream`)
- `GET /sse` + `POST /messages` — 老式 SSE 传输
- `GET /health` — 健康检查
环境变量(均可选):
- `EXA_API_KEY` — 提升 Exa 匿名限额
- `SEARCH_TIMEOUT_MS` — 上游搜索超时,默认 30000
## Docker
`docker-compose.yml` 中的 `mcp_web_search` 服务直接构建本目录,Dockerfile 已改为拷贝源码启动(不再有 `npm install -g`)。
容器内监听 3000,**默认不占宿主端口**:agent 走 `agent-mcp-net` 按容器名访问
(`http://mcp_web_search:3000/`)。要从宿主机 curl 调试,自行给该服务加 `ports` 映射。
```bash
docker compose build mcp_web_search && docker compose up -d mcp_web_search
# 不占端口的健康检查
docker exec mcp_web_search node -e "fetch('http://localhost:3000/health').then(r=>r.text()).then(console.log)"
# {"name":"web_search","version":"...","transport":"http/sse","port":3000}
```
该服务**无服务端鉴权**(上游是免费端点),**永远不要**对外映射端口——会被白嫆搜索额度。