Skip to main content
Glama
ZDOSt
by ZDOSt

私有搜索网关

该项目是一个确定性的、自托管的搜索和页面检索后端,专为AI前端设计。它暴露一个兼容SearXNG的搜索端点,通过少量搜索引擎发现来源,打开最相关的页面,提取其实际内容,跟踪有限数量的相关同站链接,在本地对证据进行重新排序,并返回带引用的来源URL和页面提取的文本。

它不调用付费搜索API或内部语言模型。前端的模型接收检索到的证据并撰写答案。这使得服务保持私有、可预测,并且可供任何接受自定义SearXNG或JSON搜索提供商的前端使用。

运行组件

  • search-gateway:唯一面向客户端的服务,位于内部端口8080

  • searxng:网页、技术、新闻、图片和研究发现

  • reranker:本地BAAI/bge-reranker-base相关性排序

  • crawl4ai:支持JavaScript的爬虫,用于处理复杂页面

  • web-runner:通过Unix套接字对Crawl4AI和Playwright进行隔离控制

  • pdf-runner:网络隔离的PDF提取

  • safe-egress:阻止浏览器访问私有网络和元数据目标

  • redis:响应缓存和过期结果回退

该栈不发布任何主机端口。前端通过共享的Docker网络在以下地址访问它:

http://search-gateway:8080/search

连接到该共享网络的每个容器都可以调用网关。如果其他不相关的容器不应拥有访问权限,请使用专用的共享网络。

Related MCP server: bathys

系统要求

  • 64位Linux VPS

  • Docker Engine和Docker Compose v2.24.4或更新版本

  • 约10 GB可用磁盘空间用于镜像、Chromium和排序模型

  • 建议16 GB RAM以运行完整栈

提供的上限总计约10.5 GB,不包括共享内存和正常的Docker开销。这些是限制值,而非预留值,但在16 GB主机上会留出有用的余量。首次构建较慢,因为它会下载Chromium、Crawl4AI镜像和排序模型。

全新安装

如果Docker网络尚不存在,请先创建一次:

docker network inspect docker-stacks_app-network >/dev/null 2>&1 || \
  docker network create docker-stacks_app-network

克隆并配置项目:

git clone https://github.com/ZDOSt/Research-MCP.git
cd Research-MCP
cp .env.example .env
chmod 600 .env

生成两个不同的密钥:

openssl rand -hex 32
openssl rand -hex 32

编辑.env文件,将SEARXNG_SECRET和CRAWL4AI_API_TOKEN替换为这些值。仅当前端使用不同的外部Docker网络时,才更改CLIENT_DOCKER_NETWORK。

验证并启动完整栈:

docker compose config --quiet
docker compose up -d --build --wait
docker compose ps

不需要ports:条目。除非您有意将网关暴露在Docker外部,否则不要添加。

验证

从网关容器运行健康检查:

docker compose exec -T search-gateway python -c \
  "import urllib.request; print(urllib.request.urlopen('http://127.0.0.1:8080/healthz').read().decode())"

从共享网络上的任何容器运行真实搜索。将your-frontend-container替换为anythingllm、librechat或其他容器名称:

docker exec your-frontend-container sh -lc \
  "wget -qO- 'http://search-gateway:8080/search?q=how+to+install+docker+compose&format=json' | head -c 1000"

响应应包含results、来源URL、提取的content和诊断信息。搜索摘要仅作为明确标记的回退使用,当网站阻止提取或请求达到截止时间时使用。

前端设置

在前端要求SearXNG URL的地方,使用以下基础URL:

http://search-gateway:8080

如果它要求完整的搜索路径,请使用:

http://search-gateway:8080/search

AnythingLLM需要完整的搜索路径,即使其字段标记为SearXNG API Base URL。将其配置为:

http://search-gateway:8080/search

标准请求为:

GET /search?q=your+question&format=json

支持的查询参数包括:

  • language=auto

  • time_range=day|week|month|year

  • categories=general,it,news,science,images

  • max_results=1..8

  • mode=auto|quick|balanced|deep

当未提供类别时,网关会根据请求推断有用的SearXNG类别。auto模式对简单查询使用快速模式,对技术问题和推荐使用平衡模式。

对于直接集成,还提供更丰富的JSON端点:

POST /v1/research
Content-Type: application/json

{
  "query": "What are the recommended settings for an AW3426DW?",
  "mode": "balanced",
  "max_results": 5,
  "language": "auto",
  "categories": []
}

更新

在VPS上的仓库目录中:

git pull --ff-only
docker compose config --quiet
docker compose up -d --build --remove-orphans --wait
docker compose ps

正常更新时无需运行docker compose down。现有的Redis缓存和排序模型下载会保留在命名卷中。

运维

常用命令:

docker compose ps
docker compose logs --tail=200 search-gateway searxng reranker
docker compose logs --tail=200 crawl4ai web-runner safe-egress pdf-runner
docker compose restart search-gateway
docker compose down
docker compose up -d --wait

docker compose down会保留命名卷。docker compose down -v会删除缓存和下载的排序模型,仅应在有意进行完全重置时使用。

限制

该项目在文档、故障排除、产品设置、游戏、当前信息和一般研究方面可以接近托管搜索工具,但无法保证与商业提供商相同的覆盖范围。无密钥的搜索引擎可能对数据中心IP进行速率限制,某些网站会阻止所有自动化浏览器,并且没有单个VPS拥有Google、Brave或付费答案引擎使用的专有搜索索引。网关通过多个发现提供商、并发提取、本地排序、有限的浏览器回退、缓存以及诚实的部分结果(而非编造答案)来弥补这些限制。

Maintenance

ActivitySlowing
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    A
    maintenance
    Provides local-first web intelligence over MCP with tools for search, fetch, crawl, extract, cache, find-similar, research, and autonomous agent loops, requiring no API keys.
    10
    875 npm
    5,455
    AGPL 3.0
  • A
    license
    A
    quality
    A
    maintenance
    Enables AI agents to run local deep-research workflows via a single MCP stdio server, combining web search, page extraction, query-aware distillation, and caching without cloud quotas. It exposes tools for deep research, search, and single or batch URL reading.
    6
    79 PyPI
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Gives MCP-capable agents live web access: search the web, scrape pages into Markdown (including JavaScript-heavy and bot-protected sites), and extract named fields as JSON, with job polling, token-aware content offloading, and built-in research guidance. Ships as a self-hostable stdio or HTTP service with spend caps and per-request key support.
    7
    MIT
  • F
    license
    B
    quality
    B
    maintenance
    Exposes web research tools to MCP agents so they can search the web, open and read pages, grep fetched content, manage a local SQLite corpus, and generate citations. Includes a containerized fetcher for headless browsing and PDF extraction.
    7
    -