No description
Find a file
User 0a80d0ef26 searcher: skip empty-result instances in failover
Treat an instance that answers 200 with zero results as a soft failure and
fall through to the next instance, instead of short-circuiting on it. This
makes public SearXNG backups actually take over when the primary instance is
up but its upstream engines are rate-limited (200-but-empty). Only return []
when every responding instance is empty; still raise SearchError only when
every instance hard-fails (unreachable/non-200/non-JSON).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 17:04:43 -07:00
config searcher: skip empty-result instances in failover 2026-07-07 17:04:43 -07:00
searxng M3: search — SearXNG container, searcher service, orchestrator /search 2026-07-05 22:07:10 -07:00
services searcher: skip empty-result instances in failover 2026-07-07 17:04:43 -07:00
.env.example Raise renderer throughput: default concurrency 4->8, env-tunable CPU/RAM 2026-07-06 12:11:18 -07:00
.gitignore Prepare for public release: AGPL license, curl installer, bearer-token auth 2026-07-06 00:43:04 -07:00
docker-compose.override.yml.example Prepare for public release: AGPL license, curl installer, bearer-token auth 2026-07-06 00:43:04 -07:00
docker-compose.yml Raise renderer throughput: default concurrency 4->8, env-tunable CPU/RAM 2026-07-06 12:11:18 -07:00
install.sh Point installer and docs at new public repo URL (pub/local-web-search) 2026-07-06 02:10:03 -07:00
LICENSE Prepare for public release: AGPL license, curl installer, bearer-token auth 2026-07-06 00:43:04 -07:00
PRD.md Prepare for public release: AGPL license, curl installer, bearer-token auth 2026-07-06 00:43:04 -07:00
README.md Point installer and docs at new public repo URL (pub/local-web-search) 2026-07-06 02:10:03 -07:00

Local Web Search Stack (LWSS)

Self-hosted, private web search + page retrieval for local LLMs — a functional replacement for Tavily/Serper/Firecrawl, exposed as an MCP server. No SaaS in the request path, no per-call fees, no LLM anywhere in the stack (the calling model does its own ranking/filtering; extraction is purely mechanical).

See PRD.md for full requirements and architecture.

Install (VPS / LXC / any Linux or macOS host)

One command — installs Docker if missing, clones the repo, generates a strong API key + SearXNG secret, and brings the stack up:

curl -fsSL https://git.neilbantoc.dev/pub/local-web-search/raw/branch/main/install.sh | bash

When it finishes it prints your MCP endpoint, the generated API key, and the exact claude mcp add command to run on your client machine. Re-running the installer updates the checkout and restarts the stack, preserving your .env (and API key). Useful overrides: LWSS_DIR, LWSS_PORT, LWSS_BIND, LWSS_BRANCH (see the top of install.sh).

Quick start (manual / development)

cp .env.example .env
# set LWSS_API_KEY to a strong value (or `openssl rand -hex 32`); empty disables auth
docker compose up --build

The orchestrator is the only exposed service, on port 8000.

Authentication

If LWSS_API_KEY is set (the installer always sets it), every request to the MCP and REST endpoints must carry Authorization: Bearer <key>. /health is always exempt so healthchecks/monitors work. An empty key disables auth — only do that on trusted/LAN networks.

MCP (primary interface)

Streamable HTTP endpoint: http://<host>:8000/mcp

Claude Code:

claude mcp add --transport http local-web-search http://<host>:8000/mcp \
  --header "Authorization: Bearer <your-api-key>"

Tools:

Tool Args Returns
web_search query, max_results=5, include_content=true ranked results: url, title, snippet (+ cleaned page text)
fetch_url url cleaned text, title, metadata for one page

REST (debug / non-MCP clients)

AUTH='-H "Authorization: Bearer <your-api-key>"'   # omit if auth is disabled
curl -X POST localhost:8000/search           -d '{"query":"..."}'            -H 'content-type: application/json' -H "Authorization: Bearer <key>"
curl -X POST localhost:8000/search/contents  -d '{"query":"...","max_results":5}' -H 'content-type: application/json' -H "Authorization: Bearer <key>"
curl -X POST localhost:8000/scrape           -d '{"url":"https://..."}'      -H 'content-type: application/json' -H "Authorization: Bearer <key>"
curl localhost:8000/health   # no auth needed

Every REST response includes a trace: per-stage timings, cache hit/miss, and a degraded list naming stages that fell back or partially failed.

Architecture

MCP client → orchestrator (REST+MCP) → searcher → searxng (local)
                                     → renderer (Playwright)
                                     → extractor (Trafilatura + readability)
                          redis: search / rendered-HTML / extracted-text caches
  • searcher — queries the SearXNG pool (file-based list in config/instances.yml, failover mode; add instances there for rotation later), normalizes + dedups results.
  • renderer — always renders via headless Chromium; single browser, pooled contexts, concurrency cap + queue; per-domain rate limiting (Redis token window); render retry with DNS-failure fast-fail; Redis HTML cache.
  • extractor — mechanical extraction only: Trafilatura (precision → recall) then readability-lxml fallback; flags thin content.
  • orchestrator — sequencing, per-URL parallelism, partial-result degradation, scrape-result cache, aggregated /health.

Configuration

All knobs are env vars (see .env.example): cache TTLs, renderer concurrency and timeouts, per-domain rate limit, stage timeouts, SearXNG secret. The SearXNG instance pool lives in config/instances.yml (hand-editable; reloaded on change without restart).

Security notes

When exposed beyond a trusted LAN, the API key is the only thing gating your renderer — anyone with the key (or with the port open and auth disabled) can drive it to fetch arbitrary URLs. Guidance:

  • Always keep LWSS_API_KEY set on any internet-reachable host.
  • Prefer a private tunnel. Set ORCHESTRATOR_BIND=127.0.0.1 and reach the box over Tailscale / WireGuard / Cloudflare Tunnel rather than opening the port. That keeps the endpoint off the public internet entirely.
  • Renderer SSRF surface: fetch_url / /scrape will fetch any URL given to it, including internal addresses reachable from the container. Don't run this where it can reach sensitive internal services you wouldn't want proxied.
  • Rotate the key by editing .env and docker compose up -d orchestrator.

Development

Python services run directly with uvicorn (--app-dir services/<name>), the renderer with node services/renderer/src/server.js. Everything degrades gracefully without Redis (caching disabled). Each service is curl-able in isolation on its own port: searcher 8001, renderer 8002, extractor 8003.

License

AGPL-3.0. If you run a modified version as a network service, the license requires you to make your modified source available to its users.