
SearchHub
io.github.woodcoalPublished by GitHub account woodcoalv0.1.10Updated Oct 24, 2026
Aggregate Serper, Tavily, Exa and AnySearch behind one MCP-ready API with key rotation and quotas.
Overview
A self-hosted search gateway that lets an assistant run web searches across Serper, Tavily, Exa and AnySearch with key rotation, quotas and failover.
- What you can do
- Run unified web searches across several search providers, with time range, site, region and language filters where supported, and see which provider and key answered each request and whether results were degraded or parameters ignored. Check provider health, circuit-breaker state and available key counts. List the configured providers and their capabilities. Manage provider keys, caller API keys, quotas, logs and usage through a local admin console and CLI.
- When to use it
- Use it when an agent needs dependable web search and you want one endpoint in front of several paid or free search APIs, so a failing key or provider does not leave the assistant without results. It suits self-hosted setups where keys and call logs should stay on your own machine.
- Requirements
- Runs locally with Node.js 22 or newer via npx or a global npm install, or with Docker. Needs provider API keys for Serper, Tavily, Exa or AnySearch, entered in the admin console or CLI, plus a caller API key for clients. Set SEARCHHUB_SECRET for key encryption and an admin password; SEARCHHUB_HOME sets the data directory.
Installation
In SourceWeft
- Open SearchHub in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
SearchHub
English README · npm · Issues
[npm version] [license] [node] [CI]
面向 AI Agent 的自托管搜索容灾网关
One protocol. Multiple search providers. Automatic key rotation and failover.
SearchHub 把 Serper、Tavily、Exa、AnySearch 等搜索 API 统一成一个协议,并集中处理 API Key 轮换、限流、配额、供应商故障切换和熔断。
它适合需要稳定联网搜索能力的 MCP 客户端、AI Agent、RAG 应用和内部自动化服务。
为什么用 SearchHub?
单个搜索供应商出问题时,Agent 不应该直接失明:
- 一个 Key 失效或被限流:自动换下一个 Key
- 一个供应商故障或超时:自动切换供应商
- 连续失败:熔断,冷却后半开探测
- 每个 Key 独立设置 QPS、日/月/总配额
- HTTP API、CLI、MCP 和管理后台统一提供
- 自托管,密钥和调用日志留在自己的机器上
界面预览
概览 —— 每个供应商一张卡片:熔断状态、可用密钥数、冷却 / 隔离数、能力标签与全局默认配额。
搜索调试 —— 一次真实调用。第一把 Exa 密钥返回配额耗尽(keyQuotaExhausted),系统自动换到第二把并成功返回;调用链路把两次尝试完整记录下来,一眼看清命中了谁、用了哪把 Key、有没有降级。
供应商配置 —— 按权重(优先级)排序。全局 QPS 与三级配额可作为兜底,密钥里留空的字段自动继承;超时、单供应商最大换 Key 次数、熔断阈值与冷却时长都可调。
用量统计 —— 按尝试次数统计,含最近 24 小时与 14 天趋势、分供应商与分密钥的成功率、平均耗时与最近错误。
API 接口 —— 内置接口文档:认证方式、请求格式,以及各供应商在分页上的能力差异。
30 秒启动
npm 全局安装
要求 Node.js >= 22(推荐 24,Active LTS)。
打开 http://localhost:8787,使用启动日志中的管理密码登录后台。
生产环境务必固定管理密码和加密密钥。下面两条命令可以直接生成强随机值:
这两项保护的是你的上游供应商密钥和后台登录。示例里出现的
change-me只是占位符,直接沿用会让密钥加密形同虚设。 另外SEARCHHUB_SECRET一旦设置就不要再改——它是密钥的解密主密钥,改了之后已落盘的供应商密钥将无法解密。
npx 试用
Docker Compose
打开 http://localhost:8787。数据和日志保存在 Docker 命名卷 searchhub-data 中。
注意 heredoc 用的是
<<EOF而不是<<'EOF'(不加引号),这样$(...)才会被 shell 展开。用 Node 生成是因为它本来就是本项目的运行前提,且跨平台一致。 生成的值请自行保管:SEARCHHUB_SECRET是供应商密钥的解密主密钥,设置之后不要再更改;改了已落盘的密钥将无法解密。
不要把
.env提交到 Git。生产环境请把SEARCHHUB_ADMIN_PASSWORD、SEARCHHUB_SECRET和供应商密钥放进安全的 Secret 管理系统。
第一次配置
- 登录管理后台。
- 进入「供应商」或「密钥管理」,添加 Serper / Tavily / Exa / AnySearch 的 API Key。
- 进入「API 授权」,创建一个调用方 API Key。
- 用调试台或 CLI 发起第一次搜索。
供应商密钥和 SearchHub 调用方 API Key 是两套凭据:前者用于访问上游搜索服务,后者用于保护 SearchHub 接口。
MCP 接入
本地 stdio
适用于 Claude Desktop、Cursor、Cline 等支持本地 MCP 的客户端:
CLI 会从当前目录 .env 和环境变量读取配置。也可以指定数据目录:
Streamable HTTP
主服务启动后默认提供 /mcp:
也可以只启动 MCP HTTP 服务:
内置工具:
HTTP API
健康检查无需认证:
搜索接口使用管理后台「API 授权」生成的 Key,或 SEARCHHUB_API_TOKEN:
返回结果统一为:
meta.attempts 会记录本次请求尝试过的 Key 和供应商,便于排障和观察降级。
接口概览:
内置供应商
SearchHub 会将各供应商不同的返回结构和错误码归一化。新增供应商只需实现适配器、错误分类并注册到 src/providers/index.ts。
容灾与配额
每个供应商和每把 Key 都可以设置:
- QPS
- 日配额
- 月配额
- 总配额
- 优先级和超时
- 单供应商最大换 Key 次数
- 熔断阈值和冷却时长
内置默认配额(按各家免费额度预设)、供应商级继承规则与三级配额的完整说明见 docs/quotas.md; 故障分类的完整判定表与熔断状态机见 docs/providers.md。
CLI
数据、日志与安全
默认目录:
- 供应商密钥使用
SEARCHHUB_SECRET进行 AES-256-GCM 加密存储;未配置时会告警。 - 管理密码只保存 scrypt 哈希。
- API Key 只保存 SHA-256 哈希,明文只在创建时显示一次。
- 日志中的 API Key、管理令牌和密钥原文会脱敏。
SEARCHHUB_LOG_RETENTION_DAYS默认保留 14 天,设为0表示永久保留。- 运行时冷却状态、统计和用量在内存中,重启会清零;多实例部署需要 Redis 化改造。
完整环境变量见 .env.example。
目录结构、后台密码优先级与找回、数据目录迁移、认证体系细节见 docs/data-and-settings.md;
日志切分与保留策略、调用日志、用量统计口径见 docs/logging.md。
从源码开发
前端开发服务器:
Docker 部署
项目提供多阶段 Dockerfile 和 docker-compose.yml:
容器内默认:
- 基于 Node.js 24(Active LTS)
- 监听
0.0.0.0:8787 SEARCHHUB_HOME=/data- 使用非 root 用户
searchhub(uid 10001) GET /api/health作为 Docker healthcheck/data保存配置、密钥密文和日志
文档
许可
MIT License。第三方搜索服务的使用仍需遵守各自的服务条款和计费规则。
Copyright (c) 2026 木炭 [email protected]
Source: README.md at commit 53349e3
Tools
0Version history
1- v0.1.10LatestSep 21, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts