Files
agent/mcp/web_search/README.md
T
kicer ae13be047c 部署:改为 IP:端口直连(无 nginx-proxy),同步文档
- docker-compose: expose 3000 → ports(WEB_SEARCH_PORT/IMAGE_GEN_PORT/VIDEO_GEN_PORT 可覆盖,默认 8081/8082/8083),去掉 VIRTUAL_HOST/VIRTUAL_PORT/CERT_NAME
- video_gen: PUBLIC_BASE_URL 改为环境变量(默认 http://localhost:8083)
- 新增根 README:部署步骤、端口变量、端口暴露范围(8083 需对外,8081/8082 建议只内网)
- image_gen / video_gen / web_search README: 域名 URL 全部改为 IP:端口
2026-09-15 17:54:46 +08:00

50 lines
1.8 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,默认映射到宿主机 `8081`(可用 `WEB_SEARCH_PORT` 覆盖):
```bash
docker compose build mcp_web_search && docker compose up -d mcp_web_search
curl http://localhost:8081/health
# {"name":"web_search","version":"...","transport":"http/sse","port":3000}
```
agent 侧走 `my-app-network` 用容器名访问(`http://mcp_web_search:3000/`),不依赖宿主机端口;
该服务**无服务端鉴权**,暴露到公网会被白嫆(消耗上游免费额度),建议不对公网放行 8081。